-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrotate.qml
115 lines (105 loc) · 3.02 KB
/
rotate.qml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
/* This file is part of Checkbox.
Copyright 2014 Canonical Ltd.
Written by:
Daniel Manrique <[email protected]>
Checkbox is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License version 3,
as published by the Free Software Foundation.
Checkbox is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Checkbox. If not, see <http://www.gnu.org/licenses/>.
*/
import QtQuick 2.0
Rectangle{
width: 400
height: 400
focus: true
Keys.onEscapePressed: {console.log("ESC pressed, let's quit"); Qt.quit()}
PinchArea {
property var startpinchangle
property var rotangle
property var currentangle
anchors.fill: parent
onPinchStarted: {
startpinchangle = pinch.angle
rotangle = rotatable.rotation
}
onPinchUpdated: {
if (startpinchangle != null){
currentangle = rotangle - (pinch.angle - startpinchangle)
rotatable.rotation = currentangle
}
if (Math.abs(currentangle) < 1){
rotatable.color = "green"
}
else if(Math.abs(Math.abs(currentangle) - 180) < 1){
rotatable.color = "green"
}
else{
rotatable.color = "blue"
}
}
onPinchFinished:{
console.log("Current angle: " + Math.abs(currentangle))
if (Math.abs(currentangle) < 1 ||
Math.abs(Math.abs(currentangle) - 180) < 1){
console.log("SUCCESS!")
timer.running = false
Qt.quit()
}
}
}
Rectangle{
height: 70
width: 380
x:10
y:10
color: "#aaaaaa"
radius: 10
}
Text {
id: text
width: 360
x:20
y:20
property var timeout: 30
text: "Using two fingers, rotate the blue line so it fits within the red outline. " +
"Press ESC to cancel the test at any time. <b>Test will exit automatically in " +
timeout + " seconds </b>"
wrapMode: Text.Wrap
}
Timer {
id: timer
interval: 1000
running: true
repeat: true
onTriggered: {
text.timeout = text.timeout - 1
if (text.timeout <= 0) {
console.log("LETS EXIT")
running = false
Qt.quit()
}
}
}
Rectangle{
width: 380
height: 30
x: 10
y: 250
border.color: "red"
border.width: 4
}
Rectangle{
id: rotatable
width: 370
height: 20
x: 15
y: 255
color: "blue"
rotation: 45
}
}