Commit 1c16dfea authored by Don Gagne's avatar Don Gagne Committed by GitHub

Merge pull request #4783 from DonLakeFlyer/MissingActiveVehicle

Toolbar Indicators: Fix reference to non-existent property
parents 3036d59f 5fff9645
......@@ -25,15 +25,17 @@ Item {
anchors.bottom: parent.bottom
width: batteryIndicatorRow.width
property var _activeVehicle: QGroundControl.multiVehicleManager.activeVehicle
function getBatteryColor() {
if(activeVehicle) {
if(activeVehicle.battery.percentRemaining.value > 75) {
if(_activeVehicle) {
if(_activeVehicle.battery.percentRemaining.value > 75) {
return qgcPal.text
}
if(activeVehicle.battery.percentRemaining.value > 50) {
if(_activeVehicle.battery.percentRemaining.value > 50) {
return colorOrange
}
if(activeVehicle.battery.percentRemaining.value > 0.1) {
if(_activeVehicle.battery.percentRemaining.value > 0.1) {
return colorRed
}
}
......@@ -41,15 +43,15 @@ Item {
}
function getBatteryPercentageText() {
if(activeVehicle) {
if(activeVehicle.battery.percentRemaining.value > 98.9) {
if(_activeVehicle) {
if(_activeVehicle.battery.percentRemaining.value > 98.9) {
return "100%"
}
if(activeVehicle.battery.percentRemaining.value > 0.1) {
return activeVehicle.battery.percentRemaining.valueString + activeVehicle.battery.percentRemaining.units
if(_activeVehicle.battery.percentRemaining.value > 0.1) {
return _activeVehicle.battery.percentRemaining.valueString + _activeVehicle.battery.percentRemaining.units
}
if(activeVehicle.battery.voltage.value >= 0) {
return activeVehicle.battery.voltage.valueString + activeVehicle.battery.voltage.units
if(_activeVehicle.battery.voltage.value >= 0) {
return _activeVehicle.battery.voltage.valueString + _activeVehicle.battery.voltage.units
}
}
return "N/A"
......@@ -87,9 +89,9 @@ Item {
anchors.horizontalCenter: parent.horizontalCenter
QGCLabel { text: qsTr("Voltage:") }
QGCLabel { text: (activeVehicle && activeVehicle.battery.voltage.value != -1) ? (activeVehicle.battery.voltage.valueString + " " + activeVehicle.battery.voltage.units) : "N/A" }
QGCLabel { text: (_activeVehicle && _activeVehicle.battery.voltage.value != -1) ? (_activeVehicle.battery.voltage.valueString + " " + _activeVehicle.battery.voltage.units) : "N/A" }
QGCLabel { text: qsTr("Accumulated Consumption:") }
QGCLabel { text: (activeVehicle && activeVehicle.battery.mahConsumed.value != -1) ? (activeVehicle.battery.mahConsumed.valueString + " " + activeVehicle.battery.mahConsumed.units) : "N/A" }
QGCLabel { text: (_activeVehicle && _activeVehicle.battery.mahConsumed.value != -1) ? (_activeVehicle.battery.mahConsumed.valueString + " " + _activeVehicle.battery.mahConsumed.units) : "N/A" }
}
}
......@@ -105,7 +107,7 @@ Item {
id: batteryIndicatorRow
anchors.top: parent.top
anchors.bottom: parent.bottom
opacity: (activeVehicle && activeVehicle.battery.voltage.value >= 0) ? 1 : 0.5
opacity: (_activeVehicle && _activeVehicle.battery.voltage.value >= 0) ? 1 : 0.5
QGCColoredImage {
anchors.top: parent.top
anchors.bottom: parent.bottom
......
......@@ -25,15 +25,17 @@ Item {
anchors.top: parent.top
anchors.bottom: parent.bottom
property var _activeVehicle: QGroundControl.multiVehicleManager.activeVehicle
function getMessageColor() {
if (activeVehicle) {
if (activeVehicle.messageTypeNone)
if (_activeVehicle) {
if (_activeVehicle.messageTypeNone)
return colorGrey
if (activeVehicle.messageTypeNormal)
if (_activeVehicle.messageTypeNormal)
return colorBlue;
if (activeVehicle.messageTypeWarning)
if (_activeVehicle.messageTypeWarning)
return colorOrange;
if (activeVehicle.messageTypeError)
if (_activeVehicle.messageTypeError)
return colorRed;
// Cannot be so make make it obnoxious to show error
console.log("Invalid vehicle message type")
......@@ -50,7 +52,7 @@ Item {
sourceSize.height: height
fillMode: Image.PreserveAspectFit
cache: false
visible: activeVehicle && activeVehicle.messageCount > 0 && isMessageImportant
visible: _activeVehicle && _activeVehicle.messageCount > 0 && isMessageImportant
}
QGCColoredImage {
......
......@@ -23,9 +23,12 @@ Item {
anchors.top: parent.top
anchors.bottom: parent.bottom
width: flightModeSelector.width
property var _activeVehicle: QGroundControl.multiVehicleManager.activeVehicle
QGCLabel {
id: flightModeSelector
text: activeVehicle ? activeVehicle.flightMode : qsTr("N/A", "No data to display")
text: _activeVehicle ? _activeVehicle.flightMode : qsTr("N/A", "No data to display")
font.pointSize: ScreenTools.mediumFontPointSize
color: qgcPal.buttonText
anchors.verticalCenter: parent.verticalCenter
......@@ -35,20 +38,20 @@ Item {
Component {
id: flightModeMenuItemComponent
MenuItem {
onTriggered: activeVehicle.flightMode = text
onTriggered: _activeVehicle.flightMode = text
}
}
property var flightModesMenuItems: []
function updateFlightModesMenu() {
if (activeVehicle && activeVehicle.flightModeSetAvailable) {
if (_activeVehicle && _activeVehicle.flightModeSetAvailable) {
// Remove old menu items
for (var i = 0; i < flightModesMenuItems.length; i++) {
flightModesMenu.removeItem(flightModesMenuItems[i])
}
flightModesMenuItems.length = 0
// Add new items
for (var i = 0; i < activeVehicle.flightModes.length; i++) {
var menuItem = flightModeMenuItemComponent.createObject(null, { "text": activeVehicle.flightModes[i] })
for (var i = 0; i < _activeVehicle.flightModes.length; i++) {
var menuItem = flightModeMenuItemComponent.createObject(null, { "text": _activeVehicle.flightModes[i] })
flightModesMenuItems.push(menuItem)
flightModesMenu.insertItem(i, menuItem)
}
......@@ -60,7 +63,7 @@ Item {
onActiveVehicleChanged: flightModeSelector.updateFlightModesMenu()
}
MouseArea {
visible: activeVehicle && activeVehicle.flightModeSetAvailable
visible: _activeVehicle && _activeVehicle.flightModeSetAvailable
anchors.fill: parent
onClicked: flightModesMenu.popup()
}
......
......@@ -24,7 +24,9 @@ Item {
width: rssiRow.width * 1.1
anchors.top: parent.top
anchors.bottom: parent.bottom
visible: activeVehicle ? activeVehicle.supportsRadio : true
visible: _activeVehicle ? _activeVehicle.supportsRadio : true
property var _activeVehicle: QGroundControl.multiVehicleManager.activeVehicle
Component {
id: rcRSSIInfo
......@@ -45,21 +47,21 @@ Item {
QGCLabel {
id: rssiLabel
text: activeVehicle ? (activeVehicle.rcRSSI != 255 ? qsTr("RC RSSI Status") : qsTr("RC RSSI Data Unavailable")) : qsTr("N/A", "No data available")
text: _activeVehicle ? (_activeVehicle.rcRSSI != 255 ? qsTr("RC RSSI Status") : qsTr("RC RSSI Data Unavailable")) : qsTr("N/A", "No data available")
font.family: ScreenTools.demiboldFontFamily
anchors.horizontalCenter: parent.horizontalCenter
}
GridLayout {
id: rcrssiGrid
visible: activeVehicle && activeVehicle.rcRSSI != 255
visible: _activeVehicle && _activeVehicle.rcRSSI != 255
anchors.margins: ScreenTools.defaultFontPixelHeight
columnSpacing: ScreenTools.defaultFontPixelWidth
columns: 2
anchors.horizontalCenter: parent.horizontalCenter
QGCLabel { text: qsTr("RSSI:") }
QGCLabel { text: activeVehicle ? (activeVehicle.rcRSSI + "%") : 0 }
QGCLabel { text: _activeVehicle ? (_activeVehicle.rcRSSI + "%") : 0 }
}
}
......@@ -84,14 +86,14 @@ Item {
sourceSize.height: height
source: "/qmlimages/RC.svg"
fillMode: Image.PreserveAspectFit
opacity: activeVehicle ? (((activeVehicle.rcRSSI < 0) || (activeVehicle.rcRSSI > 100)) ? 0.5 : 1) : 0.5
opacity: _activeVehicle ? (((_activeVehicle.rcRSSI < 0) || (_activeVehicle.rcRSSI > 100)) ? 0.5 : 1) : 0.5
color: qgcPal.buttonText
}
SignalStrength {
anchors.verticalCenter: parent.verticalCenter
size: parent.height * 0.5
percent: activeVehicle ? ((activeVehicle.rcRSSI > 100) ? 0 : activeVehicle.rcRSSI) : 0
percent: _activeVehicle ? ((_activeVehicle.rcRSSI > 100) ? 0 : _activeVehicle.rcRSSI) : 0
}
}
......
......@@ -27,7 +27,10 @@ QGCColoredImage {
source: "/qmlimages/TelemRSSI.svg"
fillMode: Image.PreserveAspectFit
color: qgcPal.buttonText
visible: activeVehicle ? (activeVehicle.telemetryLRSSI < 0) : false
visible: _activeVehicle ? (_activeVehicle.telemetryLRSSI < 0) : false
property var _activeVehicle: QGroundControl.multiVehicleManager.activeVehicle
Component {
id: telemRSSIInfo
Rectangle {
......@@ -55,19 +58,19 @@ QGCColoredImage {
columns: 2
anchors.horizontalCenter: parent.horizontalCenter
QGCLabel { text: qsTr("Local RSSI:") }
QGCLabel { text: activeVehicle.telemetryLRSSI + " dBm" }
QGCLabel { text: _activeVehicle.telemetryLRSSI + " dBm" }
QGCLabel { text: qsTr("Remote RSSI:") }
QGCLabel { text: activeVehicle.telemetryRRSSI + " dBm" }
QGCLabel { text: _activeVehicle.telemetryRRSSI + " dBm" }
QGCLabel { text: qsTr("RX Errors:") }
QGCLabel { text: activeVehicle.telemetryRXErrors }
QGCLabel { text: _activeVehicle.telemetryRXErrors }
QGCLabel { text: qsTr("Errors Fixed:") }
QGCLabel { text: activeVehicle.telemetryFixed }
QGCLabel { text: _activeVehicle.telemetryFixed }
QGCLabel { text: qsTr("TX Buffer:") }
QGCLabel { text: activeVehicle.telemetryTXBuffer }
QGCLabel { text: _activeVehicle.telemetryTXBuffer }
QGCLabel { text: qsTr("Local Noise:") }
QGCLabel { text: activeVehicle.telemetryLNoise }
QGCLabel { text: _activeVehicle.telemetryLNoise }
QGCLabel { text: qsTr("Remote Noise:") }
QGCLabel { text: activeVehicle.telemetryRNoise }
QGCLabel { text: _activeVehicle.telemetryRNoise }
}
}
Component.onCompleted: {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment