aboutsummaryrefslogtreecommitdiffstats
path: root/src/quicktemplates2/qquicktooltip.cpp
diff options
context:
space:
mode:
authorJ-P Nurmi <jpnurmi@qt.io>2016-10-01 13:07:31 +0200
committerJ-P Nurmi <jpnurmi@qt.io>2016-10-02 12:48:59 +0000
commitbfaa08a335f21e6fdf533969779f806883fe27b0 (patch)
tree2f6ff3425b6ae74670a46922c51a7cb779508693 /src/quicktemplates2/qquicktooltip.cpp
parenteb7bf1825ede649ae35ebec91ef430686ae2c70a (diff)
Fix QQuickToolTip's delay and visibility
The imperative open() and close() methods used to be the only ways to open and close popups, but the visible-property was later made writable to allow declarative visibility bindings. Since then, it is no longer sufficient for QQuickToolTip to overshadow open() and close() in QML, because setting the visible-property would bypass these overshadowed method. There was a bit of duplicate code between setVisible(), open(), and close(). This change moves the logic to one place by changing open() and close() to call setVisible(). Furthermore, setVisible() has been made virtual to make it possible for QQuickToolTip to apply its delay properly. QQuickToolTip needs to control the delay and timeout timers before the effective visibility is applied on the popup. Task-number: QTBUG-55572 Change-Id: I5a109157f9ec5d0db145e710426665a9a8d7e870 Reviewed-by: J-P Nurmi <jpnurmi@qt.io>
Diffstat (limited to 'src/quicktemplates2/qquicktooltip.cpp')
-rw-r--r--src/quicktemplates2/qquicktooltip.cpp34
1 files changed, 16 insertions, 18 deletions
diff --git a/src/quicktemplates2/qquicktooltip.cpp b/src/quicktemplates2/qquicktooltip.cpp
index b793ada5..a1601ad6 100644
--- a/src/quicktemplates2/qquicktooltip.cpp
+++ b/src/quicktemplates2/qquicktooltip.cpp
@@ -244,6 +244,20 @@ void QQuickToolTip::setTimeout(int timeout)
emit timeoutChanged();
}
+void QQuickToolTip::setVisible(bool visible)
+{
+ Q_D(QQuickToolTip);
+ if (visible) {
+ if (!d->visible && d->delay > 0) {
+ d->startDelay();
+ return;
+ }
+ } else {
+ d->stopDelay();
+ }
+ QQuickPopup::setVisible(visible);
+}
+
QQuickToolTipAttached *QQuickToolTip::qmlAttachedProperties(QObject *object)
{
QQuickItem *item = qobject_cast<QQuickItem *>(object);
@@ -253,22 +267,6 @@ QQuickToolTipAttached *QQuickToolTip::qmlAttachedProperties(QObject *object)
return new QQuickToolTipAttached(object);
}
-void QQuickToolTip::open()
-{
- Q_D(QQuickToolTip);
- if (!d->visible && d->delay > 0)
- d->startDelay();
- else
- QQuickPopup::open();
-}
-
-void QQuickToolTip::close()
-{
- Q_D(QQuickToolTip);
- d->stopDelay();
- QQuickPopup::close();
-}
-
QFont QQuickToolTip::defaultFont() const
{
return QQuickControlPrivate::themeFont(QPlatformTheme::TipLabelFont);
@@ -295,10 +293,10 @@ void QQuickToolTip::timerEvent(QTimerEvent *event)
Q_D(QQuickToolTip);
if (event->timerId() == d->timeoutTimer.timerId()) {
d->stopTimeout();
- close();
+ QQuickPopup::setVisible(false);
} else if (event->timerId() == d->delayTimer.timerId()) {
d->stopDelay();
- QQuickPopup::open();
+ QQuickPopup::setVisible(true);
}
}