Fix regression in pressDelay behavior.
authorMichael Brasser <michael.brasser@live.com>
Fri, 4 Oct 2013 02:14:08 +0000 (21:14 -0500)
committerThe Qt Project <gerrit-noreply@qt-project.org>
Fri, 4 Oct 2013 13:40:52 +0000 (15:40 +0200)
Don't deliver a press event when a Flickable is moved before
the pressDelay expires. This prevents delegates flickering
between pressed and unpressed states when beginning to
flick a Flickable.

Fixes regression introduced by
429af6244518172e19abf7fecd7112f26bac6b31/
d02131e743597b9bd3070d986c61a1c91ea8317a.

Task-number: QTBUG-31168
Change-Id: Id4e853fabe99000837df3681acd8fc4e76d2e9b3
Reviewed-by: Martin Jones <martin.jones@jollamobile.com>
src/quick/items/qquickflickable.cpp
tests/auto/quick/qquickflickable/tst_qquickflickable.cpp

index 9b5532c..b94d8dd 100644 (file)
@@ -1246,15 +1246,6 @@ void QQuickFlickable::mouseMoveEvent(QMouseEvent *event)
 {
     Q_D(QQuickFlickable);
     if (d->interactive) {
-        if (d->delayedPressEvent) {
-            // A move beyond the threshold replays the press to give nested Flickables
-            // the opportunity to grab the gesture.
-            QPointF delta = event->localPos() - d->delayedPressEvent->localPos();
-            if (QQuickWindowPrivate::dragOverThreshold(qAbs(delta.x()), Qt::XAxis, event)
-                || QQuickWindowPrivate::dragOverThreshold(qAbs(delta.y()), Qt::YAxis, event)) {
-                d->replayDelayedPress();
-            }
-        }
         d->handleMouseMoveEvent(event);
         event->accept();
     } else {
index 4392055..3c518c5 100644 (file)
@@ -414,6 +414,23 @@ void tst_qquickflickable::pressDelay()
     // On release the clicked signal should be emitted
     QTest::mouseRelease(window.data(), Qt::LeftButton, 0, QPoint(150, 150));
     QCOMPARE(clickedSpy.count(),1);
+
+    // QTBUG-31168
+    QTest::mousePress(window.data(), Qt::LeftButton, 0, QPoint(150, 110));
+
+    // The press should not occur immediately
+    QVERIFY(mouseArea->property("pressed").toBool() == false);
+
+    QTest::mouseMove(window.data(), QPoint(150, 190));
+
+    // As we moved pass the drag threshold, we should never receive the press
+    QVERIFY(mouseArea->property("pressed").toBool() == false);
+    QTest::qWait(200);
+    QVERIFY(mouseArea->property("pressed").toBool() == false);
+
+    // On release the clicked signal should *not* be emitted
+    QTest::mouseRelease(window.data(), Qt::LeftButton, 0, QPoint(150, 190));
+    QCOMPARE(clickedSpy.count(),1);
 }
 
 // QTBUG-17361