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 Fact _nullFact
19 property bool _fltmodeChExists: controller.parameterExists(-1, _modeChannelParam)
20 property Fact _fltmodeCh: _fltmodeChExists ? controller.getParameterFact(-1, _modeChannelParam) : _nullFact
21 property bool _ch7OptAvailable: controller.parameterExists(-1, "CH7_OPT")
22 property int _rcOptionStart: _ch7OptAvailable ? 7 : 6
23 property int _rcOptionStop: _ch7OptAvailable ? 12 : 16
24 property bool _customSimpleMode: controller.simpleMode === APMFlightModesComponentController.SimpleModeCustom
25
26 QGCPalette { id: qgcPal; colorGroupEnabled: true }
27
28 APMFlightModesComponentController {
29 id: controller
30 }
31
32 Component {
33 id: flightModePageComponent
34
35 Flow {
36 id: flowLayout
37 width: availableWidth
38 spacing: _margins
39
40 Column {
41 spacing: _margins
42
43 QGCLabel {
44 id: flightModeLabel
45 text: qsTr("Flight Mode Settings") + (_fltmodeChExists ? "" : qsTr(" (Channel 5)"))
46 font.bold: true
47 }
48
49 Rectangle {
50 id: flightModeSettings
51 width: flightModeColumn.width + (_margins * 2)
52 height: flightModeColumn.height + ScreenTools.defaultFontPixelHeight
53 color: qgcPal.windowShade
54
55 Column {
56 id: flightModeColumn
57 anchors.margins: ScreenTools.defaultFontPixelWidth
58 anchors.left: parent.left
59 anchors.top: parent.top
60 spacing: ScreenTools.defaultFontPixelHeight
61
62 Row {
63 spacing: _margins
64 visible: _fltmodeChExists
65
66 QGCLabel {
67 id: modeChannelLabel
68 anchors.baseline: modeChannelCombo.baseline
69 text: qsTr("Flight mode channel:")
70 }
71
72 QGCComboBox {
73 id: modeChannelCombo
74 width: ScreenTools.defaultFontPixelWidth * 15
75 model: [ qsTr("Not assigned"), qsTr("Channel 1"), qsTr("Channel 2"),
76 qsTr("Channel 3"), qsTr("Channel 4"), qsTr("Channel 5"),
77 qsTr("Channel 6"), qsTr("Channel 7"), qsTr("Channel 8") ]
78
79 currentIndex: _fltmodeCh.value
80 onActivated: (index) => { _fltmodeCh.value = index }
81 }
82 }
83
84 GridLayout {
85 rows: _customSimpleMode ? 7 : 6
86 flow: GridLayout.TopToBottom
87
88 QGCLabel { text: ""; visible: _customSimpleMode }
89 Repeater {
90 model: 6
91
92 QGCLabel {
93 text: qsTr("Flight Mode ") + index
94 color: controller.activeFlightMode == index ? "yellow" : qgcPal.text
95
96 property int index: modelData + 1
97 }
98 }
99
100 QGCLabel { text: ""; visible: _customSimpleMode }
101 Repeater {
102 model: 6
103
104 FactComboBox {
105 Layout.preferredWidth: ScreenTools.defaultFontPixelWidth * 15
106 fact: controller.getParameterFact(-1, _modeParamPrefix + index)
107 indexModel: false
108
109 property int index: modelData + 1
110 }
111 }
112
113 QGCLabel {
114 text: qsTr("Simple")
115 font.pointSize: ScreenTools.smallFontPointSize
116 visible: _customSimpleMode
117 }
118 Repeater {
119 model: controller.simpleModeEnabled
120 QGCCheckBox {
121 Layout.alignment: Qt.AlignHCenter
122 visible: _customSimpleMode
123 checked: modelData
124 onClicked: controller.setSimpleMode(index, checked)
125 }
126 }
127
128 QGCLabel {
129 text: qsTr("Super-Simple")
130 font.pointSize: ScreenTools.smallFontPointSize
131 visible: _customSimpleMode
132 }
133 Repeater {
134 model: controller.superSimpleModeEnabled
135 QGCCheckBox {
136 Layout.alignment: Qt.AlignHCenter
137 visible: _customSimpleMode
138 checked: modelData
139 onClicked: controller.setSuperSimpleMode(index, checked)
140 }
141 }
142
143 QGCLabel { text: ""; visible: _customSimpleMode }
144 Repeater {
145 model: 6
146
147 QGCLabel { text: _pwmStrings[modelData] }
148 }
149 }
150
151 RowLayout {
152 spacing: _margins
153 visible: controller.simpleModesSupported
154
155 QGCLabel { text: qsTr("Simple Mode") }
156
157 QGCComboBox {
158 model: controller.simpleModeNames
159 currentIndex: controller.simpleMode
160 onActivated: (index) => { controller.simpleMode = index }
161 }
162 }
163 } // Column - Flight Modes
164 } // Rectangle - Flight Modes
165 } // Column - Flight Modes
166
167 Column {
168 spacing: _margins
169
170 QGCLabel {
171 id: channelOptionsLabel
172 text: qsTr("Switch Options")
173 font.bold: true
174 }
175
176 Rectangle {
177 id: channelOptionsSettings
178 width: channelOptColumn.width + (_margins * 2)
179 height: channelOptColumn.height + ScreenTools.defaultFontPixelHeight
180 color: qgcPal.windowShade
181
182 Column {
183 id: channelOptColumn
184 anchors.margins: ScreenTools.defaultFontPixelWidth
185 anchors.left: parent.left
186 anchors.top: parent.top
187 spacing: ScreenTools.defaultFontPixelHeight
188
189 Repeater {
190 model: _rcOptionStop - _rcOptionStart + 1
191
192 Row {
193 spacing: ScreenTools.defaultFontPixelWidth
194
195 property int index: modelData + _rcOptionStart
196 property Fact nullFact: Fact { }
197
198 QGCLabel {
199 anchors.baseline: optCombo.baseline
200 text: qsTr("Channel option %1 :").arg(index)
201 color: controller.channelOptionEnabled[modelData + (_ch7OptAvailable ? 1 : 0)] ? "yellow" : qgcPal.text
202 }
203
204 FactComboBox {
205 id: optCombo
206 width: ScreenTools.defaultFontPixelWidth * 15
207 fact: controller.getParameterFact(-1, "r.RC" + index + "_OPTION")
208 indexModel: false
209 }
210 }
211 } // Repeater -- Channel options
212 } // Column - Channel options
213 } // Rectangle - Channel options
214 } // Column - Channel options
215 } // Flow
216 } // Component - flightModePageComponent
217} // SetupPage