QGroundControl
Ground Control Station for MAVLink Drones
Loading...
Searching...
No Matches
BatteryThresholdBar.qml
Go to the documentation of this file.
1import QtQuick
2import QtQuick.Layouts
3
4import QGroundControl
5import QGroundControl.Controls
6
7/// Bar of the emergency, critical and low battery levels, each a fraction of full charge
8ColumnLayout {
9 property real emergency: 0
10 property real critical: 0
11 property real low: 0
12
13 spacing: ScreenTools.defaultFontPixelHeight * 0.25
14
15 QGCPalette {
16 id: barPal
17 }
18
19 Row {
20 Layout.preferredWidth: ScreenTools.defaultFontPixelWidth * 28
21 Layout.preferredHeight: ScreenTools.defaultFontPixelHeight * 0.75
22
23 Repeater {
24 model: [
25 { "from": 0, "to": emergency, "color": barPal.colorRed },
26 { "from": emergency, "to": critical, "color": barPal.colorOrange },
27 { "from": critical, "to": low, "color": barPal.colorYellow },
28 { "from": low, "to": 1, "color": barPal.colorGreen }
29 ]
30
31 Rectangle {
32 width: Math.max(0, (modelData.to - modelData.from)) * parent.width
33 height: parent.height
34 color: modelData.color
35
36 required property var modelData
37 }
38 }
39 }
40
41 QGCLabel {
42 font.pointSize: ScreenTools.smallFontPointSize
43 color: barPal.textSecondary
44 text: qsTr("Emergency %1%, critical %2%, low %3%")
45 .arg(Math.round(emergency * 100))
46 .arg(Math.round(critical * 100))
47 .arg(Math.round(low * 100))
48 }
49}