diff options
author | Mitch Curtis <mitch.curtis@qt.io> | 2016-11-22 14:21:08 +0100 |
---|---|---|
committer | Mitch Curtis <mitch.curtis@qt.io> | 2016-11-22 13:43:58 +0000 |
commit | 08ba34d6a8cf7e7ab21ce51ca6aa7d812d035a67 (patch) | |
tree | dbd1b9aa096c47903629d092d7cf9a364f496aec | |
parent | 2c6553fa5ea19e7861b31587ac879da83ebb0925 (diff) |
SwipeDelegate: fix broken swiping after calling SwipeDelegate.close()
Reset the internal state when close() is called to ensure that it's
consistent.
Task-number: QTBUG-57243
Change-Id: Id52724e0eb296c3f8a4fc0a0587a04558b1d1ab6
Reviewed-by: J-P Nurmi <jpnurmi@qt.io>
-rw-r--r-- | src/quicktemplates2/qquickswipedelegate.cpp | 4 | ||||
-rw-r--r-- | tests/auto/controls/data/tst_swipedelegate.qml | 16 |
2 files changed, 17 insertions, 3 deletions
diff --git a/src/quicktemplates2/qquickswipedelegate.cpp b/src/quicktemplates2/qquickswipedelegate.cpp index fe678b80..caeea3e9 100644 --- a/src/quicktemplates2/qquickswipedelegate.cpp +++ b/src/quicktemplates2/qquickswipedelegate.cpp @@ -562,8 +562,12 @@ void QQuickSwipe::setComplete(bool complete) void QQuickSwipe::close() { + Q_D(QQuickSwipe); setPosition(0); setComplete(false); + d->wasComplete = false; + d->positionBeforePress = 0.0; + d->velocityCalculator.reset(); } class QQuickSwipeDelegatePrivate : public QQuickItemDelegatePrivate diff --git a/tests/auto/controls/data/tst_swipedelegate.qml b/tests/auto/controls/data/tst_swipedelegate.qml index fa2d218f..067fed1e 100644 --- a/tests/auto/controls/data/tst_swipedelegate.qml +++ b/tests/auto/controls/data/tst_swipedelegate.qml @@ -1054,17 +1054,17 @@ TestCase { text: "SwipeDelegate" width: 150 - onClicked: close() - swipe.right: Item { width: parent.width height: parent.height + + SwipeDelegate.onClicked: swipe.close() } } } function test_close() { - var control = swipeDelegateComponent.createObject(testCase); + var control = closeSwipeDelegateComponent.createObject(testCase); verify(control); swipe(control, 0.0, -1.0); @@ -1073,6 +1073,16 @@ TestCase { compare(control.swipe.rightItem.x, 0); tryCompare(control.swipe.rightItem, "x", control.background.x + control.background.width); + mousePress(control); + verify(control.swipe.rightItem.SwipeDelegate.pressed); + + mouseRelease(control); + verify(!control.swipe.rightItem.SwipeDelegate.pressed); + tryCompare(control.swipe, "position", 0); + + // Swiping after closing should work as normal. + swipe(control, 0.0, -1.0); + control.destroy(); } |