summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorLorn Potter <lorn.potter@nokia.com>2012-04-27 12:46:21 +1000
committerQt by Nokia <qt-info@nokia.com>2012-04-27 07:55:44 +0200
commit6bfec6216ae86ac76f5a3577043311bfe89f77b4 (patch)
treeb4577f784e27a43fd2600f03a0e413dc7c744c5a /examples
parentade764287a46cc8c0012afb8f5774c6fcdfc8448 (diff)
downloadqtsensors-6bfec6216ae86ac76f5a3577043311bfe89f77b4.tar.gz
add doubletap gesture to shakeit.
Change-Id: Ic30ec2d896b6db83e3420d38a70644ab34b5bdc9 Reviewed-by: Lincoln Ramsay <lincoln.ramsay@nokia.com>
Diffstat (limited to 'examples')
-rw-r--r--examples/sensors/shakeit/shakeit.qml36
1 files changed, 34 insertions, 2 deletions
diff --git a/examples/sensors/shakeit/shakeit.qml b/examples/sensors/shakeit/shakeit.qml
index f553b93..c39d793 100644
--- a/examples/sensors/shakeit/shakeit.qml
+++ b/examples/sensors/shakeit/shakeit.qml
@@ -76,6 +76,9 @@ Rectangle {
y: parent.height / 2 - (triangle1.height);
Behavior on x { SmoothedAnimation { velocity: 200 } }
Behavior on y { SmoothedAnimation { velocity: 200 } }
+ transform: Rotation {
+ id: myRot
+ }
}
Image {
id: triangle2
@@ -109,6 +112,7 @@ Rectangle {
PropertyChanges { target: triangle1; rotation: 0;
x: parent.width / 2 - (triangle1.width / 2)
y: parent.height / 2 - (triangle1.height);
+ transformOrigin: triangle1.Center
}
PropertyChanges { target: triangle2; rotation: 0;
x: parent.width / 2 - (triangle1.width + triangle2.width / 2)
@@ -177,7 +181,7 @@ Rectangle {
x: window.width / 2 - triangle2.width / 2; // middle
y: triangle2.height;
}
- PropertyChanges { target: triangle3; rotation: 180;
+ PropertyChanges { target: triangle3; rotation: 195;
x: (window.width / 3 + window.width / 3) - triangle3.width / 2;
y: triangle3.height
}
@@ -196,6 +200,15 @@ Rectangle {
x: window.width / 2 - triangle3.width / 2;
y:window.height - triangle3.height;
}
+ },
+ State {
+ name: "doubletapped"
+ PropertyChanges { target: triangle1; rotation: 114;
+ transformOrigin: Item.BottomLeft
+ }
+ PropertyChanges { target: triangle2; rotation: 120;
+ transformOrigin: Item.BottomLeft
+ }
}
]
@@ -220,6 +233,21 @@ Rectangle {
NumberAnimation { properties: "x"; easing.type: Easing.OutBounce;duration: 500; }
}
+ }, Transition {
+ to: "doubletapped"
+ SequentialAnimation {
+ PropertyAction { target: triangle1; property: "transformOrigin" }
+ PropertyAction { target: triangle2; property: "transformOrigin" }
+ NumberAnimation { target: triangle1; properties: "rotation"; easing.type: Easing.OutBounce;duration: 500; }
+ NumberAnimation { target: triangle2; properties: "rotation"; easing.type: Easing.OutBounce;duration: 1500; }
+ }
+ }, Transition {
+ from: "doubletapped"
+ SequentialAnimation {
+ NumberAnimation { properties: "rotation"; easing.type: Easing.OutBounce;duration: 1500; }
+ PropertyAction { target: triangle1; property: "transformOrigin" }
+ PropertyAction { target: triangle2; property: "transformOrigin" }
+ }
}
]
@@ -232,7 +260,7 @@ Rectangle {
//! [3]
//! [2]
gestures : ["QtSensors.shake", "QtSensors.whip", "QtSensors.twist", "QtSensors.cover",
- "QtSensors.hover", "QtSensors.turnover", "QtSensors.pickup", "QtSensors.slam" ]
+ "QtSensors.hover", "QtSensors.turnover", "QtSensors.pickup", "QtSensors.slam" , "QtSensors.doubletap"]
//! [2]
//! [4]
onDetected:{
@@ -277,6 +305,10 @@ Rectangle {
window.state == "slammed" ? window.state = "default" : window.state = "slammed"
timer.start()
}
+ if (gesture == "doubletap") {
+ window.state == "doubletapped" ? window.state = "default" : window.state = "doubletapped"
+ timer.start()
+ }
}
//! [4]
}