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:
Friedemann Kleint 2014-10-21 17:31:55 +02:00
parent 68d83e82f8
commit 88057e3407
2 changed files with 8 additions and 2 deletions

View File

@ -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;

View File

@ -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);