aboutsummaryrefslogtreecommitdiffstats
path: root/src/quicktemplates2/qquickdrawer.cpp
diff options
context:
space:
mode:
authorJ-P Nurmi <jpnurmi@qt.io>2016-09-01 13:20:09 +0200
committerJ-P Nurmi <jpnurmi@qt.io>2016-09-02 07:26:45 +0000
commit79636b847d9ee04475cf1a0415996d483ad32593 (patch)
tree39995f826b4366977f319446e355e7d045d1973a /src/quicktemplates2/qquickdrawer.cpp
parentf59e5d7bbd17c79ca2f06d79897212a5fc9b6ee7 (diff)
Fix QQuickDrawerPrivate::handleMouseReleaseEvent()
QQuickDrawer operates on scene/window coordinates, se it must use QMouseEvent::windowPos() instead of QMouseEvent::x() or y() which return local coordinates. QMouseEvent::windowPos() is already used in handleMousePressEvent() and handleMouseMoveEvent(). The delta between the press and the release point is used to calculate the velocity. The two points must be specified in the same coordinate space to get correct velocity calculation. Change-Id: Ic9ee904e0b2b022a58b674ee663d8963eb2417a6 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Diffstat (limited to 'src/quicktemplates2/qquickdrawer.cpp')
-rw-r--r--src/quicktemplates2/qquickdrawer.cpp11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/quicktemplates2/qquickdrawer.cpp b/src/quicktemplates2/qquickdrawer.cpp
index 056a636f..b5bebd9b 100644
--- a/src/quicktemplates2/qquickdrawer.cpp
+++ b/src/quicktemplates2/qquickdrawer.cpp
@@ -283,7 +283,8 @@ bool QQuickDrawerPrivate::handleMouseReleaseEvent(QQuickItem *item, QMouseEvent
bool wasGrabbed = popupItem->keepMouseGrab();
if (wasGrabbed) {
- velocityCalculator.stopMeasuring(event->pos(), event->timestamp());
+ const QPointF releasePoint = event->windowPos();
+ velocityCalculator.stopMeasuring(releasePoint, event->timestamp());
const qreal velocity = velocityCalculator.velocity().x();
if (position > 0.7 || velocity > openCloseVelocityThreshold) {
@@ -293,25 +294,25 @@ bool QQuickDrawerPrivate::handleMouseReleaseEvent(QQuickItem *item, QMouseEvent
} else {
switch (edge) {
case Qt::LeftEdge:
- if (event->x() - pressPoint.x() > 0)
+ if (releasePoint.x() - pressPoint.x() > 0)
transitionManager.transitionEnter();
else
transitionManager.transitionExit();
break;
case Qt::RightEdge:
- if (event->x() - pressPoint.x() < 0)
+ if (releasePoint.x() - pressPoint.x() < 0)
transitionManager.transitionEnter();
else
transitionManager.transitionExit();
break;
case Qt::TopEdge:
- if (event->y() - pressPoint.y() > 0)
+ if (releasePoint.y() - pressPoint.y() > 0)
transitionManager.transitionEnter();
else
transitionManager.transitionExit();
break;
case Qt::BottomEdge:
- if (event->y() - pressPoint.y() < 0)
+ if (releasePoint.y() - pressPoint.y() < 0)
transitionManager.transitionEnter();
else
transitionManager.transitionExit();