QGroundControl
Ground Control Station for MAVLink Drones
Loading...
Searching...
No Matches
SetupView.qml
Go to the documentation of this file.
1import QtQuick
2import QtQuick.Controls
3import QtQuick.Layouts
4
5import QGroundControl
6import QGroundControl.Controls
7
8Rectangle {
9 id: setupView
10 color: qgcPal.window
11 z: QGroundControl.zOrderTopMost
12
13 // This need to block click event leakage to underlying map.
14 DeadMouseArea {
15 anchors.fill: parent
16 }
17
18 QGCPalette { id: qgcPal; colorGroupEnabled: true }
19
20 readonly property real _defaultTextHeight: ScreenTools.defaultFontPixelHeight
21 readonly property real _defaultTextWidth: ScreenTools.defaultFontPixelWidth
22 readonly property real _horizontalMargin: _defaultTextWidth / 2
23 readonly property real _verticalMargin: _defaultTextHeight / 2
24 readonly property real _buttonWidth: _defaultTextWidth * 18
25 readonly property string _armedVehicleText: qsTr("This operation cannot be performed while the vehicle is armed.")
26
27 property var _activeVehicle: QGroundControl.multiVehicleManager.activeVehicle
28 property bool _vehicleArmed: _activeVehicle ? _activeVehicle.armed : false
29 property string _messagePanelText: qsTr("missing message panel text")
30 property bool _fullParameterVehicleAvailable: QGroundControl.multiVehicleManager.parameterReadyVehicleAvailable && !_activeVehicle.parameterManager.missingParameters
31 property var _corePlugin: QGroundControl.corePlugin
32
33 function showSummaryPanel() {
34 if (mainWindow.allowViewSwitch()) {
35 _showSummaryPanel()
36 }
37 }
38
39 function _showSummaryPanel() {
40 if (_fullParameterVehicleAvailable) {
41 if (_activeVehicle.autopilotPlugin.vehicleComponents.length === 0) {
42 panelLoader.setSourceComponent(noComponentsVehicleSummaryComponent)
43 } else {
44 panelLoader.setSource("qrc:/qml/QGroundControl/VehicleSetup/VehicleSummary.qml")
45 }
46 } else if (QGroundControl.multiVehicleManager.parameterReadyVehicleAvailable) {
47 panelLoader.setSourceComponent(missingParametersVehicleSummaryComponent)
48 } else {
49 panelLoader.setSourceComponent(disconnectedVehicleAndParamsSummaryComponent)
50 }
51 summaryButton.checked = true
52 }
53
54 function showPanel(button, qmlSource) {
55 if (mainWindow.allowViewSwitch()) {
56 button.checked = true
57 panelLoader.setSource(qmlSource)
58 }
59 }
60
61 function showVehicleComponentPanel(vehicleComponent)
62 {
63 if (mainWindow.allowViewSwitch()) {
64 var autopilotPlugin = _activeVehicle.autopilotPlugin
65 var prereq = autopilotPlugin.prerequisiteSetup(vehicleComponent)
66 if (prereq !== "") {
67 _messagePanelText = qsTr("%1 setup must be completed prior to %2 setup.").arg(prereq).arg(vehicleComponent.name)
68 panelLoader.setSourceComponent(messagePanelComponent)
69 } else {
70 panelLoader.setSource(vehicleComponent.setupSource, vehicleComponent)
71 for(var i = 0; i < componentRepeater.count; i++) {
72 var obj = componentRepeater.itemAt(i);
73 if (obj.text === vehicleComponent.name) {
74 obj.checked = true
75 break;
76 }
77 }
78 }
79 }
80 }
81
82 function showParametersPanel() {
83 if (mainWindow.allowViewSwitch()) {
84 parametersButton.checked = true
85 panelLoader.setSource("qrc:/qml/QGroundControl/VehicleSetup/SetupParameterEditor.qml")
86 }
87 }
88
89 Component.onCompleted: _showSummaryPanel()
90
91 Connections {
92 target: QGroundControl.corePlugin
93 function onShowAdvancedUIChanged(showAdvancedUI) {
94 if (!showAdvancedUI) {
95 _showSummaryPanel()
96 }
97 }
98 }
99
100 Connections {
101 target: QGroundControl.multiVehicleManager
102 function onParameterReadyVehicleAvailableChanged(parametersReady) {
103 if (parametersReady || summaryButton.checked || !firmwareButton.checked) {
104 // Show/Reload the Summary panel when:
105 // A new vehicle shows up
106 // The summary panel is already showing and the active vehicle goes away
107 // The active vehicle goes away and we are not on the Firmware panel.
108 summaryButton.checked = true
109 _showSummaryPanel()
110 }
111 }
112 }
113
114 Component {
115 id: noComponentsVehicleSummaryComponent
116 Rectangle {
117 color: qgcPal.windowShade
118 QGCLabel {
119 anchors.margins: _defaultTextWidth * 2
120 anchors.fill: parent
121 verticalAlignment: Text.AlignVCenter
122 horizontalAlignment: Text.AlignHCenter
123 wrapMode: Text.WordWrap
124 font.pointSize: ScreenTools.mediumFontPointSize
125 text: qsTr("%1 does not currently support configuration of your vehicle. ").arg(QGroundControl.appName) +
126 "If your vehicle is already configured you can still Fly."
127 }
128 }
129 }
130
131 Component {
132 id: disconnectedVehicleAndParamsSummaryComponent
133 Rectangle {
134 color: qgcPal.windowShade
135 QGCLabel {
136 anchors.margins: _defaultTextWidth * 2
137 anchors.fill: parent
138 verticalAlignment: Text.AlignVCenter
139 horizontalAlignment: Text.AlignHCenter
140 wrapMode: Text.WordWrap
141 font.pointSize: ScreenTools.largeFontPointSize
142 text: qsTr("Vehicle configuration pages will display after you connect your vehicle and parameters have been downloaded.")
143 }
144 }
145 }
146
147 Component {
148 id: missingParametersVehicleSummaryComponent
149
150 Rectangle {
151 color: qgcPal.windowShade
152
153 QGCLabel {
154 anchors.margins: _defaultTextWidth * 2
155 anchors.fill: parent
156 verticalAlignment: Text.AlignVCenter
157 horizontalAlignment: Text.AlignHCenter
158 wrapMode: Text.WordWrap
159 font.pointSize: ScreenTools.mediumFontPointSize
160 text: qsTr("Vehicle did not return the full parameter list. ") +
161 qsTr("As a result, the configuration pages are not available.")
162 }
163 }
164 }
165
166 Component {
167 id: messagePanelComponent
168
169 Item {
170 QGCLabel {
171 anchors.margins: _defaultTextWidth * 2
172 anchors.fill: parent
173 verticalAlignment: Text.AlignVCenter
174 horizontalAlignment: Text.AlignHCenter
175 wrapMode: Text.WordWrap
176 font.pointSize: ScreenTools.mediumFontPointSize
177 text: _messagePanelText
178 }
179 }
180 }
181
182 QGCFlickable {
183 id: buttonScroll
184 width: buttonColumn.width
185 anchors.topMargin: _defaultTextHeight / 2
186 anchors.top: parent.top
187 anchors.bottom: parent.bottom
188 anchors.leftMargin: _horizontalMargin
189 anchors.left: parent.left
190 contentHeight: buttonColumn.height
191 flickableDirection: Flickable.VerticalFlick
192 clip: true
193
194 ColumnLayout {
195 id: buttonColumn
196 spacing: ScreenTools.defaultFontPixelHeight / 4
197
198 ConfigButton {
199 id: summaryButton
200 icon.source: "/qmlimages/VehicleSummaryIcon.png"
201 checked: true
202 text: qsTr("Summary")
203 Layout.fillWidth: true
204
205 onClicked: showSummaryPanel()
206 }
207
208 ConfigButton {
209 visible: _activeVehicle ? _activeVehicle.flowImageIndex > 0 : false
210 text: qsTr("Optical Flow")
211 Layout.fillWidth: true
212 onClicked: showPanel(this, "qrc:/qml/QGroundControl/VehicleSetup/OpticalFlowSensor.qml");
213 }
214
215 Repeater {
216 id: componentRepeater
217 model: _fullParameterVehicleAvailable ? _activeVehicle.autopilotPlugin.vehicleComponents : 0
218
219 ConfigButton {
220 icon.source: modelData.iconResource
221 setupComplete: modelData.setupComplete
222 text: modelData.name
223 visible: modelData.setupSource.toString() !== ""
224 Layout.fillWidth: true
225 onClicked: showVehicleComponentPanel(componentUrl)
226
227 property var componentUrl: modelData
228 }
229 }
230
231 ConfigButton {
232 id: parametersButton
233 visible: QGroundControl.multiVehicleManager.parameterReadyVehicleAvailable &&
234 !_activeVehicle.usingHighLatencyLink &&
235 _corePlugin.showAdvancedUI
236 text: qsTr("Parameters")
237 Layout.fillWidth: true
238 icon.source: "/qmlimages/subMenuButtonImage.png"
239 onClicked: showPanel(this, "qrc:/qml/QGroundControl/VehicleSetup/SetupParameterEditor.qml")
240 }
241
242 ConfigButton {
243 id: firmwareButton
244 icon.source: "/qmlimages/FirmwareUpgradeIcon.png"
245 visible: !ScreenTools.isMobile && _corePlugin.options.showFirmwareUpgrade
246 text: qsTr("Firmware")
247 Layout.fillWidth: true
248
249 onClicked: showPanel(this, "qrc:/qml/QGroundControl/VehicleSetup/FirmwareUpgrade.qml")
250 }
251 }
252 }
253
254 Rectangle {
255 id: divider
256 anchors.topMargin: _verticalMargin
257 anchors.bottomMargin: _verticalMargin
258 anchors.leftMargin: _horizontalMargin
259 anchors.left: buttonScroll.right
260 anchors.top: parent.top
261 anchors.bottom: parent.bottom
262 width: 1
263 color: qgcPal.windowShade
264 }
265
266 Loader {
267 id: panelLoader
268 anchors.topMargin: _verticalMargin
269 anchors.bottomMargin: _verticalMargin
270 anchors.leftMargin: _horizontalMargin
271 anchors.rightMargin: _horizontalMargin
272 anchors.left: divider.right
273 anchors.right: parent.right
274 anchors.top: parent.top
275 anchors.bottom: parent.bottom
276
277 function setSource(source, vehicleComponent) {
278 panelLoader.source = ""
279 panelLoader.vehicleComponent = vehicleComponent
280 panelLoader.source = source
281 }
282
283 function setSourceComponent(sourceComponent, vehicleComponent) {
284 panelLoader.sourceComponent = undefined
285 panelLoader.vehicleComponent = vehicleComponent
286 panelLoader.sourceComponent = sourceComponent
287 }
288
289 property var vehicleComponent
290 }
291}