6import QGroundControl.Controls
7import QGroundControl.FactControls
11 Layout.preferredWidth: mainLayout.width
13 property bool showIndicator: true
14 property bool waitForParameters: false
16 property real fontPointSize: ScreenTools.largeFontPointSize
17 property var activeVehicle: QGroundControl.multiVehicleManager.activeVehicle
18 property bool allowEditMode: true
19 property bool editMode: false
21 property bool _isVTOL: activeVehicle ? activeVehicle.vtol : false
22 property bool _vtolInFWDFlight: activeVehicle ? activeVehicle.vtolInFwdFlight : false
23 property var _vehicleInAir: activeVehicle ? activeVehicle.flying || activeVehicle.landing : false
25 QGCPalette { id: qgcPal }
29 anchors.verticalCenter: parent.verticalCenter
30 spacing: ScreenTools.defaultFontPixelWidth / 2
34 Layout.preferredWidth: ScreenTools.defaultFontPixelWidth * 3
35 Layout.preferredHeight: ScreenTools.defaultFontPixelHeight
36 fillMode: Image.PreserveAspectFit
39 source: "/qmlimages/FlightModesComponentIcon.png"
44 text: activeVehicle ? activeVehicle.flightMode : qsTr("N/A", "No data to display")
46 font.pointSize: fontPointSize
52 Layout.alignment: Qt.AlignVCenter
53 horizontalAlignment: Text.AlignHCenter
54 text: _vtolInFWDFlight ? qsTr("FW\nVTOL") : qsTr("MR\nVTOL")
55 font.pointSize: ScreenTools.smallFontPointSize
56 wrapMode: Text.WordWrap
62 anchors.fill: mainLayout
63 onClicked: mainWindow.showIndicatorDrawer(drawerComponent, control)
71 waitForParameters: false
72 expandedComponentWaitForParameters: true
74 contentComponent: flightModeContentComponent
75 expandedComponent: flightModeExpandedComponent
86 id: flightModeContentComponent
90 spacing: ScreenTools.defaultFontPixelWidth / 2
92 property var activeVehicle: QGroundControl.multiVehicleManager.activeVehicle
93 property var flightModeSettings: QGroundControl.settingsManager.flightModeSettings
94 property var hiddenFlightModesFact: null
95 property var hiddenFlightModesList: []
97 Component.onCompleted: {
98 // Hidden flight modes are classified by firmware and vehicle class
99 var hiddenFlightModesPropPrefix
100 if (activeVehicle.px4Firmware) {
101 hiddenFlightModesPropPrefix = "px4HiddenFlightModes"
102 } else if (activeVehicle.apmFirmware) {
103 hiddenFlightModesPropPrefix = "apmHiddenFlightModes"
105 control.allowEditMode = false
107 if (control.allowEditMode) {
108 var hiddenFlightModesProp = hiddenFlightModesPropPrefix + activeVehicle.vehicleClassInternalName()
109 if (flightModeSettings.hasOwnProperty(hiddenFlightModesProp)) {
110 hiddenFlightModesFact = flightModeSettings[hiddenFlightModesProp]
111 // Split string into list of flight modes
112 if (hiddenFlightModesFact && hiddenFlightModesFact.value !== "") {
113 hiddenFlightModesList = hiddenFlightModesFact.value.split(",")
116 control.allowEditMode = false
119 hiddenModesLabel.calcVisible()
124 function onEditModeChanged() {
126 for (var i=0; i<modeRepeater.count; i++) {
127 var button = modeRepeater.itemAt(i).children[0]
128 var checkBox = modeRepeater.itemAt(i).children[1]
130 checkBox.checked = !hiddenFlightModesList.find(item => { return item === button.text } )
137 id: vtolTransitionButton
138 Layout.fillWidth: true
139 text: _vtolInFWDFlight ? qsTr("Transition to Multi-Rotor") : qsTr("Transition to Fixed Wing")
140 visible: _isVTOL && _vehicleInAir
143 _activeVehicle.vtolInFwdFlight = !_vtolInFWDFlight
144 mainWindow.closeIndicatorDrawer()
150 model: activeVehicle ? activeVehicle.flightModes : []
153 spacing: ScreenTools.defaultFontPixelWidth
154 visible: editMode || !hiddenFlightModesList.find(item => { return item === modelData } )
159 delay: flightModeSettings.requireModeChangeConfirmation.rawValue ? defaultDelay : 0
160 Layout.fillWidth: true
164 parent.children[1].toggle()
165 parent.children[1].clicked()
167 //var controller = globals.guidedControllerFlyView
168 //controller.confirmAction(controller.actionSetFlightMode, modelData)
169 activeVehicle.flightMode = modelData
170 mainWindow.closeIndicatorDrawer()
179 hiddenFlightModesList = []
180 for (var i=0; i<modeRepeater.count; i++) {
181 var checkBox = modeRepeater.itemAt(i).children[1]
182 if (!checkBox.checked) {
183 hiddenFlightModesList.push(modeRepeater.model[i])
186 hiddenFlightModesFact.value = hiddenFlightModesList.join(",")
187 hiddenModesLabel.calcVisible()
195 text: qsTr("Some Modes Hidden")
196 Layout.fillWidth: true
197 font.pointSize: ScreenTools.smallFontPointSize
198 horizontalAlignment: Text.AlignHCenter
201 function calcVisible() {
202 hiddenModesLabel.visible = hiddenFlightModesList.length > 0
209 id: flightModeExpandedComponent
212 Layout.preferredWidth: ScreenTools.defaultFontPixelWidth * 60
215 property var qgcPal: QGroundControl.globalPalette
216 property real margins: ScreenTools.defaultFontPixelHeight
217 property var flightModeSettings: QGroundControl.settingsManager.flightModeSettings
220 Layout.fillWidth: true
221 source: _activeVehicle.expandedToolbarIndicatorSource("FlightMode")
224 SettingsGroupLayout {
225 Layout.fillWidth: true
228 Layout.fillWidth: true
229 text: qsTr("Click and Hold to Confirm Mode Change")
230 fact: flightModeSettings.requireModeChangeConfirmation
234 Layout.fillWidth: true
235 enabled: control.allowEditMode
238 Layout.fillWidth: true
239 text: qsTr("Edit Displayed Flight Modes")
243 onClicked: control.editMode = checked
248 Layout.fillWidth: true
249 label: qsTr("Flight Modes")
250 buttonText: qsTr("Configure")
251 visible: _activeVehicle.autopilotPlugin.knownVehicleComponentAvailable(AutoPilotPlugin.KnownFlightModesVehicleComponent) &&
252 QGroundControl.corePlugin.showAdvancedUI
255 mainWindow.showKnownVehicleComponentConfigPage(AutoPilotPlugin.KnownFlightModesVehicleComponent)
256 mainWindow.closeIndicatorDrawer()