aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMartin Jones <martin.jones@jollamobile.com>2014-07-23 16:07:31 +1000
committerMartin Jones <martin.jones@jollamobile.com>2014-08-06 01:35:56 +0200
commitc85bfba382ca1ddf0573c8f59e95b25f804b83ff (patch)
treeff08c61e9fc017ba267bc387f377c4299d60b664 /src
parent89a01dcbc2d427e661c19d50c5b875b1dc54b2f9 (diff)
Synchronize PathView gesture grabbing with other items.
PathView didn't attempt to grab the gesture at the same event as other items. This prevented PathView from rightfully claiming the gesture before lower items in the stack. Use the same threshold test for PathView as used elsewhere. Task-number: QTBUG-37859 Change-Id: Ic57cb805ac979e41c3e35d86b2e7db781e61d69d Reviewed-by: Martin Jones <martin.jones@jollamobile.com>
Diffstat (limited to 'src')
-rw-r--r--src/quick/items/qquickpathview.cpp17
-rw-r--r--src/quick/items/qquickpathview_p_p.h1
2 files changed, 13 insertions, 5 deletions
diff --git a/src/quick/items/qquickpathview.cpp b/src/quick/items/qquickpathview.cpp
index 335e7611f1..601618d05e 100644
--- a/src/quick/items/qquickpathview.cpp
+++ b/src/quick/items/qquickpathview.cpp
@@ -1599,6 +1599,7 @@ void QQuickPathViewPrivate::handleMousePressEvent(QMouseEvent *event)
return;
startPoint = pointNear(event->localPos(), &startPc);
+ startPos = event->localPos();
if (idx == items.count()) {
qreal distance = qAbs(event->localPos().x() - startPoint.x()) + qAbs(event->localPos().y() - startPoint.y());
if (distance > dragMargin)
@@ -1621,8 +1622,6 @@ void QQuickPathView::mouseMoveEvent(QMouseEvent *event)
Q_D(QQuickPathView);
if (d->interactive) {
d->handleMouseMoveEvent(event);
- if (d->stealMouse)
- setKeepMouseGrab(true);
event->accept();
} else {
QQuickItem::mouseMoveEvent(event);
@@ -1639,9 +1638,17 @@ void QQuickPathViewPrivate::handleMouseMoveEvent(QMouseEvent *event)
qreal newPc;
QPointF pathPoint = pointNear(event->localPos(), &newPc);
if (!stealMouse) {
- QPointF delta = pathPoint - startPoint;
- if (qAbs(delta.x()) > qApp->styleHints()->startDragDistance() || qAbs(delta.y()) > qApp->styleHints()->startDragDistance()) {
- stealMouse = true;
+ QPointF posDelta = event->localPos() - startPos;
+ if (QQuickWindowPrivate::dragOverThreshold(posDelta.y(), Qt::YAxis, event) || QQuickWindowPrivate::dragOverThreshold(posDelta.x(), Qt::XAxis, event)) {
+ // The touch has exceeded the threshold. If the movement along the path is close to the drag threshold
+ // then we'll assume that this gesture targets the PathView. This ensures PathView gesture grabbing
+ // is in sync with other items.
+ QPointF pathDelta = pathPoint - startPoint;
+ if (qAbs(pathDelta.x()) > qApp->styleHints()->startDragDistance() * 0.8
+ || qAbs(pathDelta.y()) > qApp->styleHints()->startDragDistance() * 0.8) {
+ stealMouse = true;
+ q->setKeepMouseGrab(true);
+ }
}
} else {
moveReason = QQuickPathViewPrivate::Mouse;
diff --git a/src/quick/items/qquickpathview_p_p.h b/src/quick/items/qquickpathview_p_p.h
index e21f3757e6..59a7ac231b 100644
--- a/src/quick/items/qquickpathview_p_p.h
+++ b/src/quick/items/qquickpathview_p_p.h
@@ -135,6 +135,7 @@ public:
qreal currentItemOffset;
qreal startPc;
QPointF startPoint;
+ QPointF startPos;
qreal offset;
qreal offsetAdj;
qreal mappedRange;