aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/quicktemplates2/qquicktooltip.cpp15
-rw-r--r--tests/auto/controls/data/tst_tooltip.qml26
2 files changed, 37 insertions, 4 deletions
diff --git a/src/quicktemplates2/qquicktooltip.cpp b/src/quicktemplates2/qquicktooltip.cpp
index 9d733c94..8b61375e 100644
--- a/src/quicktemplates2/qquicktooltip.cpp
+++ b/src/quicktemplates2/qquicktooltip.cpp
@@ -252,9 +252,18 @@ void QQuickToolTip::setVisible(bool visible)
{
Q_D(QQuickToolTip);
if (visible) {
- if (!d->visible && d->delay > 0) {
- d->startDelay();
- return;
+ if (!d->visible) {
+ // We are being made visible, and we weren't before.
+ if (d->delay > 0) {
+ d->startDelay();
+ return;
+ }
+ } else {
+ // We are being made visible, even though we already were.
+ // We've probably been re-opened before our exit transition could finish.
+ // In that case, we need to manually start the timeout, as that is usually
+ // done in itemChange(), which won't be called in this situation.
+ d->startTimeout();
}
} else {
d->stopDelay();
diff --git a/tests/auto/controls/data/tst_tooltip.qml b/tests/auto/controls/data/tst_tooltip.qml
index d98a7cc8..adea23ef 100644
--- a/tests/auto/controls/data/tst_tooltip.qml
+++ b/tests/auto/controls/data/tst_tooltip.qml
@@ -227,15 +227,39 @@ TestCase {
id: toolTipWithExitTransition
ToolTip {
+ Component.onCompleted: contentItem.objectName = "contentItem"
+
enter: Transition {
NumberAnimation { property: "opacity"; from: 0.0; to: 1.0; duration: 100 }
}
exit: Transition {
- NumberAnimation { property: "opacity"; from: 1.0; to: 0.0; duration: 1000 }
+ NumberAnimation { property: "opacity"; from: 1.0; to: 0.0; duration: 500 }
}
}
}
+ function test_openDuringExitTransitionWithTimeout() {
+ let control = createTemporaryObject(toolTipWithExitTransition, testCase, { timeout: 250 })
+ verify(control)
+ control.open()
+ verify(control.visible)
+ // Can't be fully open yet because the enter transition has only just started.
+ compare(control.opened, false)
+ compare(control.enter.running, true)
+ tryCompare(control, "opened", true)
+
+ // Let it timeout and begin the exit transition.
+ tryCompare(control, "opened", false)
+ verify(control.visible)
+ tryCompare(control.exit, "running", true)
+ verify(control.visible)
+
+ // Quickly open it again; it should still timeout eventually.
+ control.open()
+ tryCompare(control, "opened", true)
+ tryCompare(control.exit, "running", true)
+ }
+
function test_makeVisibleWhileExitTransitionRunning_data() {
return [
{ tag: "imperative", imperative: true },