aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick/items/qquickpincharea.cpp
diff options
context:
space:
mode:
authorShawn Rutledge <shawn.rutledge@digia.com>2014-12-09 10:28:25 +0100
committerShawn Rutledge <shawn.rutledge@digia.com>2015-02-13 14:03:47 +0000
commit5b31071e56ef6e241e27b66ff91f4e9222f2cddb (patch)
tree6f87fffdc4225cff1ac97f87ef3ab045c4c1e2e1 /src/quick/items/qquickpincharea.cpp
parent3f3be0fa64f8745b05a417d3e9c8c20da74d5fa9 (diff)
PinchArea: handle smart zoom gesture
This is the double-finger double-tap trackpad gesture on OS X. Change-Id: Ie79dc533adf382170867318bc9b61b367f819e9b Reviewed-by: Morten Johan Sørvig <morten.sorvig@theqtcompany.com>
Diffstat (limited to 'src/quick/items/qquickpincharea.cpp')
-rw-r--r--src/quick/items/qquickpincharea.cpp37
1 files changed, 37 insertions, 0 deletions
diff --git a/src/quick/items/qquickpincharea.cpp b/src/quick/items/qquickpincharea.cpp
index 667a988cba..5c3916cfc4 100644
--- a/src/quick/items/qquickpincharea.cpp
+++ b/src/quick/items/qquickpincharea.cpp
@@ -234,6 +234,22 @@ QQuickPinchAreaPrivate::~QQuickPinchAreaPrivate()
The corresponding handler is \c onPinchFinished.
*/
+/*!
+ \qmlsignal QtQuick::PinchArea::smartZoom()
+ \since 5.5
+
+ This signal is emitted when the pinch area detects the smart zoom gesture.
+ This gesture occurs only on certain operating systems such as OS X.
+
+ The \l {PinchEvent}{pinch} parameter provides information about the pinch
+ gesture, including the location where the gesture occurred. \c pinch.scale
+ will be greater than zero when the gesture indicates that the user wishes to
+ enter smart zoom, and zero when exiting (even though typically the same gesture
+ is used to toggle between the two states).
+
+ The corresponding handler is \c onSmartZoom.
+*/
+
/*!
\qmlpropertygroup QtQuick::PinchArea::pinch
@@ -663,6 +679,27 @@ bool QQuickPinchArea::event(QEvent *event)
d->inPinch = true;
updatePinchTarget();
} break;
+ case Qt::SmartZoomNativeGesture: {
+ if (gesture->value() > 0.0 && d->pinch && d->pinch->target()) {
+ d->pinchStartPos = pinch()->target()->position();
+ d->pinchStartCenter = mapToItem(pinch()->target()->parentItem(), pinch()->target()->boundingRect().center());
+ d->pinchStartScale = d->pinch->target()->scale();
+ d->pinchStartRotation = d->pinch->target()->rotation();
+ d->pinchLastScale = d->pinchStartScale = d->pinch->target()->scale();
+ d->pinchLastAngle = d->pinchStartRotation = d->pinch->target()->rotation();
+ }
+ QQuickPinchEvent pe(gesture->localPos(), gesture->value(), d->pinchLastAngle, 0.0);
+ pe.setStartCenter(gesture->localPos());
+ pe.setPreviousCenter(d->pinchStartCenter);
+ pe.setPreviousAngle(d->pinchLastAngle);
+ pe.setPreviousScale(d->pinchLastScale);
+ pe.setStartPoint1(gesture->localPos());
+ pe.setStartPoint2(gesture->localPos());
+ pe.setPoint1(mapFromScene(gesture->windowPos()));
+ pe.setPoint2(mapFromScene(gesture->windowPos()));
+ pe.setPointCount(2);
+ emit smartZoom(&pe);
+ } break;
case Qt::RotateNativeGesture: {
qreal angle = d->pinchLastAngle + gesture->value();
QQuickPinchEvent pe(d->pinchStartCenter, d->pinchLastScale, angle, 0.0);