diff options
Diffstat (limited to 'src/quick/items/qquickpincharea.cpp')
-rw-r--r-- | src/quick/items/qquickpincharea.cpp | 71 |
1 files changed, 39 insertions, 32 deletions
diff --git a/src/quick/items/qquickpincharea.cpp b/src/quick/items/qquickpincharea.cpp index f741a08512..98661d8f00 100644 --- a/src/quick/items/qquickpincharea.cpp +++ b/src/quick/items/qquickpincharea.cpp @@ -393,48 +393,55 @@ void QQuickPinchArea::updatePinch() if (angle > 180) angle -= 360; if (!d->inPinch || d->initPinch) { - if (d->touchPoints.count() >= 2 - && (qAbs(p1.x()-d->sceneStartPoint1.x()) >= dragThreshold - || qAbs(p1.y()-d->sceneStartPoint1.y()) >= dragThreshold - || qAbs(p2.x()-d->sceneStartPoint2.x()) >= dragThreshold - || qAbs(p2.y()-d->sceneStartPoint2.y()) >= dragThreshold)) { - d->initPinch = false; + if (d->touchPoints.count() >= 2) { + if (d->initPinch) { + if (!d->inPinch) + d->pinchStartDist = dist; + d->initPinch = false; + } d->sceneStartCenter = sceneCenter; d->sceneLastCenter = sceneCenter; d->pinchStartCenter = mapFromScene(sceneCenter); - d->pinchStartDist = dist; d->pinchStartAngle = angle; d->pinchLastScale = 1.0; d->pinchLastAngle = angle; d->pinchRotation = 0.0; d->lastPoint1 = p1; d->lastPoint2 = p2; - QQuickPinchEvent pe(d->pinchStartCenter, 1.0, angle, 0.0); - pe.setStartCenter(d->pinchStartCenter); - pe.setPreviousCenter(d->pinchStartCenter); - pe.setPreviousAngle(d->pinchLastAngle); - pe.setPreviousScale(d->pinchLastScale); - pe.setStartPoint1(mapFromScene(d->sceneStartPoint1)); - pe.setStartPoint2(mapFromScene(d->sceneStartPoint2)); - pe.setPoint1(mapFromScene(d->lastPoint1)); - pe.setPoint2(mapFromScene(d->lastPoint2)); - pe.setPointCount(d->touchPoints.count()); - emit pinchStarted(&pe); - if (pe.accepted()) { - d->inPinch = true; - d->stealMouse = true; - QQuickWindow *c = window(); - if (c && c->mouseGrabberItem() != this) - grabMouse(); - setKeepMouseGrab(true); - if (d->pinch && d->pinch->target()) { - d->pinchStartPos = pinch()->target()->position(); - d->pinchStartScale = d->pinch->target()->scale(); - d->pinchStartRotation = d->pinch->target()->rotation(); - d->pinch->setActive(true); + if (qAbs(dist - d->pinchStartDist) >= dragThreshold || + (pinch()->axis() != QQuickPinch::NoDrag && + (qAbs(p1.x()-d->sceneStartPoint1.x()) >= dragThreshold + || qAbs(p1.y()-d->sceneStartPoint1.y()) >= dragThreshold + || qAbs(p2.x()-d->sceneStartPoint2.x()) >= dragThreshold + || qAbs(p2.y()-d->sceneStartPoint2.y()) >= dragThreshold))) { + QQuickPinchEvent pe(d->pinchStartCenter, 1.0, angle, 0.0); + d->pinchStartDist = dist; + pe.setStartCenter(d->pinchStartCenter); + pe.setPreviousCenter(d->pinchStartCenter); + pe.setPreviousAngle(d->pinchLastAngle); + pe.setPreviousScale(d->pinchLastScale); + pe.setStartPoint1(mapFromScene(d->sceneStartPoint1)); + pe.setStartPoint2(mapFromScene(d->sceneStartPoint2)); + pe.setPoint1(mapFromScene(d->lastPoint1)); + pe.setPoint2(mapFromScene(d->lastPoint2)); + pe.setPointCount(d->touchPoints.count()); + emit pinchStarted(&pe); + if (pe.accepted()) { + d->inPinch = true; + d->stealMouse = true; + QQuickWindow *c = window(); + if (c && c->mouseGrabberItem() != this) + grabMouse(); + setKeepMouseGrab(true); + if (d->pinch && d->pinch->target()) { + d->pinchStartPos = pinch()->target()->position(); + d->pinchStartScale = d->pinch->target()->scale(); + d->pinchStartRotation = d->pinch->target()->rotation(); + d->pinch->setActive(true); + } + } else { + d->pinchRejected = true; } - } else { - d->pinchRejected = true; } } } else if (d->pinchStartDist > 0) { |