diff options
author | Andrew den Exter <andrew.den.exter@jollamobile.com> | 2013-03-14 13:27:35 +1000 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-03-19 01:52:37 +0100 |
commit | b35d793648a24b229aac75ea43d5a175967304ca (patch) | |
tree | 63fd52a02374962a1f10eb97f275ff2cb1bdcad7 /tests | |
parent | 3a80424aeae19e838be03aa12a5243911ec3f020 (diff) |
Smooth dragging an item with MouseArea.
Calculate drag distance relative to the mouse position when a drag is
detected rather than the press position so there isn't a large change
in position on the first move.
Task-number: QTBUG-30188
Change-Id: I46918a7b3c62bdaef567b6a9fed651ce33434247
Reviewed-by: Martin Jones <martin.jones@jollamobile.com>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/declarative/qdeclarativemousearea/tst_qdeclarativemousearea.cpp | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/tests/auto/declarative/qdeclarativemousearea/tst_qdeclarativemousearea.cpp b/tests/auto/declarative/qdeclarativemousearea/tst_qdeclarativemousearea.cpp index 855ad602..0415c5c9 100644 --- a/tests/auto/declarative/qdeclarativemousearea/tst_qdeclarativemousearea.cpp +++ b/tests/auto/declarative/qdeclarativemousearea/tst_qdeclarativemousearea.cpp @@ -239,18 +239,18 @@ void tst_QDeclarativeMouseArea::dragging() QApplication::sendEvent(scene, &moveEvent); QVERIFY(drag->active()); - QCOMPARE(blackRect->x(), 72.0); - QCOMPARE(blackRect->y(), 72.0); + QCOMPARE(blackRect->x(), 61.0); + QCOMPARE(blackRect->y(), 61.0); QGraphicsSceneMouseEvent releaseEvent(QEvent::GraphicsSceneMouseRelease); - releaseEvent.setScenePos(QPointF(110, 110)); + releaseEvent.setScenePos(QPointF(122, 122)); releaseEvent.setButton(Qt::LeftButton); releaseEvent.setButtons(Qt::LeftButton); QApplication::sendEvent(scene, &releaseEvent); QVERIFY(!drag->active()); - QCOMPARE(blackRect->x(), 72.0); - QCOMPARE(blackRect->y(), 72.0); + QCOMPARE(blackRect->x(), 61.0); + QCOMPARE(blackRect->y(), 61.0); delete canvas; } @@ -741,14 +741,14 @@ void tst_QDeclarativeMouseArea::changeAxis() QApplication::sendEvent(scene, &moveEvent); QVERIFY(drag->active()); - QCOMPARE(blackRect->x(), 72.0); - QCOMPARE(blackRect->y(), 72.0); + QCOMPARE(blackRect->x(), 61.0); + QCOMPARE(blackRect->y(), 61.0); QCOMPARE(drag->axis(), QDeclarativeDrag::XandYAxis); /* When blackRect.x becomes bigger than 75, the drag axis is change to * Drag.YAxis by the QML code. Verify that this happens, and that the drag * movement is effectively constrained to the Y axis. */ - moveEvent.setScenePos(QPointF(133, 133)); + moveEvent.setScenePos(QPointF(144, 144)); moveEvent.setButton(Qt::LeftButton); moveEvent.setButtons(Qt::LeftButton); QApplication::sendEvent(scene, &moveEvent); @@ -757,7 +757,7 @@ void tst_QDeclarativeMouseArea::changeAxis() QCOMPARE(blackRect->y(), 83.0); QCOMPARE(drag->axis(), QDeclarativeDrag::YAxis); - moveEvent.setScenePos(QPointF(144, 144)); + moveEvent.setScenePos(QPointF(155, 155)); moveEvent.setButton(Qt::LeftButton); moveEvent.setButtons(Qt::LeftButton); QApplication::sendEvent(scene, &moveEvent); @@ -766,7 +766,7 @@ void tst_QDeclarativeMouseArea::changeAxis() QCOMPARE(blackRect->y(), 94.0); QGraphicsSceneMouseEvent releaseEvent(QEvent::GraphicsSceneMouseRelease); - releaseEvent.setScenePos(QPointF(144, 144)); + releaseEvent.setScenePos(QPointF(155, 155)); releaseEvent.setButton(Qt::LeftButton); releaseEvent.setButtons(Qt::LeftButton); QApplication::sendEvent(scene, &releaseEvent); |