-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathLinearGauge.qml
More file actions
84 lines (75 loc) · 2.49 KB
/
Copy pathLinearGauge.qml
File metadata and controls
84 lines (75 loc) · 2.49 KB
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
import QtQuick
// Reusable horizontal bar gauge — works for fuel, temp, battery, oil pressure, etc.
// Public API:
// label: text on the left (e.g. "FUEL")
// value: current reading
// maxValue: full-scale reading
// units: text after the value (e.g. "%", "°C")
// warningLow: value below which bar turns red (set -1 to disable)
// warningHigh: value above which bar turns red (set -1 to disable)
// accentColor: normal bar color
Item {
id: root
// ── Public API ──
property string label: ""
property real value: 0
property real maxValue: 100
property string units: "%"
property real warningLow: -1
property real warningHigh: -1
property color accentColor: "#00c896"
// ── Geometry ──
implicitWidth: 240
implicitHeight: 30
// Is the value in a warning state?
readonly property bool inWarning:
(warningLow >= 0 && value <= warningLow) ||
(warningHigh >= 0 && value >= warningHigh)
// ── Header row: label + numeric value ──
Text {
id: labelText
anchors.left: parent.left
anchors.top: parent.top
text: root.label
color: "#8a92a8"
font.family: "Bahnschrift"
font.pixelSize: 11
font.letterSpacing: 1.2
font.weight: Font.Medium
}
Text {
id: valueText
anchors.right: parent.right
anchors.top: parent.top
text: Math.round(root.value) + " " + root.units
color: root.inWarning ? "#ff5252" : "#ffffff"
font.family: "Bahnschrift"
font.pixelSize: 12
font.weight: Font.Medium
}
// ── Bar track ──
Rectangle {
id: track
anchors.left: parent.left
anchors.right: parent.right
anchors.bottom: parent.bottom
height: 6
radius: 2
color: "#1a1f2e"
// Filled portion
Rectangle {
anchors.left: parent.left
anchors.top: parent.top
anchors.bottom: parent.bottom
width: parent.width * Math.min(root.value / root.maxValue, 1)
radius: 2
color: root.inWarning ? "#ff5252" : root.accentColor
Behavior on width {
NumberAnimation { duration: 200; easing.type: Easing.OutCubic }
}
Behavior on color {
ColorAnimation { duration: 300 }
}
}
}
}