QSwipeGestureRecognizer: Fix gesture cancel on direction change.
Task-number: QTBUG-12736 Change-Id: I6d8d09843b45df17cb9158070f63b3397c5b4c07 Reviewed-by: Lars Knoll <lars.knoll@digia.com> Reviewed-by: Frederik Gladhorn <frederik.gladhorn@theqtcompany.com>
This commit is contained in:
parent
68d83e82f8
commit
88057e3407
@ -341,10 +341,10 @@ QGestureRecognizer::Result QSwipeGestureRecognizer::recognize(QGesture *state,
|
||||
if (d->horizontalDirection == QSwipeGesture::NoDirection)
|
||||
d->horizontalDirection = horizontal;
|
||||
if (d->verticalDirection != vertical || d->horizontalDirection != horizontal) {
|
||||
// the user has changed the direction!
|
||||
result = QGestureRecognizer::CancelGesture;
|
||||
} else {
|
||||
result = QGestureRecognizer::TriggerGesture;
|
||||
}
|
||||
result = QGestureRecognizer::TriggerGesture;
|
||||
} else {
|
||||
if (q->state() != Qt::NoGesture)
|
||||
result = QGestureRecognizer::TriggerGesture;
|
||||
|
@ -268,6 +268,7 @@ void tst_QGestureRecognizer::pinchGesture()
|
||||
|
||||
enum SwipeSubTest {
|
||||
SwipeLineSubTest,
|
||||
SwipeChangeDirectionSubTest,
|
||||
};
|
||||
|
||||
void tst_QGestureRecognizer::swipeGesture_data()
|
||||
@ -275,6 +276,7 @@ void tst_QGestureRecognizer::swipeGesture_data()
|
||||
QTest::addColumn<int>("swipeSubTest");
|
||||
QTest::addColumn<bool>("gestureExpected");
|
||||
QTest::newRow("Line") << int(SwipeLineSubTest) << true;
|
||||
QTest::newRow("ChangeDirection") << int(SwipeChangeDirectionSubTest) << false;
|
||||
}
|
||||
|
||||
void tst_QGestureRecognizer::swipeGesture()
|
||||
@ -311,6 +313,10 @@ void tst_QGestureRecognizer::swipeGesture()
|
||||
case SwipeLineSubTest:
|
||||
linearSequence(5, moveDelta, swipeSequence, points, &widget);
|
||||
break;
|
||||
case SwipeChangeDirectionSubTest:
|
||||
linearSequence(5, moveDelta, swipeSequence, points, &widget);
|
||||
linearSequence(3, QPoint(-moveDelta.x(), moveDelta.y()), swipeSequence, points, &widget);
|
||||
break;
|
||||
}
|
||||
|
||||
releaseSequence(swipeSequence, points, &widget);
|
||||
|
Loading…
Reference in New Issue
Block a user