diff --git a/qgroundcontrol.qrc b/qgroundcontrol.qrc index b25a9fa69ed727be29273e5ca840fbf3d78849fd..296df8debaf853e773ee5c14d023f9f9568186c4 100644 --- a/qgroundcontrol.qrc +++ b/qgroundcontrol.qrc @@ -2,6 +2,14 @@ src/FactSystem/FactSystemTest.qml + + src/ui/toolbar/BatteryIndicator.qml + src/ui/toolbar/GPSIndicator.qml + src/ui/toolbar/MessageIndicator.qml + src/ui/toolbar/ModeIndicator.qml + src/ui/toolbar/RCRSSIIndicator.qml + src/ui/toolbar/TelemetryRSSIIndicator.qml + src/AutoPilotPlugins/PX4/AirframeComponent.qml src/AutoPilotPlugins/PX4/AirframeComponentSummary.qml diff --git a/src/api/QGCCorePlugin.cc b/src/api/QGCCorePlugin.cc index eab76cc0f684325029845d9ab3e7f3b66e96178b..b59c274a3db8284627e30dab861dbaaaebd5b6a0 100644 --- a/src/api/QGCCorePlugin.cc +++ b/src/api/QGCCorePlugin.cc @@ -65,6 +65,7 @@ public: QGCSettings* pDebug; #endif QVariantList settingsList; + QVariantList toolBarIndicatorList; QGCOptions* defaultOptions; }; @@ -126,7 +127,7 @@ QVariantList &QGCCorePlugin::settings() return _p->settingsList; } -int QGCCorePlugin::defaltSettings() +int QGCCorePlugin::defaultSettings() { return 0; } @@ -142,7 +143,19 @@ QGCOptions* QGCCorePlugin::options() QVariant QGCCorePlugin::overrideSettingsDefault(QString name, QVariant defaultValue) { Q_UNUSED(name); - // No overrides for base plugin return defaultValue; } + +QVariantList& QGCCorePlugin::toolBarIndicators() +{ + if(_p->toolBarIndicatorList.size() == 0) { + _p->toolBarIndicatorList.append(QVariant::fromValue(QUrl::fromUserInput("qrc:/toolbar/MessageIndicator.qml"))); + _p->toolBarIndicatorList.append(QVariant::fromValue(QUrl::fromUserInput("qrc:/toolbar/GPSIndicator.qml"))); + _p->toolBarIndicatorList.append(QVariant::fromValue(QUrl::fromUserInput("qrc:/toolbar/TelemetryRSSIIndicator.qml"))); + _p->toolBarIndicatorList.append(QVariant::fromValue(QUrl::fromUserInput("qrc:/toolbar/RCRSSIIndicator.qml"))); + _p->toolBarIndicatorList.append(QVariant::fromValue(QUrl::fromUserInput("qrc:/toolbar/BatteryIndicator.qml"))); + _p->toolBarIndicatorList.append(QVariant::fromValue(QUrl::fromUserInput("qrc:/toolbar/ModeIndicator.qml"))); + } + return _p->toolBarIndicatorList; +} diff --git a/src/api/QGCCorePlugin.h b/src/api/QGCCorePlugin.h index b668a9d7cba0cc8440f38a082373bb5fc22aa768..582821a3aca385c59c44497772889a131a2f5bca 100644 --- a/src/api/QGCCorePlugin.h +++ b/src/api/QGCCorePlugin.h @@ -32,36 +32,35 @@ public: QGCCorePlugin(QGCApplication* app); ~QGCCorePlugin(); - Q_PROPERTY(QVariantList settings READ settings CONSTANT) - Q_PROPERTY(int defaltSettings READ defaltSettings CONSTANT) - Q_PROPERTY(QGCOptions* options READ options CONSTANT) + Q_PROPERTY(QVariantList settings READ settings CONSTANT) + Q_PROPERTY(int defaultSettings READ defaultSettings CONSTANT) + Q_PROPERTY(QGCOptions* options READ options CONSTANT) + Q_PROPERTY(QVariantList toolBarIndicators READ toolBarIndicators CONSTANT) - //! The list of settings under the Settings Menu - /*! - @return A list of QGCSettings - */ - virtual QVariantList& settings (); + /// The list of settings under the Settings Menu + /// @return A list of QGCSettings + virtual QVariantList& settings (); - //! The default settings panel to show - /*! - @return The settings index - */ - virtual int defaltSettings (); + /// Allows the core plugin to override the toolbar indicators + /// @return A list of QUrl with the indicators (see MainToolBarIndicators.qml) + virtual QVariantList& toolBarIndicators (); - //! Global options - /*! - @return An instance of QGCOptions - */ - virtual QGCOptions* options (); + /// The default settings panel to show + /// @return The settings index + virtual int defaultSettings (); + + /// Global options + /// @return An instance of QGCOptions + virtual QGCOptions* options (); /// Allows the core plugin to override the default value for the specified setting /// @param name - Setting name /// @param defaultValue - Standard default value for setting /// @return New default value for setting, if no override just return passed in defaultValue - virtual QVariant overrideSettingsDefault(QString name, QVariant defaultValue); + virtual QVariant overrideSettingsDefault (QString name, QVariant defaultValue); // Override from QGCTool - void setToolbox (QGCToolbox *toolbox); + void setToolbox (QGCToolbox *toolbox); private: QGCCorePlugin_p* _p; }; diff --git a/src/ui/AppSettings.qml b/src/ui/AppSettings.qml index 5599e025287adad2a717c455bf23b0e9b602d03e..4b161474d03682ed13867078311e623f3d946b32 100644 --- a/src/ui/AppSettings.qml +++ b/src/ui/AppSettings.qml @@ -36,7 +36,7 @@ Rectangle { Component.onCompleted: { //-- Default Settings - __rightPanel.source = QGroundControl.corePlugin.settings[QGroundControl.corePlugin.defaltSettings].url + __rightPanel.source = QGroundControl.corePlugin.settings[QGroundControl.corePlugin.defaultSettings].url } QGCFlickable { diff --git a/src/ui/toolbar/BatteryIndicator.qml b/src/ui/toolbar/BatteryIndicator.qml new file mode 100644 index 0000000000000000000000000000000000000000..344c7714a0559fd888c5df48bbf1db8cbfc43354 --- /dev/null +++ b/src/ui/toolbar/BatteryIndicator.qml @@ -0,0 +1,129 @@ +/**************************************************************************** + * + * (c) 2009-2016 QGROUNDCONTROL PROJECT + * + * QGroundControl is licensed according to the terms in the file + * COPYING.md in the root of the source code directory. + * + ****************************************************************************/ + + +import QtQuick 2.5 +import QtQuick.Controls 1.2 +import QtQuick.Layouts 1.2 + +import QGroundControl 1.0 +import QGroundControl.Controls 1.0 +import QGroundControl.MultiVehicleManager 1.0 +import QGroundControl.ScreenTools 1.0 +import QGroundControl.Palette 1.0 + +//------------------------------------------------------------------------- +//-- Battery Indicator +Item { + anchors.top: parent.top + anchors.bottom: parent.bottom + width: batteryIndicatorRow.width + + function getBatteryColor() { + if(activeVehicle) { + if(activeVehicle.battery.percentRemaining.value > 75) { + return qgcPal.text + } + if(activeVehicle.battery.percentRemaining.value > 50) { + return colorOrange + } + if(activeVehicle.battery.percentRemaining.value > 0.1) { + return colorRed + } + } + return colorGrey + } + + function getBatteryPercentageText() { + 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.voltage.value >= 0) { + return activeVehicle.battery.voltage.valueString + activeVehicle.battery.voltage.units + } + } + return "N/A" + } + + Component { + id: batteryInfo + + Rectangle { + width: battCol.width + ScreenTools.defaultFontPixelWidth * 3 + height: battCol.height + ScreenTools.defaultFontPixelHeight * 2 + radius: ScreenTools.defaultFontPixelHeight * 0.5 + color: qgcPal.window + border.color: qgcPal.text + + Column { + id: battCol + spacing: ScreenTools.defaultFontPixelHeight * 0.5 + width: Math.max(battGrid.width, battLabel.width) + anchors.margins: ScreenTools.defaultFontPixelHeight + anchors.centerIn: parent + + QGCLabel { + id: battLabel + text: qsTr("Battery Status") + font.family: ScreenTools.demiboldFontFamily + anchors.horizontalCenter: parent.horizontalCenter + } + + GridLayout { + id: battGrid + anchors.margins: ScreenTools.defaultFontPixelHeight + columnSpacing: ScreenTools.defaultFontPixelWidth + columns: 2 + 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: qsTr("Accumulated Consumption:") } + QGCLabel { text: (activeVehicle && activeVehicle.battery.mahConsumed.value != -1) ? (activeVehicle.battery.mahConsumed.valueString + " " + activeVehicle.battery.mahConsumed.units) : "N/A" } + } + } + + Component.onCompleted: { + var pos = mapFromItem(toolBar, centerX - (width / 2), toolBar.height) + x = pos.x + y = pos.y + ScreenTools.defaultFontPixelHeight + } + } + } + + Row { + id: batteryIndicatorRow + anchors.top: parent.top + anchors.bottom: parent.bottom + opacity: (activeVehicle && activeVehicle.battery.voltage.value >= 0) ? 1 : 0.5 + QGCColoredImage { + anchors.top: parent.top + anchors.bottom: parent.bottom + width: height + sourceSize.width: width + source: "/qmlimages/Battery.svg" + fillMode: Image.PreserveAspectFit + color: qgcPal.text + } + QGCLabel { + text: getBatteryPercentageText() + font.pointSize: ScreenTools.mediumFontPointSize + color: getBatteryColor() + anchors.verticalCenter: parent.verticalCenter + } + } + MouseArea { + anchors.fill: parent + onClicked: mainWindow.showPopUp(batteryInfo, mapToItem(toolBar, x, y).x + (width / 2)) + } +} diff --git a/src/ui/toolbar/GPS.qml b/src/ui/toolbar/GPS.qml deleted file mode 100644 index af0001d8476e6b11bc3cf2b6f3247249bad01319..0000000000000000000000000000000000000000 --- a/src/ui/toolbar/GPS.qml +++ /dev/null @@ -1,34 +0,0 @@ -/**************************************************************************** - * - * (c) 2009-2016 QGROUNDCONTROL PROJECT - * - * QGroundControl is licensed according to the terms in the file - * COPYING.md in the root of the source code directory. - * - ****************************************************************************/ - - -/** - * @file - * @brief QGC Main Tool GPS - * @author Gus Grubba - */ - -import QtQuick 2.4 -import QGroundControl.Controls 1.0 - -Item { - id: gpsRoot - property real size: 50 - property real percent: 0 - width: size - height: size - Image { - source: "/qmlimages/Gps.svg" - fillMode: Image.PreserveAspectFit - mipmap: true - smooth: true - anchors.fill: parent - opacity: (percent + 25) * 0.8 - } -} diff --git a/src/ui/toolbar/GPSIndicator.qml b/src/ui/toolbar/GPSIndicator.qml new file mode 100644 index 0000000000000000000000000000000000000000..d73479069f19b09b5d551d35cea5b56e3e06f9e2 --- /dev/null +++ b/src/ui/toolbar/GPSIndicator.qml @@ -0,0 +1,122 @@ +/**************************************************************************** + * + * (c) 2009-2016 QGROUNDCONTROL PROJECT + * + * QGroundControl is licensed according to the terms in the file + * COPYING.md in the root of the source code directory. + * + ****************************************************************************/ + + +import QtQuick 2.5 +import QtQuick.Controls 1.2 +import QtQuick.Layouts 1.2 + +import QGroundControl 1.0 +import QGroundControl.Controls 1.0 +import QGroundControl.MultiVehicleManager 1.0 +import QGroundControl.ScreenTools 1.0 +import QGroundControl.Palette 1.0 + +//------------------------------------------------------------------------- +//-- GPS Indicator +Item { + id: satelitte + width: (gpsValuesColumn.x + gpsValuesColumn.width) * 1.1 + anchors.top: parent.top + anchors.bottom: parent.bottom + + Component { + id: gpsInfo + + Rectangle { + width: gpsCol.width + ScreenTools.defaultFontPixelWidth * 3 + height: gpsCol.height + ScreenTools.defaultFontPixelHeight * 2 + radius: ScreenTools.defaultFontPixelHeight * 0.5 + color: qgcPal.window + border.color: qgcPal.text + + Column { + id: gpsCol + spacing: ScreenTools.defaultFontPixelHeight * 0.5 + width: Math.max(gpsGrid.width, gpsLabel.width) + anchors.margins: ScreenTools.defaultFontPixelHeight + anchors.centerIn: parent + + QGCLabel { + id: gpsLabel + text: (activeVehicle && activeVehicle.gps.count.value >= 0) ? qsTr("GPS Status") : qsTr("GPS Data Unavailable") + font.family: ScreenTools.demiboldFontFamily + anchors.horizontalCenter: parent.horizontalCenter + } + + GridLayout { + id: gpsGrid + visible: (activeVehicle && activeVehicle.gps.count.value >= 0) + anchors.margins: ScreenTools.defaultFontPixelHeight + columnSpacing: ScreenTools.defaultFontPixelWidth + anchors.horizontalCenter: parent.horizontalCenter + columns: 2 + + QGCLabel { text: qsTr("GPS Count:") } + QGCLabel { text: activeVehicle ? activeVehicle.gps.count.valueString : qsTr("N/A", "No data to display") } + QGCLabel { text: qsTr("GPS Lock:") } + QGCLabel { text: activeVehicle ? activeVehicle.gps.lock.enumStringValue : qsTr("N/A", "No data to display") } + QGCLabel { text: qsTr("HDOP:") } + QGCLabel { text: activeVehicle ? activeVehicle.gps.hdop.valueString : qsTr("--.--", "No data to display") } + QGCLabel { text: qsTr("VDOP:") } + QGCLabel { text: activeVehicle ? activeVehicle.gps.vdop.valueString : qsTr("--.--", "No data to display") } + QGCLabel { text: qsTr("Course Over Ground:") } + QGCLabel { text: activeVehicle ? activeVehicle.gps.courseOverGround.valueString : qsTr("--.--", "No data to display") } + } + } + + Component.onCompleted: { + var pos = mapFromItem(toolBar, centerX - (width / 2), toolBar.height) + x = pos.x + y = pos.y + ScreenTools.defaultFontPixelHeight + } + } + } + + QGCColoredImage { + id: gpsIcon + width: height + anchors.top: parent.top + anchors.bottom: parent.bottom + source: "/qmlimages/Gps.svg" + fillMode: Image.PreserveAspectFit + sourceSize.height: height + opacity: (activeVehicle && activeVehicle.gps.count.value >= 0) ? 1 : 0.5 + color: qgcPal.buttonText + } + + Column { + id: gpsValuesColumn + anchors.verticalCenter: parent.verticalCenter + anchors.leftMargin: ScreenTools.defaultFontPixelWidth / 2 + anchors.left: gpsIcon.right + + QGCLabel { + anchors.horizontalCenter: hdopValue.horizontalCenter + visible: activeVehicle && !isNaN(activeVehicle.gps.hdop.value) + color: qgcPal.buttonText + text: activeVehicle ? activeVehicle.gps.count.valueString : "" + } + + QGCLabel { + id: hdopValue + visible: activeVehicle && !isNaN(activeVehicle.gps.hdop.value) + color: qgcPal.buttonText + text: activeVehicle ? activeVehicle.gps.hdop.value.toFixed(1) : "" + } + } + + MouseArea { + anchors.fill: parent + onClicked: { + var centerX = mapToItem(toolBar, x, y).x + (width / 2) + mainWindow.showPopUp(gpsInfo, centerX) + } + } +} diff --git a/src/ui/toolbar/MainToolBarIndicators.qml b/src/ui/toolbar/MainToolBarIndicators.qml index 9a0d30b57bf83dad6dfd70a6f45abe67e779be87..16caea17a6076389c8bb0545ee92a245a8e8df01 100644 --- a/src/ui/toolbar/MainToolBarIndicators.qml +++ b/src/ui/toolbar/MainToolBarIndicators.qml @@ -19,551 +19,48 @@ import QGroundControl.ScreenTools 1.0 import QGroundControl.Palette 1.0 Item { - property var _activeVehicle: QGroundControl.multiVehicleManager.activeVehicle - property bool _communicationLost: _activeVehicle ? _activeVehicle.connectionLost : false + property var activeVehicle: QGroundControl.multiVehicleManager.activeVehicle + property bool communicationLost: activeVehicle ? activeVehicle.connectionLost : false QGCPalette { id: qgcPal } - function getBatteryColor() { - if(_activeVehicle) { - if(_activeVehicle.battery.percentRemaining.value > 75) { - return qgcPal.text - } - if(_activeVehicle.battery.percentRemaining.value > 50) { - return colorOrange - } - if(_activeVehicle.battery.percentRemaining.value > 0.1) { - return colorRed - } - } - return colorGrey - } - - function getRSSIColor(value) { - if(value >= 0) - return colorGrey; - if(value > -60) - return colorGreen; - if(value > -90) - return colorOrange; - return colorRed; - } - - function getMessageColor() { - if (_activeVehicle) { - if (_activeVehicle.messageTypeNone) - return colorGrey - if (_activeVehicle.messageTypeNormal) - return colorBlue; - if (_activeVehicle.messageTypeWarning) - return colorOrange; - if (_activeVehicle.messageTypeError) - return colorRed; - // Cannot be so make make it obnoxious to show error - console.log("Invalid vehicle message type") - return "purple"; - } - //-- It can only get here when closing (vehicle gone while window active) - return "white"; - } - - function getBatteryVoltageText() { - if (_activeVehicle.battery.voltage.value >= 0) { - return _activeVehicle.battery.voltage.valueString + _activeVehicle.battery.voltage.units - } - return 'N/A'; - } - - function getBatteryPercentageText() { - 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.voltage.value >= 0) { - return _activeVehicle.battery.voltage.valueString + _activeVehicle.battery.voltage.units - } - } - return "N/A" - } - - //--------------------------------------------- - // GPS Info - Component { - id: gpsInfo - - Rectangle { - width: gpsCol.width + ScreenTools.defaultFontPixelWidth * 3 - height: gpsCol.height + ScreenTools.defaultFontPixelHeight * 2 - radius: ScreenTools.defaultFontPixelHeight * 0.5 - color: qgcPal.window - border.color: qgcPal.text - - Column { - id: gpsCol - spacing: ScreenTools.defaultFontPixelHeight * 0.5 - width: Math.max(gpsGrid.width, gpsLabel.width) - anchors.margins: ScreenTools.defaultFontPixelHeight - anchors.centerIn: parent - - QGCLabel { - id: gpsLabel - text: (_activeVehicle && _activeVehicle.gps.count.value >= 0) ? qsTr("GPS Status") : qsTr("GPS Data Unavailable") - font.family: ScreenTools.demiboldFontFamily - anchors.horizontalCenter: parent.horizontalCenter - } - - GridLayout { - id: gpsGrid - visible: (_activeVehicle && _activeVehicle.gps.count.value >= 0) - anchors.margins: ScreenTools.defaultFontPixelHeight - columnSpacing: ScreenTools.defaultFontPixelWidth - anchors.horizontalCenter: parent.horizontalCenter - columns: 2 - - QGCLabel { text: qsTr("GPS Count:") } - QGCLabel { text: _activeVehicle ? _activeVehicle.gps.count.valueString : qsTr("N/A", "No data to display") } - QGCLabel { text: qsTr("GPS Lock:") } - QGCLabel { text: _activeVehicle ? _activeVehicle.gps.lock.enumStringValue : qsTr("N/A", "No data to display") } - QGCLabel { text: qsTr("HDOP:") } - QGCLabel { text: _activeVehicle ? _activeVehicle.gps.hdop.valueString : qsTr("--.--", "No data to display") } - QGCLabel { text: qsTr("VDOP:") } - QGCLabel { text: _activeVehicle ? _activeVehicle.gps.vdop.valueString : qsTr("--.--", "No data to display") } - QGCLabel { text: qsTr("Course Over Ground:") } - QGCLabel { text: _activeVehicle ? _activeVehicle.gps.courseOverGround.valueString : qsTr("--.--", "No data to display") } - } - } - - Component.onCompleted: { - var pos = mapFromItem(toolBar, centerX - (width / 2), toolBar.height) - x = pos.x - y = pos.y + ScreenTools.defaultFontPixelHeight - } - } - } - - //--------------------------------------------- - // Battery Info - Component { - id: batteryInfo - - Rectangle { - width: battCol.width + ScreenTools.defaultFontPixelWidth * 3 - height: battCol.height + ScreenTools.defaultFontPixelHeight * 2 - radius: ScreenTools.defaultFontPixelHeight * 0.5 - color: qgcPal.window - border.color: qgcPal.text - - Column { - id: battCol - spacing: ScreenTools.defaultFontPixelHeight * 0.5 - width: Math.max(battGrid.width, battLabel.width) - anchors.margins: ScreenTools.defaultFontPixelHeight - anchors.centerIn: parent - - QGCLabel { - id: battLabel - text: qsTr("Battery Status") - font.family: ScreenTools.demiboldFontFamily - anchors.horizontalCenter: parent.horizontalCenter - } - - GridLayout { - id: battGrid - anchors.margins: ScreenTools.defaultFontPixelHeight - columnSpacing: ScreenTools.defaultFontPixelWidth - columns: 2 - 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: qsTr("Accumulated Consumption:") } - QGCLabel { text: (_activeVehicle && _activeVehicle.battery.mahConsumed.value != -1) ? (_activeVehicle.battery.mahConsumed.valueString + " " + _activeVehicle.battery.mahConsumed.units) : "N/A" } - } - } - - Component.onCompleted: { - var pos = mapFromItem(toolBar, centerX - (width / 2), toolBar.height) - x = pos.x - y = pos.y + ScreenTools.defaultFontPixelHeight - } - } - } - - //--------------------------------------------- - // RC RSSI Info - Component { - id: rcRSSIInfo - - Rectangle { - width: rcrssiCol.width + ScreenTools.defaultFontPixelWidth * 3 - height: rcrssiCol.height + ScreenTools.defaultFontPixelHeight * 2 - radius: ScreenTools.defaultFontPixelHeight * 0.5 - color: qgcPal.window - border.color: qgcPal.text - - Column { - id: rcrssiCol - spacing: ScreenTools.defaultFontPixelHeight * 0.5 - width: Math.max(rcrssiGrid.width, rssiLabel.width) - anchors.margins: ScreenTools.defaultFontPixelHeight - anchors.centerIn: parent - - QGCLabel { - id: rssiLabel - 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 - anchors.margins: ScreenTools.defaultFontPixelHeight - columnSpacing: ScreenTools.defaultFontPixelWidth - columns: 2 - anchors.horizontalCenter: parent.horizontalCenter - - QGCLabel { text: qsTr("RSSI:") } - QGCLabel { text: _activeVehicle ? (_activeVehicle.rcRSSI + "%") : 0 } - } - } - - Component.onCompleted: { - var pos = mapFromItem(toolBar, centerX - (width / 2), toolBar.height) - x = pos.x - y = pos.y + ScreenTools.defaultFontPixelHeight - } - } - } - - //--------------------------------------------- - // Telemetry RSSI Info - Component { - id: telemRSSIInfo - - Rectangle { - width: telemCol.width + ScreenTools.defaultFontPixelWidth * 3 - height: telemCol.height + ScreenTools.defaultFontPixelHeight * 2 - radius: ScreenTools.defaultFontPixelHeight * 0.5 - color: qgcPal.window - border.color: qgcPal.text - - Column { - id: telemCol - spacing: ScreenTools.defaultFontPixelHeight * 0.5 - width: Math.max(telemGrid.width, telemLabel.width) - anchors.margins: ScreenTools.defaultFontPixelHeight - anchors.centerIn: parent - - QGCLabel { - id: telemLabel - text: qsTr("Telemetry RSSI Status") - font.family: ScreenTools.demiboldFontFamily - anchors.horizontalCenter: parent.horizontalCenter - } - - GridLayout { - id: telemGrid - anchors.margins: ScreenTools.defaultFontPixelHeight - columnSpacing: ScreenTools.defaultFontPixelWidth - columns: 2 - anchors.horizontalCenter: parent.horizontalCenter - - QGCLabel { text: qsTr("Local RSSI:") } - QGCLabel { text: _activeVehicle.telemetryLRSSI + " dBm" } - QGCLabel { text: qsTr("Remote RSSI:") } - QGCLabel { text: _activeVehicle.telemetryRRSSI + " dBm" } - QGCLabel { text: qsTr("RX Errors:") } - QGCLabel { text: _activeVehicle.telemetryRXErrors } - QGCLabel { text: qsTr("Errors Fixed:") } - QGCLabel { text: _activeVehicle.telemetryFixed } - QGCLabel { text: qsTr("TX Buffer:") } - QGCLabel { text: _activeVehicle.telemetryTXBuffer } - QGCLabel { text: qsTr("Local Noise:") } - QGCLabel { text: _activeVehicle.telemetryLNoise } - QGCLabel { text: qsTr("Remote Noise:") } - QGCLabel { text: _activeVehicle.telemetryRNoise } - } - } - - Component.onCompleted: { - var pos = mapFromItem(toolBar, centerX - (width / 2), toolBar.height) - x = pos.x - y = pos.y + ScreenTools.defaultFontPixelHeight - } - } - } - Row { id: indicatorRow anchors.top: parent.top anchors.bottom: parent.bottom spacing: ScreenTools.defaultFontPixelWidth * 1.5 - visible: !_communicationLost - - //------------------------------------------------------------------------- - //-- Message Indicator - Item { - id: messages - width: height - anchors.top: parent.top - anchors.bottom: parent.bottom - visible: _activeVehicle && _activeVehicle.messageCount - - Image { - id: criticalMessageIcon - anchors.fill: parent - source: "/qmlimages/Yield.svg" - sourceSize.height: height - fillMode: Image.PreserveAspectFit - cache: false - visible: _activeVehicle && _activeVehicle.messageCount > 0 && isMessageImportant - } - - QGCColoredImage { - anchors.fill: parent - source: "/qmlimages/Megaphone.svg" - sourceSize.height: height - fillMode: Image.PreserveAspectFit - color: getMessageColor() - visible: !criticalMessageIcon.visible - } - - MouseArea { - anchors.fill: parent - onClicked: mainWindow.showMessageArea() - } - } - - //------------------------------------------------------------------------- - //-- GPS Indicator - Item { - id: satelitte - width: (gpsValuesColumn.x + gpsValuesColumn.width) * 1.1 - anchors.top: parent.top - anchors.bottom: parent.bottom - - QGCColoredImage { - id: gpsIcon - width: height - anchors.top: parent.top - anchors.bottom: parent.bottom - source: "/qmlimages/Gps.svg" - fillMode: Image.PreserveAspectFit - sourceSize.height: height - opacity: (_activeVehicle && _activeVehicle.gps.count.value >= 0) ? 1 : 0.5 - color: qgcPal.buttonText - } - - Column { - id: gpsValuesColumn - anchors.verticalCenter: parent.verticalCenter - anchors.leftMargin: ScreenTools.defaultFontPixelWidth / 2 - anchors.left: gpsIcon.right - - QGCLabel { - anchors.horizontalCenter: hdopValue.horizontalCenter - visible: _activeVehicle && !isNaN(_activeVehicle.gps.hdop.value) - color: qgcPal.buttonText - text: _activeVehicle ? _activeVehicle.gps.count.valueString : "" - } - - QGCLabel { - id: hdopValue - visible: _activeVehicle && !isNaN(_activeVehicle.gps.hdop.value) - color: qgcPal.buttonText - text: _activeVehicle ? _activeVehicle.gps.hdop.value.toFixed(1) : "" - } - } // Column - - MouseArea { - anchors.fill: parent - onClicked: { - var centerX = mapToItem(toolBar, x, y).x + (width / 2) - mainWindow.showPopUp(gpsInfo, centerX) - } - } - } - - //------------------------------------------------------------------------- - //-- RC RSSI - Item { - id: rcRssi - width: rssiRow.width * 1.1 - anchors.top: parent.top - anchors.bottom: parent.bottom - visible: _activeVehicle ? _activeVehicle.supportsRadio : true - - Row { - id: rssiRow - anchors.top: parent.top - anchors.bottom: parent.bottom - spacing: ScreenTools.defaultFontPixelWidth - - QGCColoredImage { - width: height - anchors.top: parent.top - anchors.bottom: parent.bottom - sourceSize.height: height - source: "/qmlimages/RC.svg" - fillMode: Image.PreserveAspectFit - 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 - } - } - - MouseArea { - anchors.fill: parent - - onClicked: { - var centerX = mapToItem(toolBar, x, y).x + (width / 2) - mainWindow.showPopUp(rcRSSIInfo, centerX) - } - } - } - - //------------------------------------------------------------------------- - //-- Telemetry RSSI - QGCColoredImage { - anchors.top: parent.top - anchors.bottom: parent.bottom - sourceSize.height: height - source: "/qmlimages/TelemRSSI.svg" - fillMode: Image.PreserveAspectFit - color: qgcPal.buttonText - visible: _activeVehicle ? (_activeVehicle.telemetryLRSSI < 0) : false - - MouseArea { - anchors.fill: parent - - onClicked: { - var centerX = mapToItem(toolBar, x, y).x + (width / 2) - mainWindow.showPopUp(telemRSSIInfo, centerX) - } - } - } - - //------------------------------------------------------------------------- - //-- Battery Indicator - Item { - anchors.top: parent.top - anchors.bottom: parent.bottom - width: batteryIndicatorRow.width - - Row { - id: batteryIndicatorRow + visible: !communicationLost + Repeater { + model: QGroundControl.corePlugin.toolBarIndicators + Loader { anchors.top: parent.top anchors.bottom: parent.bottom - opacity: (_activeVehicle && _activeVehicle.battery.voltage.value >= 0) ? 1 : 0.5 - - QGCColoredImage { - anchors.top: parent.top - anchors.bottom: parent.bottom - width: height - sourceSize.width: width - source: "/qmlimages/Battery.svg" - fillMode: Image.PreserveAspectFit - color: qgcPal.text - } - - QGCLabel { - text: getBatteryPercentageText() - font.pointSize: ScreenTools.mediumFontPointSize - color: getBatteryColor() - anchors.verticalCenter: parent.verticalCenter - } - } - - MouseArea { - anchors.fill: parent - onClicked: mainWindow.showPopUp(batteryInfo, mapToItem(toolBar, x, y).x + (width / 2)) + source: modelData; } } - - //------------------------------------------------------------------------- - //-- Mode Selector - QGCLabel { - id: flightModeSelector - text: _activeVehicle ? _activeVehicle.flightMode : qsTr("N/A", "No data to display") - font.pointSize: ScreenTools.mediumFontPointSize - color: qgcPal.buttonText - anchors.verticalCenter: parent.verticalCenter - - Menu { - id: flightModesMenu - } - - Component { - id: flightModeMenuItemComponent - - MenuItem { - onTriggered: _activeVehicle.flightMode = text - } - } - - property var flightModesMenuItems: [] - - function updateFlightModesMenu() { - 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] }) - flightModesMenuItems.push(menuItem) - flightModesMenu.insertItem(i, menuItem) - } - } - } - - Component.onCompleted: flightModeSelector.updateFlightModesMenu() - - Connections { - target: QGroundControl.multiVehicleManager - onActiveVehicleChanged: flightModeSelector.updateFlightModesMenu() - } - - MouseArea { - visible: _activeVehicle && _activeVehicle.flightModeSetAvailable - anchors.fill: parent - onClicked: flightModesMenu.popup() - } - } // QGCLabel - Flight mode selector - } // Row - Vehicle indicators + } Image { anchors.right: parent.right anchors.top: parent.top anchors.bottom: parent.bottom - visible: x > indicatorRow.width && !_communicationLost + visible: x > indicatorRow.width && !communicationLost fillMode: Image.PreserveAspectFit - source: _activeVehicle ? _activeVehicle.brandImage : "" + source: activeVehicle ? activeVehicle.brandImage : "" } Row { anchors.fill: parent layoutDirection: Qt.RightToLeft spacing: ScreenTools.defaultFontPixelWidth - visible: _communicationLost + visible: communicationLost QGCButton { id: disconnectButton anchors.verticalCenter: parent.verticalCenter text: qsTr("Disconnect") primary: true - onClicked: _activeVehicle.disconnectInactiveVehicle() + onClicked: activeVehicle.disconnectInactiveVehicle() } QGCLabel { @@ -574,5 +71,5 @@ Item { font.family: ScreenTools.demiboldFontFamily color: colorRed } - } // Row - Communication lost -} // Item + } +} diff --git a/src/ui/toolbar/MessageIndicator.qml b/src/ui/toolbar/MessageIndicator.qml new file mode 100644 index 0000000000000000000000000000000000000000..aecd246149bd9c15a55fb9d045b337e5c886327d --- /dev/null +++ b/src/ui/toolbar/MessageIndicator.qml @@ -0,0 +1,69 @@ +/**************************************************************************** + * + * (c) 2009-2016 QGROUNDCONTROL PROJECT + * + * QGroundControl is licensed according to the terms in the file + * COPYING.md in the root of the source code directory. + * + ****************************************************************************/ + + +import QtQuick 2.5 +import QtQuick.Controls 1.2 +import QtQuick.Layouts 1.2 + +import QGroundControl 1.0 +import QGroundControl.Controls 1.0 +import QGroundControl.MultiVehicleManager 1.0 +import QGroundControl.ScreenTools 1.0 +import QGroundControl.Palette 1.0 + +//------------------------------------------------------------------------- +//-- GPS Indicator +Item { + width: height + anchors.top: parent.top + anchors.bottom: parent.bottom + + function getMessageColor() { + if (activeVehicle) { + if (activeVehicle.messageTypeNone) + return colorGrey + if (activeVehicle.messageTypeNormal) + return colorBlue; + if (activeVehicle.messageTypeWarning) + return colorOrange; + if (activeVehicle.messageTypeError) + return colorRed; + // Cannot be so make make it obnoxious to show error + console.log("Invalid vehicle message type") + return "purple"; + } + //-- It can only get here when closing (vehicle gone while window active) + return "white"; + } + + Image { + id: criticalMessageIcon + anchors.fill: parent + source: "/qmlimages/Yield.svg" + sourceSize.height: height + fillMode: Image.PreserveAspectFit + cache: false + visible: activeVehicle && activeVehicle.messageCount > 0 && isMessageImportant + } + + QGCColoredImage { + anchors.fill: parent + source: "/qmlimages/Megaphone.svg" + sourceSize.height: height + fillMode: Image.PreserveAspectFit + color: getMessageColor() + visible: !criticalMessageIcon.visible + } + + MouseArea { + anchors.fill: parent + onClicked: mainWindow.showMessageArea() + } +} diff --git a/src/ui/toolbar/ModeIndicator.qml b/src/ui/toolbar/ModeIndicator.qml new file mode 100644 index 0000000000000000000000000000000000000000..2d8ba75259bfabbe1ed4493e54846963f4392880 --- /dev/null +++ b/src/ui/toolbar/ModeIndicator.qml @@ -0,0 +1,63 @@ +/**************************************************************************** + * + * (c) 2009-2016 QGROUNDCONTROL PROJECT + * + * QGroundControl is licensed according to the terms in the file + * COPYING.md in the root of the source code directory. + * + ****************************************************************************/ + + +import QtQuick 2.5 +import QtQuick.Controls 1.2 + +import QGroundControl 1.0 +import QGroundControl.Controls 1.0 +import QGroundControl.MultiVehicleManager 1.0 +import QGroundControl.ScreenTools 1.0 +import QGroundControl.Palette 1.0 + +//------------------------------------------------------------------------- +//-- Mode Indicator +QGCLabel { + id: flightModeSelector + text: activeVehicle ? activeVehicle.flightMode : qsTr("N/A", "No data to display") + font.pointSize: ScreenTools.mediumFontPointSize + color: qgcPal.buttonText + anchors.verticalCenter: parent.verticalCenter + Menu { + id: flightModesMenu + } + Component { + id: flightModeMenuItemComponent + MenuItem { + onTriggered: activeVehicle.flightMode = text + } + } + property var flightModesMenuItems: [] + function updateFlightModesMenu() { + 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] }) + flightModesMenuItems.push(menuItem) + flightModesMenu.insertItem(i, menuItem) + } + } + } + Component.onCompleted: flightModeSelector.updateFlightModesMenu() + Connections { + target: QGroundControl.multiVehicleManager + onActiveVehicleChanged: flightModeSelector.updateFlightModesMenu() + } + MouseArea { + visible: activeVehicle && activeVehicle.flightModeSetAvailable + anchors.fill: parent + onClicked: flightModesMenu.popup() + } +} diff --git a/src/ui/toolbar/RCRSSIIndicator.qml b/src/ui/toolbar/RCRSSIIndicator.qml new file mode 100644 index 0000000000000000000000000000000000000000..64471abf26ff99419c40a60c34b1e6c744e46412 --- /dev/null +++ b/src/ui/toolbar/RCRSSIIndicator.qml @@ -0,0 +1,105 @@ +/**************************************************************************** + * + * (c) 2009-2016 QGROUNDCONTROL PROJECT + * + * QGroundControl is licensed according to the terms in the file + * COPYING.md in the root of the source code directory. + * + ****************************************************************************/ + + +import QtQuick 2.5 +import QtQuick.Controls 1.2 +import QtQuick.Layouts 1.2 + +import QGroundControl 1.0 +import QGroundControl.Controls 1.0 +import QGroundControl.MultiVehicleManager 1.0 +import QGroundControl.ScreenTools 1.0 +import QGroundControl.Palette 1.0 + +//------------------------------------------------------------------------- +//-- GPS Indicator +Item { + width: rssiRow.width * 1.1 + anchors.top: parent.top + anchors.bottom: parent.bottom + visible: activeVehicle ? activeVehicle.supportsRadio : true + + Component { + id: rcRSSIInfo + + Rectangle { + width: rcrssiCol.width + ScreenTools.defaultFontPixelWidth * 3 + height: rcrssiCol.height + ScreenTools.defaultFontPixelHeight * 2 + radius: ScreenTools.defaultFontPixelHeight * 0.5 + color: qgcPal.window + border.color: qgcPal.text + + Column { + id: rcrssiCol + spacing: ScreenTools.defaultFontPixelHeight * 0.5 + width: Math.max(rcrssiGrid.width, rssiLabel.width) + anchors.margins: ScreenTools.defaultFontPixelHeight + anchors.centerIn: parent + + QGCLabel { + id: rssiLabel + 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 + anchors.margins: ScreenTools.defaultFontPixelHeight + columnSpacing: ScreenTools.defaultFontPixelWidth + columns: 2 + anchors.horizontalCenter: parent.horizontalCenter + + QGCLabel { text: qsTr("RSSI:") } + QGCLabel { text: activeVehicle ? (activeVehicle.rcRSSI + "%") : 0 } + } + } + + Component.onCompleted: { + var pos = mapFromItem(toolBar, centerX - (width / 2), toolBar.height) + x = pos.x + y = pos.y + ScreenTools.defaultFontPixelHeight + } + } + } + + Row { + id: rssiRow + anchors.top: parent.top + anchors.bottom: parent.bottom + spacing: ScreenTools.defaultFontPixelWidth + + QGCColoredImage { + width: height + anchors.top: parent.top + anchors.bottom: parent.bottom + sourceSize.height: height + source: "/qmlimages/RC.svg" + fillMode: Image.PreserveAspectFit + 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 + } + } + + MouseArea { + anchors.fill: parent + onClicked: { + var centerX = mapToItem(toolBar, x, y).x + (width / 2) + mainWindow.showPopUp(rcRSSIInfo, centerX) + } + } +} diff --git a/src/ui/toolbar/TelemetryRSSIIndicator.qml b/src/ui/toolbar/TelemetryRSSIIndicator.qml new file mode 100644 index 0000000000000000000000000000000000000000..145fa6519c3165c73c8a7a14941842c28506363b --- /dev/null +++ b/src/ui/toolbar/TelemetryRSSIIndicator.qml @@ -0,0 +1,87 @@ +/**************************************************************************** + * + * (c) 2009-2016 QGROUNDCONTROL PROJECT + * + * QGroundControl is licensed according to the terms in the file + * COPYING.md in the root of the source code directory. + * + ****************************************************************************/ + + +import QtQuick 2.5 +import QtQuick.Controls 1.2 +import QtQuick.Layouts 1.2 + +import QGroundControl 1.0 +import QGroundControl.Controls 1.0 +import QGroundControl.MultiVehicleManager 1.0 +import QGroundControl.ScreenTools 1.0 +import QGroundControl.Palette 1.0 + +//------------------------------------------------------------------------- +//-- Telemetry RSSI +QGCColoredImage { + anchors.top: parent.top + anchors.bottom: parent.bottom + sourceSize.height: height + source: "/qmlimages/TelemRSSI.svg" + fillMode: Image.PreserveAspectFit + color: qgcPal.buttonText + visible: activeVehicle ? (activeVehicle.telemetryLRSSI < 0) : false + Component { + id: telemRSSIInfo + Rectangle { + width: telemCol.width + ScreenTools.defaultFontPixelWidth * 3 + height: telemCol.height + ScreenTools.defaultFontPixelHeight * 2 + radius: ScreenTools.defaultFontPixelHeight * 0.5 + color: qgcPal.window + border.color: qgcPal.text + Column { + id: telemCol + spacing: ScreenTools.defaultFontPixelHeight * 0.5 + width: Math.max(telemGrid.width, telemLabel.width) + anchors.margins: ScreenTools.defaultFontPixelHeight + anchors.centerIn: parent + QGCLabel { + id: telemLabel + text: qsTr("Telemetry RSSI Status") + font.family: ScreenTools.demiboldFontFamily + anchors.horizontalCenter: parent.horizontalCenter + } + GridLayout { + id: telemGrid + anchors.margins: ScreenTools.defaultFontPixelHeight + columnSpacing: ScreenTools.defaultFontPixelWidth + columns: 2 + anchors.horizontalCenter: parent.horizontalCenter + QGCLabel { text: qsTr("Local RSSI:") } + QGCLabel { text: activeVehicle.telemetryLRSSI + " dBm" } + QGCLabel { text: qsTr("Remote RSSI:") } + QGCLabel { text: activeVehicle.telemetryRRSSI + " dBm" } + QGCLabel { text: qsTr("RX Errors:") } + QGCLabel { text: activeVehicle.telemetryRXErrors } + QGCLabel { text: qsTr("Errors Fixed:") } + QGCLabel { text: activeVehicle.telemetryFixed } + QGCLabel { text: qsTr("TX Buffer:") } + QGCLabel { text: activeVehicle.telemetryTXBuffer } + QGCLabel { text: qsTr("Local Noise:") } + QGCLabel { text: activeVehicle.telemetryLNoise } + QGCLabel { text: qsTr("Remote Noise:") } + QGCLabel { text: activeVehicle.telemetryRNoise } + } + } + Component.onCompleted: { + var pos = mapFromItem(toolBar, centerX - (width / 2), toolBar.height) + x = pos.x + y = pos.y + ScreenTools.defaultFontPixelHeight + } + } + } + MouseArea { + anchors.fill: parent + onClicked: { + var centerX = mapToItem(toolBar, x, y).x + (width / 2) + mainWindow.showPopUp(telemRSSIInfo, centerX) + } + } +}