QGroundControl
Ground Control Station for MAVLink Drones
Loading...
Searching...
No Matches
LabelledFactIncrementer.qml
Go to the documentation of this file.
1import QtQuick
2import QtQuick.Layouts
3
4import QGroundControl
5import QGroundControl.Controls
6
7/// Generic increment/decrement control for a numeric Fact.
8/// Shows a label, a "-" button, the current value with its units,
9/// and a "+" button. Clamped to fact.min / fact.max.
10///
11/// Properties:
12/// fact - The Fact to control (required).
13/// label - Display label (defaults to fact.label).
14/// step - Amount added/subtracted per click (default 5).
15RowLayout {
16 id: root
17
18 property string label: fact.label
19 property Fact fact
20 property real step: 5
21
22 spacing: ScreenTools.defaultFontPixelWidth * 2
23
24 QGCLabel {
25 Layout.fillWidth: true
26 Layout.minimumWidth: implicitWidth
27 text: root.label
28 }
29
30 RowLayout {
31 spacing: ScreenTools.defaultFontPixelWidth * 2
32
33 QGCButton {
34 Layout.preferredWidth: height
35 height: valueLabel.height * 1.5
36 leftPadding: 0
37 rightPadding: 0
38 text: "-"
39 onClicked: {
40 if (root.fact.value > root.fact.min) {
41 root.fact.value = root.fact.value - root.step
42 }
43 }
44 }
45
46 QGCLabel {
47 id: valueLabel
48 width: ScreenTools.defaultFontPixelWidth * 6
49 text: root.fact.valueString
50 }
51
52 QGCButton {
53 Layout.preferredWidth: height
54 height: valueLabel.height * 1.5
55 leftPadding: 0
56 rightPadding: 0
57 text: "+"
58 onClicked: {
59 if (root.fact.value < root.fact.max) {
60 root.fact.value = root.fact.value + root.step
61 }
62 }
63 }
64 }
65}