diff options
Diffstat (limited to 'multilayer-dashboard/RotatableImage.qml')
| -rw-r--r-- | multilayer-dashboard/RotatableImage.qml | 38 |
1 files changed, 27 insertions, 11 deletions
diff --git a/multilayer-dashboard/RotatableImage.qml b/multilayer-dashboard/RotatableImage.qml index 5938252..59df4e2 100644 --- a/multilayer-dashboard/RotatableImage.qml +++ b/multilayer-dashboard/RotatableImage.qml @@ -42,6 +42,8 @@ import Qt 4.7 import Qt.labs.gestures 1.0 Rectangle { + id: me + property string source : "images/qt-logo.png" width: 160 @@ -58,15 +60,13 @@ Rectangle { } function pinch(gesture) { - if (parent.fullScreen) { - if (gesture.changeFlags & PinchGesture.RotationAngleChanged) - img.rotation += gesture.rotationAngle - gesture.lastRotationAngle - if (gesture.changeFlags & PinchGesture.ScaleFactorChanged) - img.scale *= gesture.scaleFactor - if (gesture.changeFlags & PinchGesture.CenterPointChanged) { - img.x += gesture.centerPoint.x - gesture.lastCenterPoint.x - img.y += gesture.centerPoint.y - gesture.lastCenterPoint.y - } + if (gesture.changeFlags & PinchGesture.RotationAngleChanged) + img.rotation += gesture.rotationAngle - gesture.lastRotationAngle + if (gesture.changeFlags & PinchGesture.ScaleFactorChanged) + img.scale *= gesture.scaleFactor + if (gesture.changeFlags & PinchGesture.CenterPointChanged) { + img.x += gesture.centerPoint.x - gesture.lastCenterPoint.x + img.y += gesture.centerPoint.y - gesture.lastCenterPoint.y } } @@ -74,8 +74,24 @@ Rectangle { anchors.fill: parent Pinch { - onStarted: pinch(gesture) - onUpdated: pinch(gesture) + when: me.parent.fullScreen + onUpdated: { + if (gesture.changeFlags & PinchGesture.RotationAngleChanged) + img.rotation += gesture.rotationAngle - gesture.lastRotationAngle + if (gesture.changeFlags & PinchGesture.ScaleFactorChanged) + img.scale *= gesture.scaleFactor + if (gesture.changeFlags & PinchGesture.CenterPointChanged) { + img.x += gesture.centerPoint.x - gesture.lastCenterPoint.x + img.y += gesture.centerPoint.y - gesture.lastCenterPoint.y + } + } + } + Pan { + when: me.parent.fullScreen + onUpdated: { + img.x += gesture.delta.x + img.y += gesture.delta.y + } } } } |
