diff options
author | Shawn Rutledge <shawn.rutledge@qt.io> | 2020-06-29 15:57:23 +0200 |
---|---|---|
committer | Shawn Rutledge <shawn.rutledge@qt.io> | 2020-06-30 09:08:23 +0200 |
commit | 8bd6342639721b7db08acf554c6bcd3e7ab04cb6 (patch) | |
tree | 9115fbfa5080edaa5efa5204ae11fe619b7f9a3a /tests | |
parent | b1493678fc295765ce93e565c5194e860e746436 (diff) |
Update the window cursor on mouse release
When a PointerHandler with a custom cursor deactivates, the cursor
wasn't restored until the next mouse move.
I was writing a test to ensure that there were no bugs analogous
to QTBUG-85303 with a handler that uses its active state to change
the cursor (unlike HoverHandler which changes it whenever the
mouse is hovering) and found this new bug.
Pick-to: 5.15
Fixes: QTBUG-85325
Task-number: QTBUG-85303
Change-Id: I4ea8dbd267046c8e972e723cc491bd44bbbfd7f2
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/quick/pointerhandlers/qquickdraghandler/data/dragMargin.qml | 3 | ||||
-rw-r--r-- | tests/auto/quick/pointerhandlers/qquickdraghandler/tst_qquickdraghandler.cpp | 12 |
2 files changed, 14 insertions, 1 deletions
diff --git a/tests/auto/quick/pointerhandlers/qquickdraghandler/data/dragMargin.qml b/tests/auto/quick/pointerhandlers/qquickdraghandler/data/dragMargin.qml index e5ca681bd5..60ea740105 100644 --- a/tests/auto/quick/pointerhandlers/qquickdraghandler/data/dragMargin.qml +++ b/tests/auto/quick/pointerhandlers/qquickdraghandler/data/dragMargin.qml @@ -1,4 +1,4 @@ -import QtQuick 2.12 +import QtQuick 2.15 Rectangle { color: "#333" @@ -13,6 +13,7 @@ Rectangle { DragHandler { id: dragHandler margin: 20 + cursorShape: Qt.ClosedHandCursor } Rectangle { diff --git a/tests/auto/quick/pointerhandlers/qquickdraghandler/tst_qquickdraghandler.cpp b/tests/auto/quick/pointerhandlers/qquickdraghandler/tst_qquickdraghandler.cpp index f6faa97b37..3740bf5709 100644 --- a/tests/auto/quick/pointerhandlers/qquickdraghandler/tst_qquickdraghandler.cpp +++ b/tests/auto/quick/pointerhandlers/qquickdraghandler/tst_qquickdraghandler.cpp @@ -407,6 +407,9 @@ void tst_DragHandler::dragFromMargin() // QTBUG-74966 QVERIFY(!dragHandler->active()); QCOMPARE(dragHandler->centroid().scenePosition(), scenePressPos); QCOMPARE(dragHandler->centroid().scenePressPosition(), scenePressPos); +#if QT_CONFIG(cursor) + QCOMPARE(window->cursor().shape(), Qt::ArrowCursor); +#endif p1 += QPoint(dragThreshold * 2, 0); QTest::mouseMove(window, p1); QTRY_VERIFY(dragHandler->active()); @@ -415,9 +418,18 @@ void tst_DragHandler::dragFromMargin() // QTBUG-74966 QCOMPARE(dragHandler->translation().x(), 0.0); // hmm that's odd QCOMPARE(dragHandler->translation().y(), 0.0); QCOMPARE(draggableItem->position(), originalPos + QPointF(dragThreshold * 2, 0)); +#if QT_CONFIG(cursor) + // The cursor doesn't change until the next event after the handler becomes active. + p1 += QPoint(1, 0); + QTest::mouseMove(window, p1); + QTRY_COMPARE(window->cursor().shape(), Qt::ClosedHandCursor); +#endif QTest::mouseRelease(window, Qt::LeftButton, Qt::NoModifier, p1); QTRY_VERIFY(!dragHandler->active()); QCOMPARE(dragHandler->centroid().pressedButtons(), Qt::NoButton); +#if QT_CONFIG(cursor) + QTRY_COMPARE(window->cursor().shape(), Qt::ArrowCursor); +#endif } void tst_DragHandler::snapMode_data() |