QGroundControl
Ground Control Station for MAVLink Drones
Loading...
Searching...
No Matches
APMFlightModeIndicator.qml
Go to the documentation of this file.
1import QtQuick
2import QtQuick.Controls
3import QtQuick.Layouts
4
5import QGroundControl
6import QGroundControl.Controls
7import QGroundControl.FactControls
8
9SettingsGroupLayout {
10 Layout.fillWidth: true
11 heading: qsTr("Return to Launch")
12 visible: activeVehicle.multiRotor
13
14 property var activeVehicle: QGroundControl.multiVehicleManager.activeVehicle
15 property Fact rtlAltFact: controller.getParameterFact(-1, "RTL_ALT_M")
16 // RTL_ALT_M (4.7+) is in meters, RTL_ALT (pre-4.7) is in centimeters
17 property bool _rtlAltIsMeters: controller.parameterExists(-1, "noremap.RTL_ALT_M")
18
19 FactPanelController { id: controller }
20
21 RowLayout {
22 Layout.fillWidth: true
23 spacing: ScreenTools.defaultFontPixelWidth * 2
24
25 QGCLabel {
26 id: label
27 Layout.fillWidth: true
28 text: qsTr("Return At")
29 }
30
31 QGCComboBox {
32 id: returnAtCombo
33 sizeToContents: true
34 model: [ qsTr("Current altitude"), qsTr("Specified altitude") ]
35
36 function setCurrentIndex() {
37 if (rtlAltFact.value === 0) {
38 returnAtCombo.currentIndex = 0
39 } else {
40 returnAtCombo.currentIndex = 1
41 }
42 }
43
44 Component.onCompleted: setCurrentIndex()
45
46 onActivated: (index) => {
47 if (index === 0) {
48 rtlAltFact.rawValue = 0
49 } else {
50 // RTL_ALT_M (4.7+) is in meters, RTL_ALT (pre-4.7) is in centimeters
51 rtlAltFact.rawValue = _rtlAltIsMeters ? 15 : 1500
52 }
53 }
54
55 Connections {
56 target: rtlAltFact
57 onRawValueChanged: returnAtCombo.setCurrentIndex()
58 }
59 }
60
61 FactTextField {
62 fact: rtlAltFact
63 enabled: rtlAltFact.rawValue !== 0
64 }
65 }
66}