QGroundControl
Ground Control Station for MAVLink Drones
Loading...
Searching...
No Matches
RemoteIDIndicatorPage.qml
Go to the documentation of this file.
1import QtQuick
2import QtQuick.Layouts
3
4import QGroundControl
5import QGroundControl.Controls
6import QGroundControl.FactControls
7
8ToolIndicatorPage {
9 showExpand: true
10
11 property var _activeVehicle: QGroundControl.multiVehicleManager.activeVehicle
12
13 property bool gpsFlag: _activeVehicle && _activeVehicle.remoteIDManager ? _activeVehicle.remoteIDManager.gcsGPSGood : false
14 property bool basicIDFlag: _activeVehicle && _activeVehicle.remoteIDManager ? _activeVehicle.remoteIDManager.basicIDGood : false
15 property bool armFlag: _activeVehicle && _activeVehicle.remoteIDManager ? _activeVehicle.remoteIDManager.armStatusGood : false
16 property bool commsFlag: _activeVehicle && _activeVehicle.remoteIDManager ? _activeVehicle.remoteIDManager.commsGood : false
17 property bool emergencyDeclared: _activeVehicle && _activeVehicle.remoteIDManager ? _activeVehicle.remoteIDManager.emergencyDeclared : false
18 property bool operatorIDFlag: _activeVehicle && _activeVehicle.remoteIDManager ? _activeVehicle.remoteIDManager.operatorIDGood : false
19
20 property int _regionOperation: QGroundControl.settingsManager.remoteIDSettings.region.value
21
22 // Flags visual properties
23 property real flagsWidth: ScreenTools.defaultFontPixelWidth * 10
24 property real flagsHeight: ScreenTools.defaultFontPixelWidth * 5
25 property int radiusFlags: 5
26
27 // Visual properties
28 property real _margins: ScreenTools.defaultFontPixelWidth
29
30 enum RegionOperation {
31 FAA,
32 EU
33 }
34
35 enum LocationType {
36 TAKEOFF,
37 LIVE,
38 FIXED
39 }
40
41 enum ClassificationType {
42 UNDEFINED,
43 EU
44 }
45
46 function goToSettings() {
47 if (mainWindow.allowViewSwitch()) {
48 mainWindow.closeIndicatorDrawer()
49 globals.commingFromRIDIndicator = true
50 mainWindow.showSettingsTool()
51 }
52 }
53
54 contentComponent: Component {
55 Rectangle {
56 width: remoteIDCol.width + ScreenTools.defaultFontPixelWidth * 3
57 height: remoteIDCol.height + ScreenTools.defaultFontPixelHeight * 2 + (emergencyButtonItem.visible ? emergencyButtonItem.height : 0)
58 radius: ScreenTools.defaultFontPixelHeight * 0.5
59 color: qgcPal.window
60 border.color: qgcPal.text
61
62 Column {
63 id: remoteIDCol
64 spacing: ScreenTools.defaultFontPixelHeight * 0.5
65 width: Math.max(remoteIDGrid.width, remoteIDLabel.width)
66 anchors.margins: ScreenTools.defaultFontPixelHeight
67 anchors.top: parent.top
68 anchors.horizontalCenter: parent.horizontalCenter
69
70 QGCLabel {
71 id: remoteIDLabel
72 text: qsTr("RemoteID Status")
73 font.bold: true
74 anchors.horizontalCenter: parent.horizontalCenter
75 }
76
77 GridLayout {
78 id: remoteIDGrid
79 anchors.margins: ScreenTools.defaultFontPixelHeight
80 columnSpacing: ScreenTools.defaultFontPixelWidth
81 anchors.horizontalCenter: parent.horizontalCenter
82 columns: 2
83
84 Image {
85 id: armFlagImage
86 width: flagsWidth
87 height: flagsHeight
88 source: armFlag ? "/qmlimages/RidFlagBackgroundGreen.svg" : "/qmlimages/RidFlagBackgroundRed.svg"
89 fillMode: Image.PreserveAspectFit
90 sourceSize.height: height
91 visible: commsFlag
92
93 QGCLabel {
94 anchors.fill: parent
95 text: qsTr("ARM STATUS")
96 wrapMode: Text.WordWrap
97 horizontalAlignment: Text.AlignHCenter
98 verticalAlignment: Text.AlignVCenter
99 font.bold: true
100 font.pointSize: ScreenTools.smallFontPointSize
101 }
102
103 QGCMouseArea {
104 anchors.fill: parent
105 onClicked: goToSettings()
106 }
107 }
108
109 Image {
110 id: commsFlagImage
111 width: flagsWidth
112 height: flagsHeight
113 source: commsFlag ? "/qmlimages/RidFlagBackgroundGreen.svg" : "/qmlimages/RidFlagBackgroundRed.svg"
114 fillMode: Image.PreserveAspectFit
115 sourceSize.height: height
116
117 QGCLabel {
118 anchors.fill: parent
119 text: commsFlag ? qsTr("RID COMMS") : qsTr("NOT CONNECTED")
120 wrapMode: Text.WordWrap
121 horizontalAlignment: Text.AlignHCenter
122 verticalAlignment: Text.AlignVCenter
123 font.bold: true
124 font.pointSize: ScreenTools.smallFontPointSize
125 }
126
127 QGCMouseArea {
128 anchors.fill: parent
129 onClicked: goToSettings()
130 }
131 }
132
133 Image {
134 id: gpsFlagImage
135 width: flagsWidth
136 height: flagsHeight
137 source: gpsFlag ? "/qmlimages/RidFlagBackgroundGreen.svg" : "/qmlimages/RidFlagBackgroundRed.svg"
138 fillMode: Image.PreserveAspectFit
139 sourceSize.height: height
140 visible: commsFlag
141
142 QGCLabel {
143 anchors.fill: parent
144 text: qsTr("GCS GPS")
145 wrapMode: Text.WordWrap
146 horizontalAlignment: Text.AlignHCenter
147 verticalAlignment: Text.AlignVCenter
148 font.bold: true
149 font.pointSize: ScreenTools.smallFontPointSize
150 }
151
152 QGCMouseArea {
153 anchors.fill: parent
154 onClicked: goToSettings()
155 }
156 }
157
158 Image {
159 id: basicIDFlagIge
160 width: flagsWidth
161 height: flagsHeight
162 source: basicIDFlag ? "/qmlimages/RidFlagBackgroundGreen.svg" : "/qmlimages/RidFlagBackgroundRed.svg"
163 fillMode: Image.PreserveAspectFit
164 sourceSize.height: height
165 visible: commsFlag
166
167 QGCLabel {
168 anchors.fill: parent
169 text: qsTr("BASIC ID")
170 wrapMode: Text.WordWrap
171 horizontalAlignment: Text.AlignHCenter
172 verticalAlignment: Text.AlignVCenter
173 font.bold: true
174 font.pointSize: ScreenTools.smallFontPointSize
175 }
176
177 QGCMouseArea {
178 anchors.fill: parent
179 onClicked: goToSettings()
180 }
181 }
182
183 Image {
184 id: operatorIDFlagImage
185 width: flagsWidth
186 height: flagsHeight
187 source: operatorIDFlag ? "/qmlimages/RidFlagBackgroundGreen.svg" : "/qmlimages/RidFlagBackgroundRed.svg"
188 fillMode: Image.PreserveAspectFit
189 sourceSize.height: height
190 visible: commsFlag && _activeVehicle ? (QGroundControl.settingsManager.remoteIDSettings.sendOperatorID.value || _regionOperation == RemoteIDIndicatorPage.EU) : false
191
192 QGCLabel {
193 anchors.fill: parent
194 text: qsTr("OPERATOR ID")
195 wrapMode: Text.WordWrap
196 horizontalAlignment: Text.AlignHCenter
197 verticalAlignment: Text.AlignVCenter
198 font.bold: true
199 font.pointSize: ScreenTools.smallFontPointSize
200 }
201
202 QGCMouseArea {
203 anchors.fill: parent
204 onClicked: goToSettings()
205 }
206 }
207 }
208 }
209
210 Item {
211 id: emergencyButtonItem
212 anchors.top: remoteIDCol.bottom
213 anchors.left: parent.left
214 anchors.right: parent.right
215 height: emergencyDeclareLabel.height + emergencyButton.height + (_margins * 4)
216 visible: commsFlag
217
218 QGCLabel {
219 id: emergencyDeclareLabel
220 text: emergencyDeclared ? qsTr("EMERGENCY HAS BEEN DECLARED, Press and Hold for 3 seconds to cancel") : qsTr("Press and Hold below button to declare emergency")
221 font.bold: true
222 anchors.top: parent.top
223 anchors.left: parent.left
224 anchors.right: parent.right
225 anchors.margins: _margins
226 anchors.topMargin: _margins * 3
227 wrapMode: Text.WordWrap
228 horizontalAlignment: Text.AlignHCenter
229 visible: true
230 }
231
232 Image {
233 id: emergencyButton
234 width: flagsWidth * 2
235 height: flagsHeight * 1.5
236 source: "/qmlimages/RidEmergencyBackground.svg"
237 sourceSize.height: height
238 anchors.horizontalCenter: parent.horizontalCenter
239 anchors.top: emergencyDeclareLabel.bottom
240 anchors.margins: _margins
241 visible: true
242
243 QGCLabel {
244 anchors.fill: parent
245 text: emergencyDeclared ? qsTr("Clear Emergency") : qsTr("EMERGENCY")
246 wrapMode: Text.WordWrap
247 horizontalAlignment: Text.AlignHCenter
248 verticalAlignment: Text.AlignVCenter
249 font.bold: true
250 font.pointSize: ScreenTools.largeFontPointSize
251 }
252
253 Timer {
254 id: emergencyButtonTimer
255 interval: 350
256 onTriggered: {
257 if (emergencyButton.source == "/qmlimages/RidEmergencyBackgroundHighlight.svg" ) {
258 emergencyButton.source = "/qmlimages/RidEmergencyBackground.svg"
259 } else {
260 emergencyButton.source = "/qmlimages/RidEmergencyBackgroundHighlight.svg"
261 }
262 }
263 }
264
265 MouseArea {
266 anchors.fill: parent
267 hoverEnabled: true
268 onEntered: emergencyButton.source = "/qmlimages/RidEmergencyBackgroundHighlight.svg"
269 onExited: emergencyButton.source = "/qmlimages/RidEmergencyBackground.svg"
270 pressAndHoldInterval: emergencyDeclared ? 3000 : 800
271 onPressAndHold: {
272 if (emergencyButton.source == "/qmlimages/RidEmergencyBackgroundHighlight.svg" ) {
273 emergencyButton.source = "/qmlimages/RidEmergencyBackground.svg"
274 } else {
275 emergencyButton.source = "/qmlimages/RidEmergencyBackgroundHighlight.svg"
276 }
277 emergencyButtonTimer.restart()
278 if (_activeVehicle) {
279 _activeVehicle.remoteIDManager.setEmergency(!emergencyDeclared)
280 }
281 }
282 }
283 }
284 }
285 }
286 }
287
288 expandedComponent: Component {
289 RowLayout {
290 spacing: ScreenTools.defaultFontPixelWidth
291
292 property var remoteIDSettings:QGroundControl.settingsManager.remoteIDSettings
293 property Fact regionFact: remoteIDSettings.region
294 property Fact sendOperatorIdFact: remoteIDSettings.sendOperatorID
295 property Fact locationTypeFact: remoteIDSettings.locationType
296 property Fact operatorIDFact: remoteIDSettings.operatorID
297 property bool isEURegion: regionFact.rawValue == RemoteIDIndicatorPage.EU
298 property bool isFAARegion: regionFact.rawValue == RemoteIDIndicatorPage.FAA
299 property real textFieldWidth: ScreenTools.defaultFontPixelWidth * 24
300 property real textLabelWidth: ScreenTools.defaultFontPixelWidth * 30
301
302 Connections {
303 target: regionFact
304 onRawValueChanged: {
305 if (regionFact.rawValue === RemoteIDIndicatorPage.EU) {
306 sendOperatorIdFact.rawValue = true
307 }
308 if (regionFact.rawValue === RemoteIDIndicatorPage.FAA) {
309 locationTypeFact.value = RemoteIDIndicatorPage.LocationType.LIVE
310 }
311 }
312 }
313
314 ColumnLayout {
315 spacing: ScreenTools.defaultFontPixelHeight / 2
316 Layout.alignment: Qt.AlignTop
317
318
319 SettingsGroupLayout {
320 visible: armStatusLabel.labelText !== ""
321 LabelledLabel {
322 id : armStatusLabel
323 label: qsTr("Arm Status Error")
324 labelText: remoteIDManager.armStatusError
325 Layout.fillWidth: true
326 }
327 }
328
329 SettingsGroupLayout {
330 heading: qsTr("Self ID")
331 Layout.fillWidth: true
332
333 ColumnLayout {
334 Layout.fillWidth: true
335 spacing: ScreenTools.defaultFontPixelHeight / 2
336
337 FactCheckBoxSlider {
338 id: sendSelfIDSlider
339 text: qsTr("Broadcast")
340 fact: _fact
341 visible: _fact.visible
342 Layout.fillWidth: true
343
344 property Fact _fact: remoteIDSettings.sendSelfID
345 }
346
347 QGCLabel {
348 text: qsTr("If an emergency is declared, Emergency Text will be broadcast even if Broadcast setting is not enabled.")
349 font.pointSize: ScreenTools.smallFontPointSize
350 wrapMode: Text.WordWrap
351 Layout.preferredWidth: sendSelfIDSlider.width
352 visible: !sendSelfIDSlider._fact.rawValue
353 }
354 }
355
356 LabelledFactComboBox {
357 id: selfIDTypeCombo
358 label: qsTr("Broadcast Message")
359 fact: _fact
360 indexModel: false
361 visible: _fact.visible
362 enabled: sendSelfIDSlider._fact.rawValue
363 Layout.fillWidth: true
364
365 property Fact _fact: remoteIDSettings.selfIDType
366 }
367
368 LabelledFactTextField {
369 label: _fact.shortDescription
370 fact: _fact
371 visible: _fact.visible
372 enabled: sendSelfIDSlider._fact.rawValue
373 textField.maximumLength: 23
374 Layout.fillWidth: true
375 textFieldPreferredWidth: textFieldWidth
376
377 property Fact _fact: remoteIDSettings.selfIDFree
378 }
379
380 LabelledFactTextField {
381 label: _fact.shortDescription
382 fact: _fact
383 visible: _fact.visible
384 enabled: sendSelfIDSlider._fact.rawValue
385 textField.maximumLength: 23
386 Layout.fillWidth: true
387 textFieldPreferredWidth: textFieldWidth
388
389 property Fact _fact: remoteIDSettings.selfIDExtended
390 }
391
392 LabelledFactTextField {
393 label: _fact.shortDescription
394 fact: _fact
395 visible: _fact.visible
396 textField.maximumLength: 23
397 Layout.fillWidth: true
398 textFieldPreferredWidth: textFieldWidth
399
400 property Fact _fact: remoteIDSettings.selfIDEmergency
401 }
402 }
403
404 SettingsGroupLayout {
405 Layout.fillWidth: true
406 visible: QGroundControl.corePlugin.showAdvancedUI
407
408 RowLayout {
409 Layout.fillWidth: true
410
411 QGCLabel { Layout.fillWidth: true; text: qsTr("Remote ID") }
412 QGCButton {
413 text: qsTr("Configure")
414 onClicked: {
415 goToSettings()
416 }
417 }
418 }
419 }
420 }
421
422 }
423 }
424}