From 5b31071e56ef6e241e27b66ff91f4e9222f2cddb Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Tue, 9 Dec 2014 10:28:25 +0100 Subject: PinchArea: handle smart zoom gesture MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This is the double-finger double-tap trackpad gesture on OS X. Change-Id: Ie79dc533adf382170867318bc9b61b367f819e9b Reviewed-by: Morten Johan Sørvig --- examples/quick/demos/photosurface/photosurface.qml | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) (limited to 'examples/quick/demos') diff --git a/examples/quick/demos/photosurface/photosurface.qml b/examples/quick/demos/photosurface/photosurface.qml index c7d59ffa9b..fc3b505bcf 100644 --- a/examples/quick/demos/photosurface/photosurface.qml +++ b/examples/quick/demos/photosurface/photosurface.qml @@ -37,7 +37,7 @@ ** $QT_END_LICENSE$ ** ****************************************************************************/ -import QtQuick 2.4 +import QtQuick 2.5 import QtQuick.Dialogs 1.0 import QtQuick.Window 2.1 import Qt.labs.folderlistmodel 1.0 @@ -104,6 +104,25 @@ Window { pinch.maximumScale: 10 pinch.dragAxis: Pinch.XAndYAxis onPinchStarted: setFrameColor(); + property real zRestore: 0 + onSmartZoom: { + if (pinch.scale > 0) { + photoFrame.rotation = 0; + photoFrame.scale = Math.min(root.width, root.height) / Math.max(image.sourceSize.width, image.sourceSize.height) * 0.85 + photoFrame.x = flick.contentX + (flick.width - photoFrame.width) / 2 + photoFrame.y = flick.contentY + (flick.height - photoFrame.height) / 2 + zRestore = photoFrame.z + photoFrame.z = ++root.highestZ; + } else { + photoFrame.rotation = pinch.previousAngle + photoFrame.scale = pinch.previousScale + photoFrame.x = pinch.previousCenter.x - photoFrame.width / 2 + photoFrame.y = pinch.previousCenter.y - photoFrame.height / 2 + photoFrame.z = zRestore + --root.highestZ + } + } + MouseArea { id: dragArea hoverEnabled: true -- cgit v1.2.3