Fix attached ToolTips using the timeout of the last shown tool tip
Attached ToolTips share a single ToolTip item and set properties
(such as delay) on it before showing it. Before 63899f3185
,
this wasn't a problem, but now QQuickToolTip has its own show()
function that QQuickToolTipAttached calls. QQuickToolTipAttached
passes -1 by default, which QQuickToolTip sees as the "default"
and hence doesn't set a timeout at all. However, since that
QQuickToolTip instance is shared, it still has a previous
timeout value from the last time it was shown by a different
QQuickToolTipAttached object.
So, instead of QQuickToolTipAttached passing the timeout to
QQuickToolTip::show(), make it set it on the QQuickToolTip
instead. This ensures that it has the correct value if no
timeout was specified for an attached tool tip.
Task-number: QTBUG-74226
Change-Id: Iceed17bbb640a929fae3b9c975519df36cc2d210
Reviewed-by: Frederik Gladhorn <frederik.gladhorn@qt.io>
This commit is contained in:
parent
73914e00db
commit
1ef176b5da
|
@ -534,7 +534,8 @@ void QQuickToolTipAttached::show(const QString &text, int ms)
|
|||
tip->resetHeight();
|
||||
tip->setParentItem(qobject_cast<QQuickItem *>(parent()));
|
||||
tip->setDelay(d->delay);
|
||||
tip->show(text, ms >= 0 ? ms : d->timeout);
|
||||
tip->setTimeout(ms >= 0 ? ms : d->timeout);
|
||||
tip->show(text);
|
||||
}
|
||||
|
||||
/*!
|
||||
|
|
|
@ -347,4 +347,69 @@ TestCase {
|
|||
verify(tip.visible)
|
||||
tryCompare(tip, "visible", false)
|
||||
}
|
||||
|
||||
Component {
|
||||
id: timeoutButtonRowComponent
|
||||
|
||||
Row {
|
||||
Button {
|
||||
text: "Timeout: 1"
|
||||
ToolTip.text: text
|
||||
ToolTip.visible: down
|
||||
ToolTip.timeout: 1
|
||||
}
|
||||
|
||||
Button {
|
||||
text: "Timeout: -1"
|
||||
ToolTip.text: text
|
||||
ToolTip.visible: down
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// QTBUG-74226
|
||||
function test_attachedTimeout() {
|
||||
var row = createTemporaryObject(timeoutButtonRowComponent, testCase)
|
||||
verify(row)
|
||||
|
||||
// Press the button that has no timeout; it should stay visible.
|
||||
var button2 = row.children[1]
|
||||
mousePress(button2)
|
||||
compare(button2.down, true)
|
||||
tryCompare(button2.ToolTip.toolTip, "opened", true)
|
||||
|
||||
// Wait a bit to make sure that it's still visible.
|
||||
wait(50)
|
||||
compare(button2.ToolTip.toolTip.opened, true)
|
||||
|
||||
// Release and should close.
|
||||
mouseRelease(button2)
|
||||
compare(button2.down, false)
|
||||
tryCompare(button2.ToolTip, "visible", false)
|
||||
|
||||
// Now, press the first button that does have a timeout; it should close on its own eventually.
|
||||
var button1 = row.children[0]
|
||||
mousePress(button1)
|
||||
compare(button1.down, true)
|
||||
// We use a short timeout to speed up the test, but tryCompare(...opened, true) then
|
||||
// fails because the dialog has already been hidden by that point, so just check that it's
|
||||
// immediately visible, which is more or less the same thing.
|
||||
compare(button1.ToolTip.visible, true)
|
||||
tryCompare(button1.ToolTip, "visible", false)
|
||||
mouseRelease(button2)
|
||||
|
||||
// Now, hover over the second button again. It should still stay visible until the mouse is released.
|
||||
mousePress(button2)
|
||||
compare(button2.down, true)
|
||||
tryCompare(button2.ToolTip.toolTip, "opened", true)
|
||||
|
||||
// Wait a bit to make sure that it's still visible.
|
||||
wait(50)
|
||||
compare(button2.ToolTip.toolTip.opened, true)
|
||||
|
||||
// Release and should close.
|
||||
mouseRelease(button2)
|
||||
compare(button2.down, false)
|
||||
tryCompare(button2.ToolTip, "visible", false)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue