-
Notifications
You must be signed in to change notification settings - Fork 4
/
main.qml
85 lines (76 loc) · 2.64 KB
/
main.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
import QtQuick 2.7
import QtQuick.Controls 2.0
import QtQuick.Layouts 1.3
ApplicationWindow {
id: window
width: 1060
height: 635
visible: true
color: "#000000"
title: "Car Speed Guage"
RowLayout{
anchors.centerIn:parent
spacing: 100
Gauge2 {
id:leftGuage
property bool accelerating
width: 400
height: 400
value: accelerating ? maximumValue : 0
maximumValue: 250
Component.onCompleted: forceActiveFocus()
Behavior on value { NumberAnimation { duration: 1000 }}
Keys.onSpacePressed: leftGuage.accelerating = true
Keys.onEnterPressed: rightGuage.accelerating = true
Keys.onReturnPressed: rightGuage.accelerating = true
Keys.onReleased: {
if (event.key === Qt.Key_Return || event.key === Qt.Key_Enter) {
rightGuage.accelerating = false;
event.accepted = true;
}else if (event.key === Qt.Key_Space) {
leftGuage.accelerating = false;
event.accepted = true;
}
}
}
Gauge2 {
id:rightGuage
property bool accelerating
width: 400
height: 400
value: accelerating ? maximumValue : 0
maximumValue: 100
Component.onCompleted: forceActiveFocus()
Behavior on value { NumberAnimation { duration: 1000 }}
Keys.onSpacePressed: leftGuage.accelerating = true
Keys.onEnterPressed: rightGuage.accelerating = true
Keys.onReturnPressed: rightGuage.accelerating = true
Keys.onReleased: {
if (event.key === Qt.Key_Return || event.key === Qt.Key_Enter) {
rightGuage.accelerating = false;
event.accepted = true;
}else if (event.key === Qt.Key_Space) {
leftGuage.accelerating = false;
event.accepted = true;
}
}
}
}
// Gauge2 {
// visible: false
// property bool accelerating
// width: 400
// height: 400
// value: accelerating ? maximumValue : 0
// maximumValue: 250
// Component.onCompleted: forceActiveFocus()
// Behavior on value { NumberAnimation { duration: 1000 }}
// Keys.onSpacePressed: accelerating = true
// Keys.onReleased: {
// if (event.key === Qt.Key_Space) {
// accelerating = false;
// event.accepted = true;
// }
// }
// }
}