1pragma ComponentBehavior: Bound
6import QGroundControl.Controls
8// Vehicle GPS status, or the GNSS receiver's while the vehicle reports no GPS, plus correction and resilience state.
11 objectName: "toolbar_gpsIndicator"
12 width: gpsIndicatorRow.width
13 anchors.top: parent.top
14 anchors.bottom: parent.bottom
16 property bool showIndicator: true
17 property Vehicle _activeVehicle: QGroundControl.multiVehicleManager.activeVehicle
18 property VehicleGPSFactGroup _gps: _activeVehicle ? _activeVehicle.gps : null
19 property VehicleGPSFactGroup _gps2: _activeVehicle ? _activeVehicle.gps2 : null
20 readonly property bool _vehicleGps: !!_gps && _gps.telemetryAvailable
21 property GPSReceiver _receiver: QGroundControl.gpsManager.receiver
22 readonly property GPSReceiverFactGroup _receiverFacts: _receiver.facts
23 property bool _receiverConnected: _receiverFacts.telemetryAvailable
24 readonly property bool _receiverWarning: _receiverConnected && _receiverFacts.receiverWarning
25 readonly property int _receiverSatellites: _receiverFacts.numSatellitesUsed.rawValue
26 readonly property string _receiverDetail: _receiver.summaryLabel
27 property int _correctionState: QGroundControl.gpsManager.corrections.state
28 readonly property bool _showRtk: _correctionState !== GPSCorrectionManager.Inactive
29 // The icons show the worse of the two receivers.
30 readonly property VehicleGPSFactGroup _authenticationSource:
31 _gps2 && (!_gps || _gps2.authenticationSeverity > _gps.authenticationSeverity) ? _gps2 : _gps
32 readonly property int _authenticationState: _authenticationSource && _authenticationSource.authenticationReported
33 ? _authenticationSource.authenticationState.value : 0
34 readonly property int _interferenceState: {
35 const first = control._gps ? control._gps.interferenceState : 0
36 const second = control._gps2 ? control._gps2.interferenceState : 0
37 return control._interferenceSeverity(second) > control._interferenceSeverity(first) ? second : first
39 readonly property color _authenticationColor: {
40 switch (_authenticationState) {
41 case VehicleGPSFactGroup.AuthenticationState.Initializing: return qgcPal.colorYellow
42 case VehicleGPSFactGroup.AuthenticationState.Error: return qgcPal.colorRed
43 case VehicleGPSFactGroup.AuthenticationState.Ok: return qgcPal.colorGreen
44 default: return qgcPal.colorGrey
47 readonly property color _interferenceColor: {
48 switch (_interferenceState) {
49 case VehicleGPSFactGroup.InterferenceState.NotDetected: return qgcPal.colorGreen
50 case VehicleGPSFactGroup.InterferenceState.Mitigated: return qgcPal.colorOrange
51 default: return qgcPal.colorRed
55 function _interferenceSeverity(state) {
57 case VehicleGPSFactGroup.InterferenceState.NotDetected: return 1
58 case VehicleGPSFactGroup.InterferenceState.Mitigated: return 2
59 case VehicleGPSFactGroup.InterferenceState.Detected: return 3
64 QGCPalette { id: qgcPal }
68 anchors.top: parent.top
69 anchors.bottom: parent.bottom
70 spacing: ScreenTools.defaultFontPixelWidth / 2
73 anchors.top: parent.top
74 anchors.bottom: parent.bottom
75 spacing: -ScreenTools.defaultFontPixelWidth / 2
79 objectName: "gpsCorrectionsLabel"
81 text: control._showRtk ? qsTr("RTK") : qsTr("GNSS")
82 color: control._receiverWarning || control._correctionState === GPSCorrectionManager.Waiting
83 ? qgcPal.colorOrange : qgcPal.text
84 anchors.verticalCenter: parent.verticalCenter
85 visible: control._receiverConnected || control._showRtk
91 anchors.top: parent.top
92 anchors.bottom: parent.bottom
93 source: "/qmlimages/GPS.svg"
94 fillMode: Image.PreserveAspectFit
95 sourceSize.height: height
96 opacity: (control._vehicleGps ? control._gps.count.value > 0
97 : control._receiverConnected && control._receiverSatellites > 0) ? 1 : 0.5
102 // Satellites and HDOP from the vehicle; satellites used and fix from the receiver without vehicle GPS.
105 anchors.verticalCenter: parent.verticalCenter
106 visible: control._vehicleGps ? !isNaN(control._gps.hdop.value) : control._receiverConnected
110 objectName: "gpsSatelliteCount"
111 anchors.horizontalCenter: gpsDetail.horizontalCenter
113 text: control._vehicleGps ? control._gps.count.valueString
114 : control._receiverSatellites >= 0 ? String(control._receiverSatellites) : "–"
119 objectName: "gpsDetail"
121 text: control._vehicleGps ? control._gps.hdop.valueString : control._receiverDetail
127 anchors.top: parent.top
128 anchors.bottom: parent.bottom
129 visible: control._authenticationState > 0 || control._interferenceState > 0
132 width: parent.height * 0.95
134 anchors.centerIn: parent
135 objectName: "gpsAuthenticationIcon"
136 source: "/qmlimages/GPSAuthentication.svg"
137 fillMode: Image.PreserveAspectFit
138 sourceSize.height: height
139 color: control._authenticationColor
140 visible: control._authenticationState > 0
144 objectName: "gpsInterferenceIcon"
145 width: parent.height * 0.55
147 anchors.centerIn: parent
148 source: "/qmlimages/GPSInterference.svg"
149 fillMode: Image.PreserveAspectFit
150 sourceSize.height: height
151 color: control._interferenceColor
152 visible: control._interferenceState > 0
159 onClicked: mainWindow.showIndicatorDrawer(gpsIndicatorPage, control)