QGroundControl
Ground Control Station for MAVLink Drones
Loading...
Searching...
No Matches
APMFlightModesComponent.qml
Go to the documentation of this file.
1import QtQuick
2import QtQuick.Controls
3import QtQuick.Layouts
4
5import QGroundControl
6import QGroundControl.FactControls
7import QGroundControl.Controls
8
9SetupPage {
10 id: flightModePage
11 pageComponent: flightModePageComponent
12
13 readonly property string _modeChannelParam: controller.modeChannelParam
14 readonly property string _modeParamPrefix: controller.modeParamPrefix
15 readonly property var _pwmStrings: [ "PWM 0 - 1230", "PWM 1231 - 1360", "PWM 1361 - 1490", "PWM 1491 - 1620", "PWM 1621 - 1749", "PWM 1750 +"]
16
17 property real _margins: ScreenTools.defaultFontPixelHeight
18 property real _comboWidth: ScreenTools.defaultFontPixelWidth * 30
19 property Fact _nullFact
20 property bool _fltmodeChExists: controller.parameterExists(-1, _modeChannelParam)
21 property Fact _fltmodeCh: _fltmodeChExists ? controller.getParameterFact(-1, _modeChannelParam) : _nullFact
22 property bool _ch7OptAvailable: controller.parameterExists(-1, "CH7_OPT")
23 property int _rcOptionStart: _ch7OptAvailable ? 7 : 6
24 property int _rcOptionStop: _ch7OptAvailable ? 12 : 16
25 property bool _customSimpleMode: controller.simpleMode === APMFlightModesComponentController.SimpleModeCustom
26
27 QGCPalette { id: qgcPal; colorGroupEnabled: true }
28
29 APMFlightModesComponentController {
30 id: controller
31 }
32
33 Component {
34 id: flightModePageComponent
35
36 Flow {
37 id: flowLayout
38 width: availableWidth
39 spacing: _margins
40
41 QGCGroupBox {
42 title: qsTr("Flight Mode Settings") + (_fltmodeChExists ? "" : qsTr(" (Channel 5)"))
43
44 ColumnLayout {
45 spacing: ScreenTools.defaultFontPixelHeight
46
47 Row {
48 spacing: _margins
49 visible: _fltmodeChExists
50
51 QGCLabel {
52 id: modeChannelLabel
53 anchors.baseline: modeChannelCombo.baseline
54 text: qsTr("Flight mode channel:")
55 }
56
57 QGCComboBox {
58 id: modeChannelCombo
59 sizeToContents: true
60 Layout.maximumWidth: _comboWidth
61 model: [ qsTr("Not assigned"), qsTr("Channel 1"), qsTr("Channel 2"),
62 qsTr("Channel 3"), qsTr("Channel 4"), qsTr("Channel 5"),
63 qsTr("Channel 6"), qsTr("Channel 7"), qsTr("Channel 8") ]
64
65 currentIndex: _fltmodeCh.value
66 onActivated: (index) => { _fltmodeCh.value = index }
67 }
68 }
69
70 GridLayout {
71 rows: _customSimpleMode ? 7 : 6
72 flow: GridLayout.TopToBottom
73
74 QGCLabel { text: ""; visible: _customSimpleMode }
75 Repeater {
76 model: 6
77
78 QGCLabel {
79 text: qsTr("Flight Mode ") + index
80 color: controller.activeFlightMode == index ? "yellow" : qgcPal.text
81
82 property int index: modelData + 1
83 }
84 }
85
86 QGCLabel { text: ""; visible: _customSimpleMode }
87 Repeater {
88 model: 6
89
90 FactComboBox {
91 sizeToContents: true
92 Layout.maximumWidth: _comboWidth
93 fact: controller.getParameterFact(-1, _modeParamPrefix + index)
94 indexModel: false
95
96 property int index: modelData + 1
97 }
98 }
99
100 QGCLabel {
101 text: qsTr("Simple")
102 font.pointSize: ScreenTools.smallFontPointSize
103 visible: _customSimpleMode
104 }
105 Repeater {
106 model: controller.simpleModeEnabled
107 QGCCheckBox {
108 Layout.alignment: Qt.AlignHCenter
109 visible: _customSimpleMode
110 checked: modelData
111 onClicked: controller.setSimpleMode(index, checked)
112 }
113 }
114
115 QGCLabel {
116 text: qsTr("Super-Simple")
117 font.pointSize: ScreenTools.smallFontPointSize
118 visible: _customSimpleMode
119 }
120 Repeater {
121 model: controller.superSimpleModeEnabled
122 QGCCheckBox {
123 Layout.alignment: Qt.AlignHCenter
124 visible: _customSimpleMode
125 checked: modelData
126 onClicked: controller.setSuperSimpleMode(index, checked)
127 }
128 }
129
130 QGCLabel { text: ""; visible: _customSimpleMode }
131 Repeater {
132 model: 6
133
134 QGCLabel { text: _pwmStrings[modelData] }
135 }
136 }
137
138 RowLayout {
139 spacing: _margins
140 visible: controller.simpleModesSupported
141
142 QGCLabel { text: qsTr("Simple Mode") }
143
144 QGCComboBox {
145 model: controller.simpleModeNames
146 currentIndex: controller.simpleMode
147 onActivated: (index) => { controller.simpleMode = index }
148 }
149 }
150 } // ColumnLayout
151 } // QGCGroupBox - Flight Modes
152
153 QGCGroupBox {
154 title: qsTr("Switch Options")
155
156 ColumnLayout {
157 spacing: ScreenTools.defaultFontPixelHeight
158
159 Repeater {
160 model: _rcOptionStop - _rcOptionStart + 1
161
162 Row {
163 spacing: ScreenTools.defaultFontPixelWidth
164
165 property int index: modelData + _rcOptionStart
166 property Fact nullFact: Fact { }
167
168 QGCLabel {
169 anchors.baseline: optCombo.baseline
170 text: qsTr("Channel option %1 :").arg(index)
171 color: controller.channelOptionEnabled[modelData + (_ch7OptAvailable ? 1 : 0)] ? "yellow" : qgcPal.text
172 }
173
174 FactComboBox {
175 id: optCombo
176 sizeToContents: true
177 Layout.maximumWidth: _comboWidth
178 fact: controller.getParameterFact(-1, "RC" + index + "_OPTION")
179 indexModel: false
180 }
181 }
182 } // Repeater -- Channel options
183 } // ColumnLayout
184 } // QGCGroupBox - Channel options
185 } // Flow
186 } // Component - flightModePageComponent
187} // SetupPage