diff options
author | Lorn Potter <lorn.potter@nokia.com> | 2012-02-01 10:22:00 +1000 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-02-01 06:24:57 +0100 |
commit | bda393ce3853c1507b0870815e57cb136c7d7ac5 (patch) | |
tree | d7e167dd9af43223fca7d38914e656136387cbfe /examples/sensors | |
parent | 89fbd66b01bab3eca2ed9591f158f28d6e43e9e2 (diff) | |
download | qtsensors-bda393ce3853c1507b0870815e57cb136c7d7ac5.tar.gz |
add more sensor gestures to shakeit
Change-Id: I83ddbc84ce90c2e89f7a950f061065f0b0ce38f3
Sanity-Review: Lorn Potter <lorn.potter@nokia.com>
Reviewed-by: Lincoln Ramsay <lincoln.ramsay@nokia.com>
Diffstat (limited to 'examples/sensors')
-rwxr-xr-x | examples/sensors/shakeit/audio/loopy2a_mono.wav | bin | 0 -> 67772 bytes | |||
-rw-r--r-- | examples/sensors/shakeit/audio/phone.wav | bin | 0 -> 22094 bytes | |||
-rw-r--r-- | examples/sensors/shakeit/qml.pro | 6 | ||||
-rw-r--r-- | examples/sensors/shakeit/shakeit.pro | 3 | ||||
-rw-r--r-- | examples/sensors/shakeit/shakeit.qml | 149 |
5 files changed, 145 insertions, 13 deletions
diff --git a/examples/sensors/shakeit/audio/loopy2a_mono.wav b/examples/sensors/shakeit/audio/loopy2a_mono.wav Binary files differnew file mode 100755 index 0000000..7d76cb6 --- /dev/null +++ b/examples/sensors/shakeit/audio/loopy2a_mono.wav diff --git a/examples/sensors/shakeit/audio/phone.wav b/examples/sensors/shakeit/audio/phone.wav Binary files differnew file mode 100644 index 0000000..884e9ac --- /dev/null +++ b/examples/sensors/shakeit/audio/phone.wav diff --git a/examples/sensors/shakeit/qml.pro b/examples/sensors/shakeit/qml.pro new file mode 100644 index 0000000..440ca68 --- /dev/null +++ b/examples/sensors/shakeit/qml.pro @@ -0,0 +1,6 @@ +TEMPLATE = aux + +files.files = info.json icon.png images audio shakeit.qml + +files.path = /opt/mt/applications/com.nokia.mt.shakeit +INSTALLS = files diff --git a/examples/sensors/shakeit/shakeit.pro b/examples/sensors/shakeit/shakeit.pro new file mode 100644 index 0000000..6dc685b --- /dev/null +++ b/examples/sensors/shakeit/shakeit.pro @@ -0,0 +1,3 @@ +TEMPLATE = subdirs + +SUBDIRS = qml.pro diff --git a/examples/sensors/shakeit/shakeit.qml b/examples/sensors/shakeit/shakeit.qml index 0ffcaf0..fe0a8e1 100644 --- a/examples/sensors/shakeit/shakeit.qml +++ b/examples/sensors/shakeit/shakeit.qml @@ -43,11 +43,27 @@ import QtQuick 2.0 //! [0] import QtSensors 5.0 //! [0] +//import QtMultimedia 4.0 +import Qt.multimediakit 4.0 + + Rectangle { id: window + state: "default" + + Audio { + id :phone + source: "audio/phone.wav" //mono + } + Audio { + id :loopy2a_mono + source: "audio/loopy2a_mono.wav" //mono + } + Text { + id: label text: qsTr("Shake to rotate triangles") y: parent.height / 4 anchors.horizontalCenter: parent.horizontalCenter @@ -56,20 +72,29 @@ Rectangle { id: triangle1 smooth: true source: "images/triangle.png" - y: parent.height / 2 - (triangle1.height); x: parent.width / 2 - (triangle1.width / 2) + y: parent.height / 2 - (triangle1.height); + Behavior on x { SmoothedAnimation { velocity: 200 } } + Behavior on y { SmoothedAnimation { velocity: 200 } } } Image { id: triangle2 smooth: true source: "images/triangle2.png" - anchors.right: triangle1.left; anchors.top: triangle1.bottom + x: parent.width / 2 - (triangle1.width + triangle2.width / 2) + y: parent.height / 2 + (triangle2.height / 2); + Behavior on x { SmoothedAnimation { velocity: 200 } } + Behavior on y { SmoothedAnimation { velocity: 200 } } } Image { id: triangle3 smooth: true source: "images/triangle3.png" - anchors.left: triangle1.right; anchors.top: triangle1.bottom + x: parent.width / 2 + (triangle1.width / 2) + y: parent.height / 2 + (triangle3.height / 2); + + Behavior on x { SmoothedAnimation { velocity: 200 } } + Behavior on y { SmoothedAnimation { velocity: 200 } } } states: [ @@ -80,16 +105,90 @@ Rectangle { PropertyChanges { target: triangle3; rotation: 270 } }, State { - name: "unrotated" - PropertyChanges { target: triangle1; rotation: 0 } - PropertyChanges { target: triangle2; rotation: 0 } - PropertyChanges { target: triangle3; rotation: 0 } - } + name: "default" + PropertyChanges { target: triangle1; rotation: 0; + x: parent.width / 2 - (triangle1.width / 2) + y: parent.height / 2 - (triangle1.height); + } + PropertyChanges { target: triangle2; rotation: 0; + x: parent.width / 2 - (triangle1.width + triangle2.width / 2) + y: parent.height / 2 + (triangle2.height / 2); + } + PropertyChanges { target: triangle3; rotation: 0; + x: parent.width / 2 + (triangle1.width / 2) + y: parent.height / 2 + (triangle3.height / 2); + } + }, + State { + name: "whipped" + PropertyChanges { target: triangle1; rotation: 0; x:0; + } + PropertyChanges { target: triangle2; rotation: 0; x:0; + } + PropertyChanges { target: triangle3; rotation: 0; x:0; + y: triangle2.y + triangle2.height; + } + }, + State { + name: "twisted" + PropertyChanges { target: triangle1; rotation: 270; + x:window.width - triangle1.width; + } + PropertyChanges { target: triangle2; rotation: 180; + x:window.width - triangle2.width; + } + PropertyChanges { target: triangle3; rotation: 90; + x:window.width - triangle3.width; + y:triangle2.y + triangle2.height; + } + }, + State { + name: "covered" + PropertyChanges { target: triangle1; rotation: 0; + x: window.width / 3 - triangle1.width / 2; + y: window.height - triangle1.height; + } + PropertyChanges { target: triangle2; rotation: 0; + x: window.width / 2 - triangle2.width / 2; // middle + y: window.height - triangle2.height; + } + PropertyChanges { target: triangle3; rotation: 0; + x: (window.width / 3 + window.width / 3) - triangle3.width / 2; + y: window.height - triangle3.height; + } + }, + State { + name: "hovered" + PropertyChanges { target: triangle1; rotation: 90; + x: window.width / 3 - triangle1.width / 2; + y: triangle1.height; + } + PropertyChanges { target: triangle2; rotation: 270; + x: window.width / 2 - triangle2.width / 2; // middle + y: triangle2.height; + } + PropertyChanges { target: triangle3; rotation: 180; + x: (window.width / 3 + window.width / 3) - triangle3.width / 2; + y: triangle3.height + } + }/*, + State { + name :"turnedover" + }*/ ] + + transitions: Transition { - RotationAnimation { id: t1Rotation; target: triangle1; duration: 1000; direction: RotationAnimation.Clockwise } - RotationAnimation { id: t2Rotation; target: triangle2; duration: 3000; direction: RotationAnimation.Counterclockwise } - RotationAnimation { id: t3Rotation; target: triangle3; duration: 3000; direction: RotationAnimation.Clockwise } + ParallelAnimation { + running: true + NumberAnimation { properties: "x,y"; easing.type: Easing.OutBounce;duration: 3000; } + RotationAnimation { id: t1Rotation; target: triangle1; duration: 1000; + direction: RotationAnimation.Clockwise } + RotationAnimation { id: t2Rotation; target: triangle2; duration: 3000; + direction: RotationAnimation.Counterclockwise } + RotationAnimation { id: t3Rotation; target: triangle3; duration: 3000; + direction: RotationAnimation.Clockwise } + } } //! [1] @@ -100,12 +199,36 @@ Rectangle { enabled: true //! [3] //! [2] - gestures : ["QtSensors.shake"] + gestures : ["QtSensors.shake", "QtSensors.whip", "QtSensors.twist", "QtSensors.cover", + "QtSensors.hover", "QtSensors.turnover", "QtSensors.pickup"] //! [2] //! [4] onDetected:{ + console.debug(gesture) + label.text = gesture + if (gesture == "shake") { - window.state == "rotated" ? window.state = "unrotated" : window.state = "rotated" + window.state == "rotated" ? window.state = "default" : window.state = "rotated" + } + if (gesture == "whip") { + window.state == "whipped" ? window.state = "default" : window.state = "whipped" + } + if (gesture == "twistRight") { + window.state == "twisted" ? window.state = "default" : window.state = "twisted" + } + if (gesture == "cover") { + window.state == "covered" ? window.state = "default" : window.state = "covered" + } + if (gesture == "hover") { + window.state == "hovered" ? window.state = "default" : window.state = "hovered" + } + if (gesture == "turnover") { + window.state = "default" + loopy2a_mono.play(); + } + if (gesture == "pickup") { + window.state = "default" + phone.play() } } //! [4] |