forked from alex-adam/Tesla
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Speedometer.qml
90 lines (76 loc) · 3.16 KB
/
Speedometer.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
import QtQuick 2.4
import QtGraphicalEffects 1.0
Rectangle {
color: "transparent"
SpeedNeedle {
id: speedoNeedle
anchors.verticalCenterOffset: 0
anchors.centerIn: parent
focus: true
Keys.onPressed: {
if (event.key == Qt.Key_Space && !event.isAutoRepeat) {
speedoNeedle.value = 100
kWNeedle.value = 0
drive()
}
}
Keys.onReleased: {
if (event.key == Qt.Key_Space && !event.isAutoRepeat) {
speedoNeedle.value = 0
kWNeedle.value = 100
}}}
KWNeedle {
id: kWNeedle
anchors.verticalCenterOffset: 0
anchors.centerIn: parent
value: 100
}
InnerRing {
id: innerring
speed: (Math.round(speedoNeedle.currentValue, 0) + 360) * 0.68
}
//Letter: P R N D
Grid {
anchors.horizontalCenter: parent.horizontalCenter
y: parent.height - 65
columns: 4
Rectangle { color: "transparent"; width: 25; height: 25
Text {
id: letterP
text: " P "
font.family: "Eurostile"; font.pixelSize: 36
color: "white"
anchors.centerIn: parent
} }
Rectangle { color: "transparent"; width: 25; height: 25
Text {
text: " R "
font.family: "Eurostile"; font.pixelSize: 18
color: "darkgray"
anchors.centerIn: parent
}}
Rectangle { color: "transparent"; width: 25; height: 25
Text {
text: " N "
font.family: "Eurostile"; font.pixelSize: 18
color: "darkgray"
anchors.centerIn: parent
}}
Rectangle { color: "transparent"; width: 25; height: 25
Text {
id: letterD
text: " D "
font.family: "Eurostile"; font.pixelSize: 18
color: "darkgray"
anchors.centerIn: parent
}}
}
function drive() {
letterD.font.bold = true
letterD.color = "white"
letterD.font.pixelSize = 36
letterP.font.bold = false
letterP.color = "darkgray"
letterP.font.pixelSize = 18
}
}