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 text: "-"
37 onClicked: {
38 if (root.fact.value > root.fact.min) {
39 root.fact.value = root.fact.value - root.step
40 }
41 }
42 }
43
44 QGCLabel {
45 id: valueLabel
46 width: ScreenTools.defaultFontPixelWidth * 6
47 text: root.fact.valueString
48 }
49
50 QGCButton {
51 Layout.preferredWidth: height
52 height: valueLabel.height * 1.5
53 text: "+"
54 onClicked: {
55 if (root.fact.value < root.fact.max) {
56 root.fact.value = root.fact.value + root.step
57 }
58 }
59 }
60 }
61}