From da8d8bb58137ca1bfc8c671c3c0d74a0fa36a818 Mon Sep 17 00:00:00 2001 From: dogmaphobic Date: Fri, 30 Oct 2015 15:54:00 -0400 Subject: [PATCH] Main Toolbar Work --- qgcresources.qrc | 26 +- qgroundcontrol.qrc | 5 +- resources/Gears.svg | 34 + resources/Gps.svg | 275 -------- resources/Megaphone.png | Bin 346 -> 0 bytes resources/PaperPlane.svg | 13 + resources/Plan.svg | 29 + resources/PowerButton.svg | 12 + resources/Yield.png | Bin 295 -> 0 bytes src/FirmwarePlugin/PX4/PX4FirmwarePlugin.cc | 64 +- src/FlightDisplay/FlightDisplayView.qml | 19 +- src/FlightDisplay/FlightDisplayViewVideo.qml | 2 +- .../FlightDisplayViewWidgets.qml | 5 +- src/MissionEditor/MissionEditor.qml | 2 +- src/QmlControls/QGCToolBarButton.qml | 51 +- .../QGroundControl.Controls.qmldir | 15 +- src/QmlControls/QGroundControlQmlGlobal.h | 6 + src/QmlControls/ScreenTools.qml | 7 +- src/VehicleSetup/SetupView.qml | 25 +- src/ui/MainWindow.qml | 45 +- src/ui/toolbar/GPS.qml | 47 ++ src/ui/toolbar/Images/AirplaneIcon.svg | 15 + src/ui/toolbar/Images/Armed.svg | 11 + src/ui/toolbar/Images/Battery.svg | 19 + src/ui/toolbar/Images/Connect.svg | 19 + src/ui/toolbar/Images/Disarmed.svg | 14 + src/ui/toolbar/Images/Disconnect.svg | 12 + src/ui/toolbar/Images/Gps.svg | 79 +++ src/ui/toolbar/Images/Megaphone.svg | 18 + src/ui/toolbar/Images/Quad.svg | 55 ++ src/ui/toolbar/Images/RC.svg | 75 +++ src/ui/toolbar/Images/Signal0.svg | 73 +++ src/ui/toolbar/Images/Signal100.svg | 72 +++ src/ui/toolbar/Images/Signal20.svg | 74 +++ src/ui/toolbar/Images/Signal40.svg | 74 +++ src/ui/toolbar/Images/Signal60.svg | 73 +++ src/ui/toolbar/Images/Signal80.svg | 73 +++ src/ui/toolbar/Images/Yield.svg | 17 + src/ui/toolbar/MainToolBar.qml | 610 ++++++++---------- .../MainToolBarActiveVehicleComponent.qml | 426 ------------ src/ui/toolbar/MainToolBarIndicators.qml | 557 ++++++++++++++++ src/ui/toolbar/SignalStrength.qml | 59 ++ 42 files changed, 1965 insertions(+), 1142 deletions(-) create mode 100644 resources/Gears.svg delete mode 100644 resources/Gps.svg delete mode 100644 resources/Megaphone.png create mode 100644 resources/PaperPlane.svg create mode 100644 resources/Plan.svg create mode 100644 resources/PowerButton.svg delete mode 100644 resources/Yield.png create mode 100644 src/ui/toolbar/GPS.qml create mode 100644 src/ui/toolbar/Images/AirplaneIcon.svg create mode 100644 src/ui/toolbar/Images/Armed.svg create mode 100644 src/ui/toolbar/Images/Battery.svg create mode 100644 src/ui/toolbar/Images/Connect.svg create mode 100644 src/ui/toolbar/Images/Disarmed.svg create mode 100644 src/ui/toolbar/Images/Disconnect.svg create mode 100644 src/ui/toolbar/Images/Gps.svg create mode 100644 src/ui/toolbar/Images/Megaphone.svg create mode 100644 src/ui/toolbar/Images/Quad.svg create mode 100644 src/ui/toolbar/Images/RC.svg create mode 100644 src/ui/toolbar/Images/Signal0.svg create mode 100644 src/ui/toolbar/Images/Signal100.svg create mode 100644 src/ui/toolbar/Images/Signal20.svg create mode 100644 src/ui/toolbar/Images/Signal40.svg create mode 100644 src/ui/toolbar/Images/Signal60.svg create mode 100644 src/ui/toolbar/Images/Signal80.svg create mode 100644 src/ui/toolbar/Images/Yield.svg delete mode 100644 src/ui/toolbar/MainToolBarActiveVehicleComponent.qml create mode 100644 src/ui/toolbar/MainToolBarIndicators.qml create mode 100644 src/ui/toolbar/SignalStrength.qml diff --git a/qgcresources.qrc b/qgcresources.qrc index d06de6ec2..f0886b88a 100644 --- a/qgcresources.qrc +++ b/qgcresources.qrc @@ -80,6 +80,25 @@ src/FlightMap/Images/XDelete.svg src/FlightMap/Images/XDeleteBlack.svg + + + src/ui/toolbar/Images/Armed.svg + src/ui/toolbar/Images/Battery.svg + src/ui/toolbar/Images/Connect.svg + src/ui/toolbar/Images/Disarmed.svg + src/ui/toolbar/Images/Disconnect.svg + src/ui/toolbar/Images/Gps.svg + src/ui/toolbar/Images/Megaphone.svg + src/ui/toolbar/Images/Quad.svg + src/ui/toolbar/Images/RC.svg + src/ui/toolbar/Images/Signal0.svg + src/ui/toolbar/Images/Signal20.svg + src/ui/toolbar/Images/Signal40.svg + src/ui/toolbar/Images/Signal60.svg + src/ui/toolbar/Images/Signal80.svg + src/ui/toolbar/Images/Signal100.svg + src/ui/toolbar/Images/Yield.svg + @@ -100,9 +119,6 @@ resources/Shutdown.svg resources/Antenna_T.svg resources/Antenna_RC.svg - resources/Gps.svg - resources/Megaphone.png - resources/Yield.png resources/Battery_0.svg resources/Battery_20.svg resources/Battery_40.svg @@ -112,6 +128,10 @@ resources/SystemLockScreen.svg resources/SplashScreen.png resources/QGroundControlConnect.svg + resources/Gears.svg + resources/Plan.svg + resources/PaperPlane.svg + resources/PowerButton.svg diff --git a/qgroundcontrol.qrc b/qgroundcontrol.qrc index 81ced86ff..6a423dbe2 100644 --- a/qgroundcontrol.qrc +++ b/qgroundcontrol.qrc @@ -51,8 +51,11 @@ src/ui/MainWindow.qml + + src/ui/toolbar/MainToolBar.qml - src/ui/toolbar/MainToolBarActiveVehicleComponent.qml + src/ui/toolbar/MainToolBarIndicators.qml + src/ui/toolbar/SignalStrength.qml src/VehicleSetup/SetupView.qml diff --git a/resources/Gears.svg b/resources/Gears.svg new file mode 100644 index 000000000..308898715 --- /dev/null +++ b/resources/Gears.svg @@ -0,0 +1,34 @@ + + + + + + + + + + diff --git a/resources/Gps.svg b/resources/Gps.svg deleted file mode 100644 index 72049357b..000000000 --- a/resources/Gps.svg +++ /dev/null @@ -1,275 +0,0 @@ - -GPSimage/svg+xmlGPSGus Grubba \ No newline at end of file diff --git a/resources/Megaphone.png b/resources/Megaphone.png deleted file mode 100644 index 6b401fcced14c241aed70c4a994b512bd86af40b..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 346 zcmeAS@N?(olHy`uVBq!ia0vp^fh5b$6dPj{_DGrUc-xwryba} z7C62R)7~^$EaUSwNezQtDrQW@7rGx@E$WKuPO@7rqh$IJBj2TcqIg(}&g_o%NERapLNX7T$HW zxmV{jw)H%_ZS>CazPeFiaP66Hkd093uXt0fZrp+3 pGcMb%uCw?cZXQ#<^}p%?hH3Yzo4;+9_zm + + + + + diff --git a/resources/Plan.svg b/resources/Plan.svg new file mode 100644 index 000000000..73d08fc1a --- /dev/null +++ b/resources/Plan.svg @@ -0,0 +1,29 @@ + + + + + + + + + + + + + + + + diff --git a/resources/PowerButton.svg b/resources/PowerButton.svg new file mode 100644 index 000000000..e53c97689 --- /dev/null +++ b/resources/PowerButton.svg @@ -0,0 +1,12 @@ + + + + + + diff --git a/resources/Yield.png b/resources/Yield.png deleted file mode 100644 index 5bf66c2e1caeb0cd312bb86410a8948e49b16d4a..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 295 zcmeAS@N?(olHy`uVBq!ia0vp^f5@FF%du6s*VS;r zF<-XMV~Z5b{{Gmr_+_9+m3-!p(}50Oa}t*(PMpp1w8C5M&*s+$!sb-D-@eiCVwLbk pr|*wn7l^Le|Kstxll~2i48~Qjg2lFIy#u - + This file is part of the QGROUNDCONTROL project - + QGROUNDCONTROL is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. - + QGROUNDCONTROL is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - + You should have received a copy of the GNU General Public License along with QGROUNDCONTROL. If not, see . - + ======================================================================*/ /// @file @@ -76,75 +76,75 @@ static const struct Modes2Name rgModes2Name[] = { { PX4_CUSTOM_MAIN_MODE_ACRO, 0, "Acro", true }, { PX4_CUSTOM_MAIN_MODE_STABILIZED, 0, "Stabilized", true }, { PX4_CUSTOM_MAIN_MODE_RATTITUDE, 0, "Rattitude", true }, - { PX4_CUSTOM_MAIN_MODE_ALTCTL, 0, "Altitude control", true }, - { PX4_CUSTOM_MAIN_MODE_POSCTL, 0, "Position control", true }, - { PX4_CUSTOM_MAIN_MODE_OFFBOARD, 0, "Offboard control", true }, - { PX4_CUSTOM_MAIN_MODE_AUTO, PX4_CUSTOM_SUB_MODE_AUTO_READY, "Auto ready", false }, - { PX4_CUSTOM_MAIN_MODE_AUTO, PX4_CUSTOM_SUB_MODE_AUTO_TAKEOFF, "Taking off", false }, + { PX4_CUSTOM_MAIN_MODE_ALTCTL, 0, "Altitude Control", true }, + { PX4_CUSTOM_MAIN_MODE_POSCTL, 0, "Position Control", true }, + { PX4_CUSTOM_MAIN_MODE_OFFBOARD, 0, "Offboard Control", true }, + { PX4_CUSTOM_MAIN_MODE_AUTO, PX4_CUSTOM_SUB_MODE_AUTO_READY, "Auto Ready", false }, + { PX4_CUSTOM_MAIN_MODE_AUTO, PX4_CUSTOM_SUB_MODE_AUTO_TAKEOFF, "Taking Off", false }, { PX4_CUSTOM_MAIN_MODE_AUTO, PX4_CUSTOM_SUB_MODE_AUTO_LOITER, "Loiter", true }, { PX4_CUSTOM_MAIN_MODE_AUTO, PX4_CUSTOM_SUB_MODE_AUTO_MISSION, "Mission", true }, - { PX4_CUSTOM_MAIN_MODE_AUTO, PX4_CUSTOM_SUB_MODE_AUTO_RTL, "Return to Land", true }, + { PX4_CUSTOM_MAIN_MODE_AUTO, PX4_CUSTOM_SUB_MODE_AUTO_RTL, "Return To Land", true }, { PX4_CUSTOM_MAIN_MODE_AUTO, PX4_CUSTOM_SUB_MODE_AUTO_LAND, "Landing", false }, }; PX4FirmwarePlugin::PX4FirmwarePlugin(void) { - + } QList PX4FirmwarePlugin::componentsForVehicle(AutoPilotPlugin* vehicle) { Q_UNUSED(vehicle); - + return QList(); } QStringList PX4FirmwarePlugin::flightModes(void) { QStringList flightModes; - + // FIXME: fixed-wing/multi-rotor differences? - + for (size_t i=0; icanBeSet) { flightModes += pModes2Name->name; } } - + return flightModes; } QString PX4FirmwarePlugin::flightMode(uint8_t base_mode, uint32_t custom_mode) { QString flightMode = "Unknown"; - + if (base_mode & MAV_MODE_FLAG_CUSTOM_MODE_ENABLED) { union px4_custom_mode px4_mode; px4_mode.data = custom_mode; - + // FIXME: fixed-wing/multi-rotor differences? bool found = false; for (size_t i=0; imain_mode == px4_mode.main_mode && pModes2Name->sub_mode == px4_mode.sub_mode) { flightMode = pModes2Name->name; found = true; break; } } - + if (!found) { qWarning() << "Unknown flight mode" << custom_mode; } } else { qWarning() << "PX4 Flight Stack flight mode without custom mode enabled?"; } - + return flightMode; } @@ -152,30 +152,30 @@ bool PX4FirmwarePlugin::setFlightMode(const QString& flightMode, uint8_t* base_m { *base_mode = 0; *custom_mode = 0; - + bool found = false; for (size_t i=0; iname, Qt::CaseInsensitive) == 0) { union px4_custom_mode px4_mode; px4_mode.data = 0; px4_mode.main_mode = pModes2Name->main_mode; px4_mode.sub_mode = pModes2Name->sub_mode; - + *base_mode = MAV_MODE_FLAG_CUSTOM_MODE_ENABLED; *custom_mode = px4_mode.data; - + found = true; break; } } - + if (!found) { qWarning() << "Unknown flight Mode" << flightMode; } - + return found; } @@ -187,7 +187,7 @@ int PX4FirmwarePlugin::manualControlReservedButtonCount(void) void PX4FirmwarePlugin::adjustMavlinkMessage(mavlink_message_t* message) { Q_UNUSED(message); - + // PX4 Flight Stack plugin does no message adjustment } @@ -199,7 +199,7 @@ bool PX4FirmwarePlugin::isCapable(FirmwareCapabilities capabilities) void PX4FirmwarePlugin::initializeVehicle(Vehicle* vehicle) { Q_UNUSED(vehicle); - + // PX4 Flight Stack doesn't need to do any extra work } diff --git a/src/FlightDisplay/FlightDisplayView.qml b/src/FlightDisplay/FlightDisplayView.qml index 7734fe120..caca9f4a2 100644 --- a/src/FlightDisplay/FlightDisplayView.qml +++ b/src/FlightDisplay/FlightDisplayView.qml @@ -43,7 +43,11 @@ Item { QGCPalette { id: qgcPal; colorGroupEnabled: enabled } - property var _activeVehicle: multiVehicleManager.activeVehicle + property real avaiableHeight: parent.height + + readonly property bool isBackgroundDark: _mainIsMap ? (_flightMap ? _flightMap.isSatelliteMap : true) : true + + property var _activeVehicle: multiVehicleManager.activeVehicle readonly property var _defaultVehicleCoordinate: QtPositioning.coordinate(37.803784, -122.462276) readonly property real _defaultRoll: 0 @@ -73,9 +77,6 @@ Item { property real _airSpeed: _activeVehicle ? _activeVehicle.airSpeed : _defaultAirSpeed property real _climbRate: _activeVehicle ? _activeVehicle.climbRate : _defaultClimbRate - property bool _isBackgroundDark: _mainIsMap ? (_flightMap ? _flightMap.isSatelliteMap : true) : true - - property var _flightMap: null property var _flightVideo: null property var _savedZoomLevel: 0 @@ -135,7 +136,7 @@ Item { width: _pipSize height: _pipSize * (9/16) color: "#000010" - border.color: _isBackgroundDark ? Qt.rgba(1,1,1,0.75) : Qt.rgba(0,0,0,0.75) + border.color: isBackgroundDark ? Qt.rgba(1,1,1,0.75) : Qt.rgba(0,0,0,0.75) Loader { id: pipLoader anchors.fill: parent @@ -186,7 +187,7 @@ Item { width: ScreenTools.defaultFontPixelSize * 2 radius: ScreenTools.defaultFontPixelSize / 3 visible: _controller.hasVideo && !_isPipVisible - color: _isBackgroundDark ? Qt.rgba(1,1,1,0.5) : Qt.rgba(0,0,0,0.5) + color: isBackgroundDark ? Qt.rgba(1,1,1,0.5) : Qt.rgba(0,0,0,0.5) Image { width: parent.width * 0.75 height: parent.height * 0.75 @@ -208,6 +209,10 @@ Item { //-- Widgets Loader { id: widgetsLoader - anchors.fill: parent + anchors.right: parent.right + anchors.left: parent.left + anchors.bottom: parent.bottom + height: avaiableHeight } + } diff --git a/src/FlightDisplay/FlightDisplayViewVideo.qml b/src/FlightDisplay/FlightDisplayViewVideo.qml index 94f945560..0a5c505f7 100644 --- a/src/FlightDisplay/FlightDisplayViewVideo.qml +++ b/src/FlightDisplay/FlightDisplayViewVideo.qml @@ -45,7 +45,7 @@ Item { text: "NO VIDEO" font.weight: Font.DemiBold color: "white" - font.pixelSize: ScreenTools.defaultFontPixelSize * 1.5 + font.pixelSize: _mainIsMap ? 12 * ScreenTools.fontHRatio : 20 * ScreenTools.fontHRatio anchors.centerIn: parent } } diff --git a/src/FlightDisplay/FlightDisplayViewWidgets.qml b/src/FlightDisplay/FlightDisplayViewWidgets.qml index 0fec4f8ef..8751bf859 100644 --- a/src/FlightDisplay/FlightDisplayViewWidgets.qml +++ b/src/FlightDisplay/FlightDisplayViewWidgets.qml @@ -82,7 +82,7 @@ Item { anchors.right: parent.right anchors.verticalCenter: parent.verticalCenter visible: _isInstrumentVisible - size: mainWindow.width * 0.15 + size: ScreenTools.isTinyScreen ? mainWindow.width * 0.2 : mainWindow.width * 0.15 active: _activeVehicle != null heading: _heading rollAngle: _roll @@ -108,7 +108,7 @@ Item { width: ScreenTools.defaultFontPixelSize * 2 radius: ScreenTools.defaultFontPixelSize / 3 visible: !_isInstrumentVisible - color: _isBackgroundDark ? Qt.rgba(1,1,1,0.5) : Qt.rgba(0,0,0,0.5) + color: isBackgroundDark ? Qt.rgba(1,1,1,0.5) : Qt.rgba(0,0,0,0.5) Image { width: parent.width * 0.75 height: parent.height * 0.75 @@ -130,6 +130,7 @@ Item { //-- Vertical Tool Buttons Column { id: toolColumn + visible: _mainIsMap anchors.margins: ScreenTools.defaultFontPixelHeight anchors.left: parent.left anchors.top: parent.top diff --git a/src/MissionEditor/MissionEditor.qml b/src/MissionEditor/MissionEditor.qml index 4d5a688f1..95ae418d6 100644 --- a/src/MissionEditor/MissionEditor.qml +++ b/src/MissionEditor/MissionEditor.qml @@ -373,7 +373,7 @@ QGCView { // Mission Item Editor Item { id: missionItemEditor - anchors.top: parent.top + height: mainWindow.avaiableHeight anchors.bottom: parent.bottom anchors.right: parent.right width: _rightPanelWidth diff --git a/src/QmlControls/QGCToolBarButton.qml b/src/QmlControls/QGCToolBarButton.qml index c14b4f428..a32229aa8 100644 --- a/src/QmlControls/QGCToolBarButton.qml +++ b/src/QmlControls/QGCToolBarButton.qml @@ -1,11 +1,51 @@ -import QtQuick 2.2 +import QtQuick 2.4 import QtQuick.Controls 1.2 -import QtQuick.Controls.Styles 1.2 -import QtQuick.Controls.Private 1.0 +import QtGraphicalEffects 1.0 -import QGroundControl.Controls 1.0 -import QGroundControl.Palette 1.0 +Item { + id: _root + + property alias source: icon.source + property bool checked: false + property ExclusiveGroup exclusiveGroup: null + + signal clicked() + + onExclusiveGroupChanged: { + if (exclusiveGroup) { + exclusiveGroup.bindCheckable(_root) + } + } + + Image { + id: icon + width: parent.height * 0.9 + height: parent.height * 0.9 + mipmap: true + fillMode: Image.PreserveAspectFit + visible: false + anchors.verticalCenter: parent.verticalCenter + anchors.horizontalCenter: parent.horizontalCenter + } + + ColorOverlay { + id: iconOverlay + anchors.fill: icon + source: icon + color: (checked ? "#ffff20" : "#ffffff") + } + + MouseArea { + anchors.fill: parent + onClicked: { + checked = true + _root.clicked() + } + } +} + +/* QGCButton { id: button property bool repaintChevron: false @@ -62,3 +102,4 @@ QGCButton { } } } +*/ diff --git a/src/QmlControls/QGroundControl.Controls.qmldir b/src/QmlControls/QGroundControl.Controls.qmldir index ca970c0f3..0b96e7952 100644 --- a/src/QmlControls/QGroundControl.Controls.qmldir +++ b/src/QmlControls/QGroundControl.Controls.qmldir @@ -23,17 +23,18 @@ ExclusiveGroupItem 1.0 ExclusiveGroupItem.qml ParameterEditor 1.0 ParameterEditor.qml ParameterEditorDialog 1.0 ParameterEditorDialog.qml -ModeSwitchDisplay 1.0 ModeSwitchDisplay.qml +ModeSwitchDisplay 1.0 ModeSwitchDisplay.qml -QGCView 1.0 QGCView.qml -QGCViewPanel 1.0 QGCViewPanel.qml -QGCViewDialog 1.0 QGCViewDialog.qml -QGCViewMessage 1.0 QGCViewMessage.qml +QGCView 1.0 QGCView.qml +QGCViewPanel 1.0 QGCViewPanel.qml +QGCViewDialog 1.0 QGCViewDialog.qml +QGCViewMessage 1.0 QGCViewMessage.qml MissionItemIndexLabel 1.0 MissionItemIndexLabel.qml MissionItemSummary 1.0 MissionItemSummary.qml MissionItemEditor 1.0 MissionItemEditor.qml -MainToolBar 1.0 MainToolBar.qml +MainToolBar 1.0 MainToolBar.qml +SignalStrength 1.0 SignalStrength.qml -ClickableColor 1.0 ClickableColor.qml +ClickableColor 1.0 ClickableColor.qml diff --git a/src/QmlControls/QGroundControlQmlGlobal.h b/src/QmlControls/QGroundControlQmlGlobal.h index 506a93f91..b52b976ee 100644 --- a/src/QmlControls/QGroundControlQmlGlobal.h +++ b/src/QmlControls/QGroundControlQmlGlobal.h @@ -48,6 +48,9 @@ public: Q_PROPERTY(qreal zOrderWidgets READ zOrderWidgets CONSTANT) ///< z order value to widgets, for example: zoom controls, hud widgetss Q_PROPERTY(qreal zOrderMapItems READ zOrderMapItems CONSTANT) ///< z order value for map items, for example: mission item indicators + /// Global "Advance Mode" preference. Certain UI elements and features are different based on this. + Q_PROPERTY(bool isAdvancedMode READ isAdvancedMode CONSTANT) + Q_INVOKABLE void saveGlobalSetting (const QString& key, const QString& value); Q_INVOKABLE QString loadGlobalSetting (const QString& key, const QString& defaultValue); Q_INVOKABLE void saveBoolGlobalSetting (const QString& key, bool value); @@ -62,6 +65,9 @@ public: qreal zOrderWidgets () { return 100; } qreal zOrderMapItems () { return 50; } + //-- TODO: Make this into an actual preference. + bool isAdvancedMode () { return false; } + private: HomePositionManager* _homePositionManager; FlightMapSettings* _flightMapSettings; diff --git a/src/QmlControls/ScreenTools.qml b/src/QmlControls/ScreenTools.qml index efb4e1557..3852467be 100644 --- a/src/QmlControls/ScreenTools.qml +++ b/src/QmlControls/ScreenTools.qml @@ -14,6 +14,12 @@ Item { readonly property real defaultFontPixelWidth: _textMeasure.fontWidth readonly property real smallFontPixelSize: defaultFontPixelSize * ScreenToolsController.smallFontPixelSizeRatio + // To proportionally scale fonts + + readonly property real _defaultFontHeight: 16 + readonly property real fontHRatio: isTinyScreen ? (_textMeasure.contentHeight / _defaultFontHeight) * 0.75 : (_textMeasure.contentHeight / _defaultFontHeight) + readonly property real realFontHeight: _textMeasure.contentHeight + // On OSX ElCapitan with Qt 5.4.0 any font pixel size above 19 shows garbage test. No idea why at this point. // Will remove Math.min when problem is figure out. readonly property real mediumFontPixelSize: Math.min(defaultFontPixelSize * ScreenToolsController.mediumFontPixelSizeRatio, ScreenToolsController.isMobile ? 10000 : 19) @@ -36,7 +42,6 @@ Item { Text { id: _textMeasure text: "X" - property real fontWidth: contentWidth * (ScreenToolsController.testHighDPI ? 2 : 1) property real fontHeight: contentHeight * (ScreenToolsController.testHighDPI ? 2 : 1) } diff --git a/src/VehicleSetup/SetupView.qml b/src/VehicleSetup/SetupView.qml index 9c50dd10f..68b071121 100644 --- a/src/VehicleSetup/SetupView.qml +++ b/src/VehicleSetup/SetupView.qml @@ -36,7 +36,6 @@ import QGroundControl.ScreenTools 1.0 import QGroundControl.MultiVehicleManager 1.0 Rectangle { - anchors.fill: parent color: qgcPal.window z: QGroundControl.zOrderTopMost @@ -204,10 +203,11 @@ Rectangle { } Rectangle { - //anchors.margins: _defaultTextHeight * 2 + //-- Fill entire screen, including behind tool bar anchors.fill: parent color: qgcPal.windowShadeDark + /* I think this takes too much space and is not exactly necessary QGCLabel { id: title anchors.topMargin: _margin @@ -218,24 +218,27 @@ Rectangle { font.pixelSize: ScreenTools.largeFontPixelSize text: "Vehicle Setup" } + */ Rectangle { + //-- Limit height to available height (below tool bar) anchors.topMargin: _margin - anchors.top: title.bottom + //anchors.top: title.bottom + height: mainWindow.avaiableHeight anchors.bottom: parent.bottom anchors.left: parent.left anchors.right: parent.right color: qgcPal.window - Flickable { - id: buttonFlickable + ScrollView { + id: buttonScroll width: _buttonWidth anchors.topMargin: _defaultTextHeight / 2 anchors.top: parent.top anchors.bottom: parent.bottom - contentWidth: _buttonWidth - contentHeight: buttonColumn.height - flickableDirection: Flickable.VerticalFlick + frameVisible: false + horizontalScrollBarPolicy: Qt.ScrollBarAlwaysOff + verticalScrollBarPolicy: Qt.ScrollBarAlwaysOff Column { id: buttonColumn @@ -314,13 +317,15 @@ Rectangle { } } // Column - } // Flickable + } // ScrollView Loader { id: panelLoader + anchors.topMargin: _margin + anchors.bottomMargin: _margin anchors.leftMargin: _defaultTextWidth anchors.rightMargin: _defaultTextWidth - anchors.left: buttonFlickable.right + anchors.left: buttonScroll.right anchors.right: parent.right anchors.top: parent.top anchors.bottom: parent.bottom diff --git a/src/ui/MainWindow.qml b/src/ui/MainWindow.qml index 81f34f299..cadd828a4 100644 --- a/src/ui/MainWindow.qml +++ b/src/ui/MainWindow.qml @@ -34,11 +34,11 @@ import QGroundControl.ScreenTools 1.0 Item { id: mainWindow - property var _toolbar: toolbarLoader.item - readonly property string _planViewSource: "MissionEditor.qml" readonly property string _setupViewSource: "SetupView.qml" + property real avaiableHeight: height - toolBar.height + Connections { target: controller @@ -67,7 +67,7 @@ Item { planViewLoader.visible = false } - onShowToolbarMessage: _toolbar.showToolbarMessage(message) + onShowToolbarMessage: toolBar.showToolbarMessage(message) // The following are use for unit testing only @@ -77,11 +77,6 @@ Item { onShowSetupVehicleComponent: setupViewLoader.item.showVehicleComponentPanel(vehicleComponent) } - // We delay load the following control to improve boot time - Component.onCompleted: { - toolbarLoader.source = "MainToolBar.qml" - } - // Detect tablet position property var tabletPosition: QtPositioning.coordinate(37.803784, -122.462276) PositionSource { @@ -97,41 +92,37 @@ Item { } } - Loader { - id: toolbarLoader - width: parent.width - height: item ? item.height : 0 + MainToolBar { + id: toolBar + height: ScreenTools.isMobile ? (ScreenTools.isTinyScreen ? (mainWindow.width * 0.0666) : (mainWindow.width * 0.0444)) : ScreenTools.defaultFontPixelSize * 4 + anchors.left: parent.left + anchors.right: parent.right + anchors.top: parent.top + isBackgroundDark: flightView.isBackgroundDark z: QGroundControl.zOrderTopMost } FlightDisplayView { - id: flightView - anchors.left: parent.left - anchors.right: parent.right - anchors.top: toolbarLoader.bottom - anchors.bottom: parent.bottom - visible: true + id: flightView + anchors.fill: parent + avaiableHeight: mainWindow.avaiableHeight + visible: true } Loader { id: planViewLoader - anchors.left: parent.left - anchors.right: parent.right - anchors.top: toolbarLoader.bottom - anchors.bottom: parent.bottom + anchors.fill: parent visible: false - property var tabletPosition: mainWindow.tabletPosition } Loader { id: setupViewLoader - anchors.left: parent.left - anchors.right: parent.right - anchors.top: toolbarLoader.bottom anchors.bottom: parent.bottom + anchors.right: parent.right + anchors.left: parent.left + height: mainWindow.avaiableHeight visible: false - property var tabletPosition: mainWindow.tabletPosition } } diff --git a/src/ui/toolbar/GPS.qml b/src/ui/toolbar/GPS.qml new file mode 100644 index 000000000..865348601 --- /dev/null +++ b/src/ui/toolbar/GPS.qml @@ -0,0 +1,47 @@ +/*===================================================================== + +QGroundControl Open Source Ground Control Station + +(c) 2009, 2015 QGROUNDCONTROL PROJECT + +This file is part of the QGROUNDCONTROL project + + QGROUNDCONTROL is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + QGROUNDCONTROL is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with QGROUNDCONTROL. If not, see . + +======================================================================*/ + +/** + * @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/Images/AirplaneIcon.svg b/src/ui/toolbar/Images/AirplaneIcon.svg new file mode 100644 index 000000000..d6e8ac565 --- /dev/null +++ b/src/ui/toolbar/Images/AirplaneIcon.svg @@ -0,0 +1,15 @@ + + + + + + diff --git a/src/ui/toolbar/Images/Armed.svg b/src/ui/toolbar/Images/Armed.svg new file mode 100644 index 000000000..8c1ef8ab4 --- /dev/null +++ b/src/ui/toolbar/Images/Armed.svg @@ -0,0 +1,11 @@ + + + + + + + diff --git a/src/ui/toolbar/Images/Battery.svg b/src/ui/toolbar/Images/Battery.svg new file mode 100644 index 000000000..31cbf4627 --- /dev/null +++ b/src/ui/toolbar/Images/Battery.svg @@ -0,0 +1,19 @@ + + + + + + + + + + diff --git a/src/ui/toolbar/Images/Connect.svg b/src/ui/toolbar/Images/Connect.svg new file mode 100644 index 000000000..620818334 --- /dev/null +++ b/src/ui/toolbar/Images/Connect.svg @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + + diff --git a/src/ui/toolbar/Images/Disarmed.svg b/src/ui/toolbar/Images/Disarmed.svg new file mode 100644 index 000000000..0a02dbfb9 --- /dev/null +++ b/src/ui/toolbar/Images/Disarmed.svg @@ -0,0 +1,14 @@ + + + + + + + + + + diff --git a/src/ui/toolbar/Images/Disconnect.svg b/src/ui/toolbar/Images/Disconnect.svg new file mode 100644 index 000000000..c9051b789 --- /dev/null +++ b/src/ui/toolbar/Images/Disconnect.svg @@ -0,0 +1,12 @@ + + + + + + diff --git a/src/ui/toolbar/Images/Gps.svg b/src/ui/toolbar/Images/Gps.svg new file mode 100644 index 000000000..fcb5b4fc7 --- /dev/null +++ b/src/ui/toolbar/Images/Gps.svg @@ -0,0 +1,79 @@ + + + + +GPS + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/ui/toolbar/Images/Megaphone.svg b/src/ui/toolbar/Images/Megaphone.svg new file mode 100644 index 000000000..7942f51cb --- /dev/null +++ b/src/ui/toolbar/Images/Megaphone.svg @@ -0,0 +1,18 @@ + + + + + + + + + + diff --git a/src/ui/toolbar/Images/Quad.svg b/src/ui/toolbar/Images/Quad.svg new file mode 100644 index 000000000..ae693a31d --- /dev/null +++ b/src/ui/toolbar/Images/Quad.svg @@ -0,0 +1,55 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/ui/toolbar/Images/RC.svg b/src/ui/toolbar/Images/RC.svg new file mode 100644 index 000000000..7e70a74d2 --- /dev/null +++ b/src/ui/toolbar/Images/RC.svg @@ -0,0 +1,75 @@ + + + + +GPS + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/ui/toolbar/Images/Signal0.svg b/src/ui/toolbar/Images/Signal0.svg new file mode 100644 index 000000000..5343a5e60 --- /dev/null +++ b/src/ui/toolbar/Images/Signal0.svg @@ -0,0 +1,73 @@ + + + + +GPS + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/ui/toolbar/Images/Signal100.svg b/src/ui/toolbar/Images/Signal100.svg new file mode 100644 index 000000000..4b74688d7 --- /dev/null +++ b/src/ui/toolbar/Images/Signal100.svg @@ -0,0 +1,72 @@ + + + + +GPS + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/ui/toolbar/Images/Signal20.svg b/src/ui/toolbar/Images/Signal20.svg new file mode 100644 index 000000000..2d8518932 --- /dev/null +++ b/src/ui/toolbar/Images/Signal20.svg @@ -0,0 +1,74 @@ + + + + +GPS + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/ui/toolbar/Images/Signal40.svg b/src/ui/toolbar/Images/Signal40.svg new file mode 100644 index 000000000..b1f899e7e --- /dev/null +++ b/src/ui/toolbar/Images/Signal40.svg @@ -0,0 +1,74 @@ + + + + +GPS + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/ui/toolbar/Images/Signal60.svg b/src/ui/toolbar/Images/Signal60.svg new file mode 100644 index 000000000..c6a002d79 --- /dev/null +++ b/src/ui/toolbar/Images/Signal60.svg @@ -0,0 +1,73 @@ + + + + +GPS + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/ui/toolbar/Images/Signal80.svg b/src/ui/toolbar/Images/Signal80.svg new file mode 100644 index 000000000..9c04753ea --- /dev/null +++ b/src/ui/toolbar/Images/Signal80.svg @@ -0,0 +1,73 @@ + + + + +GPS + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/ui/toolbar/Images/Yield.svg b/src/ui/toolbar/Images/Yield.svg new file mode 100644 index 000000000..11ba1bd49 --- /dev/null +++ b/src/ui/toolbar/Images/Yield.svg @@ -0,0 +1,17 @@ + + + + + + + + + diff --git a/src/ui/toolbar/MainToolBar.qml b/src/ui/toolbar/MainToolBar.qml index f31f096b3..fd299ef58 100644 --- a/src/ui/toolbar/MainToolBar.qml +++ b/src/ui/toolbar/MainToolBar.qml @@ -27,7 +27,7 @@ This file is part of the QGROUNDCONTROL project * @author Gus Grubba */ -import QtQuick 2.3 +import QtQuick 2.5 import QtQuick.Controls 1.2 import QtQuick.Controls.Styles 1.2 @@ -39,275 +39,232 @@ import QGroundControl.ScreenTools 1.0 import QGroundControl.Controllers 1.0 Rectangle { - id: toolBarHolder - anchors.left: parent.left - anchors.right: parent.right - height: toolBarHeight - color: qgcPal.window + id: toolBar + color: isBackgroundDark ? Qt.rgba(0,0,0,0.75) : Qt.rgba(0,0,0,0.5) QGCPalette { id: qgcPal; colorGroupEnabled: true } - property var activeVehicle: multiVehicleManager.activeVehicle + property var activeVehicle: multiVehicleManager.activeVehicle + property bool isMessageImportant: activeVehicle ? !activeVehicle.messageTypeNormal && !activeVehicle.messageTypeNone : false + property bool isBackgroundDark: true - readonly property real toolBarHeight: ScreenTools.defaultFontPixelHeight * 3 - property int cellSpacerSize: ScreenTools.isMobile ? getProportionalDimmension(6) : getProportionalDimmension(4) - readonly property int cellHeight: toolBarHeight * 0.75 + /* + Dev System (Mac OS) + + qml: Main Window Width: 1008 + qml: Toolbar height: 51.2 + qml: Default font: 12.8 + qml: Font (.75): 9.600000000000001 + qml: Font (.85): 10.88 + qml: Font 1.5): 19.200000000000003 + qml: Default Font Width: 8.328125 + qml: Default Font Height: 12.8 + qml: -- + qml: Real Font Height: 16 + qml: fontHRatio: 1 + qml: -- + qml: cellHeight: 38 + qml: tbFontSmall: 10 + qml: tbFontNormal: 12 + qml: tbFontLarge: 18 + qml: tbSpacing: 9.54 + + Nexus 9 + + qml: Main Window Width: 2048 + qml: Toolbar height: 90.9312 + qml: Default font: 38 + qml: Font (.75): 28.5 + qml: Font (.85): 32.3 + qml: Font 1.5): 57 + qml: Default Font Width: 20.0625 + qml: Default Font Height: 38 + qml: -- + qml: Real Font Height: 38 + qml: fontHRatio: 2.375 + qml: -- + qml: cellHeight: 68 + qml: tbFontSmall: 23.75 + qml: tbFontNormal: 28.5 + qml: tbFontLarge: 42.75 + qml: tbSpacing: 16.87552 + + Nexus 7 + + qml: Main Window Width: 1920 + qml: Toolbar height: 85.248 + qml: Default font: 38 + qml: Font (.75): 28.5 + qml: Font (.85): 32.3 + qml: Font 1.5): 57 + qml: Default Font Width: 20.140625 + qml: Default Font Height: 38 + qml: -- + qml: Real Font Height: 38 + qml: fontHRatio: 2.375 + qml: -- + qml: cellHeight: 63 + qml: tbFontSmall: 23.75 + qml: tbFontNormal: 28.5 + qml: tbFontLarge: 42.75 + qml: tbSpacing: 15.820800000000002 + + Nexus 4 + + qml: Main Window Width: 1196 + qml: Toolbar height: 79.65360000000001 + qml: Default font: 38 + qml: Font (.75): 28.5 + qml: Font (.85): 32.3 + qml: Font 1.5): 57 + qml: Default Font Width: 20.140625 + qml: Default Font Height: 38 + qml: -- + qml: Real Font Height: 38 + qml: fontHRatio: 2.375 + qml: -- + qml: cellHeight: 59 + qml: tbFontSmall: 23.75 + qml: tbFontNormal: 28.5 + qml: tbFontLarge: 42.75 + qml: tbSpacing: 9.85504 + + */ + + readonly property int cellHeight: height * 0.75 - readonly property real horizontalMargins: ScreenTools.defaultFontPixelWidth / 2 - readonly property real verticalMargins: ScreenTools.defaultFontPixelHeight / 4 + readonly property real tbFontSmall: 10 * ScreenTools.fontHRatio + readonly property real tbFontNormal: 12 * ScreenTools.fontHRatio + readonly property real tbFontLarge: 18 * ScreenTools.fontHRatio - readonly property var colorBlue: "#1a6eaa" - readonly property var colorGreen: "#329147" - readonly property var colorRed: "#942324" - readonly property var colorOrange: "#a76f26" - readonly property var colorWhite: "#f0f0f0" + readonly property real tbSpacing: ScreenTools.isMobile ? toolBar.width * 0.00824 : 9.54 - property var colorOrangeText: (qgcPal.globalTheme === QGCPalette.Light) ? "#b75711" : "#ea8225" - property var colorRedText: (qgcPal.globalTheme === QGCPalette.Light) ? "#ee1112" : "#ef2526" - property var colorGreenText: (qgcPal.globalTheme === QGCPalette.Light) ? "#046b1b" : "#00d930" - property var colorWhiteText: (qgcPal.globalTheme === QGCPalette.Light) ? "#343333" : "#f0f0f0" + readonly property var colorGreen: "#05f068" + readonly property var colorOrange: "#f0ab06" + readonly property var colorRed: "#fc4638" + readonly property var colorGrey: "#7f7f7f" + readonly property var colorBlue: "#636efe" + readonly property var colorWhite: "#ffffff" MainToolBarController { id: _controller } function showToolbarMessage(message) { toolBarMessage.text = message - if (toolBarMessage.contentHeight > toolBarMessageCloseButton.height) { - toolBarHolder.height = toolBarHeight + toolBarMessage.contentHeight + (verticalMargins * 2) - } else { - toolBarHolder.height = toolBarHeight + toolBarMessageCloseButton.height + (verticalMargins * 2) - } toolBarMessageArea.visible = true } - function getProportionalDimmension(val) { - return toolBarHeight * val / 40 - } - - function getMessageColor() { - if (activeVehicle.messageTypeNone) - return qgcPal.button; - if (activeVehicle.messageTypeNorma) - return colorBlue; - if (activeVehicle.messageTypeWarning) - return colorOrange; - if (activeVehicle.messageTypeError) - return colorRed; - // Cannot be so make make it obnoxious to show error - return "purple"; - } - - function getMessageIcon() { - if (activeVehicle.messageTypeNormal || activeVehicle.messageTypeNone) - return "qrc:/res/Megaphone"; - else - return "qrc:/res/Yield"; - } - - function getBatteryIcon() { - if(activeVehicle.batteryPercent < 20.0) - return "qrc:/res/Battery_0"; - else if(activeVehicle.batteryPercent < 40.0) - return "qrc:/res/Battery_20"; - else if(activeVehicle.batteryPercent < 60.0) - return "qrc:/res/Battery_40"; - else if(activeVehicle.batteryPercent < 80.0) - return "qrc:/res/Battery_60"; - else if(activeVehicle.batteryPercent < 90.0) - return "qrc:/res/Battery_80"; - else - return "qrc:/res/Battery_100"; - } - - function getBatteryColor() { - if (activeVehicle.batteryPercent > 40.0) - return colorGreen; - if(activeVehicle.batteryPercent > 0.01) - return colorRed; - // This means there is no battery level data - return colorBlue; - } - - function getSatelliteColor() { - // No GPS data - if (activeVehicle.satelliteCount < 0) - return qgcPal.button - // No Lock - if(activeVehicle.satelliteLock < 2) - return colorRed; - // 2D Lock - if(activeVehicle.satelliteLock === 2) - return colorBlue; - // Lock is 3D or more - return colorGreen; - } - - function getRSSIColor(value) { - if(value < 10) - return colorRed; - if(value < 50) - return colorOrange; - return colorGreen; - } - function showMavStatus() { return (multiVehicleManager.activeVehicleAvailable && activeVehicle.heartbeatTimeout === 0 && _controller.connectionCount > 0); } - //------------------------------------------------------------------------- - //-- Main menu for Mobile Devices - Menu { - id: mobileMenu - - ExclusiveGroup { id: mainMenuGroup } - - MenuItem { - id: flyViewShowing - text: "Fly" - checkable: true - checked: true - exclusiveGroup: mainMenuGroup - - onTriggered: { - checked = true - _controller.onFlyView(); - } - } + Component.onCompleted: { + //-- TODO: Get this from the actual state + flyButton.checked = true + } - MenuItem { - id: setupViewShowing - text: "Setup" - checkable: true - exclusiveGroup: mainMenuGroup + Connections { + target: controller + onShowFlyView: { flyButton.checked = true } + onShowPlanView: { planButton.checked = true } + onShowSetupView:{ setupButton.checked = true } + } - onTriggered: { - checked = true + Row { + id: viewRow + height: cellHeight + spacing: tbSpacing + anchors.left: parent.left + anchors.leftMargin: tbSpacing + anchors.verticalCenter: parent.verticalCenter + + ExclusiveGroup { id: mainActionGroup } + + QGCToolBarButton { + id: setupButton + width: cellHeight * 1.3 + height: cellHeight + exclusiveGroup: mainActionGroup + source: "qrc:/res/Gears" + onClicked: { _controller.onSetupView(); } } - MenuItem { - id: planViewShowing - text: "Plan" - checkable: true - exclusiveGroup: mainMenuGroup + Rectangle { + height: cellHeight + width: 1 + color: Qt.rgba(1,1,1,0.45) + } - onTriggered: { - checked = true + QGCToolBarButton { + id: planButton + width: cellHeight * 1.3 + height: cellHeight + exclusiveGroup: mainActionGroup + source: "qrc:/res/Plan" + onClicked: { _controller.onPlanView(); } } - MenuSeparator { } - - - MenuItem { - text: "QGroundControl Settings" - - onTriggered: controller.showSettings() + Rectangle { + height: cellHeight + width: 1 + color: Qt.rgba(1,1,1,0.45) } - } // Menu - /* - Row { - id: toolRow - height: cellHeight - spacing: getProportionalDimmension(4) - } - */ - - Loader { - id: desktopToolsLoader - height: cellHeight - x: horizontalMargins - y: (toolBarHeight - cellHeight) / 2 - sourceComponent: ScreenTools.isMobile ? undefined : desktopTools - } - - //--------------------------------------------------------------------- - //-- Indicators - Row { - id: row12 - x: horizontalMargins + (ScreenTools.isMobile ? 0: desktopToolsLoader.item.width) - height: cellHeight - spacing: cellSpacerSize - anchors.top: desktopToolsLoader.top - anchors.verticalCenter: desktopToolsLoader.verticalCenter - - //-- "Hamburger" menu for Mobile Devices - Item { - id: actionButton - visible: ScreenTools.isMobile - height: cellHeight - width: cellHeight - Image { - id: buttomImg - anchors.fill: parent - source: "/qmlimages/buttonMore.svg" - mipmap: true - smooth: true - antialiasing: true - fillMode: Image.PreserveAspectFit - } - MouseArea { - anchors.fill: parent - acceptedButtons: Qt.LeftButton - onClicked: { - if (mouse.button == Qt.LeftButton) - { - mobileMenu.popup(); - } - } + QGCToolBarButton { + id: flyButton + width: cellHeight * 1.3 + height: cellHeight + exclusiveGroup: mainActionGroup + source: "qrc:/res/PaperPlane" + onClicked: { + _controller.onFlyView(); } } - //-- Separator if Hamburger menu is visible Rectangle { - visible: actionButton.visible - height: cellHeight - width: cellHeight - color: "#00000000" - anchors.verticalCenter: parent.verticalCenter + height: cellHeight + width: 1 + color: Qt.rgba(1,1,1,0.45) } - Loader { - id: activeVehicleLoader - visible: showMavStatus() - source: multiVehicleManager.activeVehicleAvailable ? "MainToolBarActiveVehicleComponent.qml" : "" + } - property real cellHeight: toolBarHolder.cellHeight - property real cellSpacerSize: toolBarHolder.cellSpacerSize + Item { + visible: showMavStatus() && !connectionStatus.visible + height: cellHeight + width: (toolBar.width - viewRow.width - connectRow.width) + anchors.left: viewRow.right + anchors.leftMargin: tbSpacing * 2 + anchors.verticalCenter: parent.verticalCenter + Loader { + source: multiVehicleManager.activeVehicleAvailable ? "MainToolBarIndicators.qml" : "" + anchors.left: parent.left + anchors.verticalCenter: parent.verticalCenter } + } - Rectangle { - id: connectionStatus - width: getProportionalDimmension(160) - height: cellHeight - visible: (_controller.connectionCount > 0 && multiVehicleManager.activeVehicleAvailable && activeVehicle.heartbeatTimeout != 0) - anchors.verticalCenter: parent.verticalCenter - color: "#00000000" - border.color: "#00000000" - border.width: 0 - - QGCLabel { - id: connectionStatusText - text: qsTr("CONNECTION LOST") - font.pixelSize: ScreenTools.defaultFontPixelSize - font.weight: Font.DemiBold - anchors.verticalCenter: parent.verticalCenter - anchors.horizontalCenter: parent.horizontalCenter - color: colorRedText - } - } - } // Row + QGCLabel { + id: connectionStatus + visible: (_controller.connectionCount > 0 && multiVehicleManager.activeVehicleAvailable && activeVehicle.heartbeatTimeout != 0) + text: "CONNECTION LOST" + font.pixelSize: tbFontLarge + font.weight: Font.DemiBold + color: colorRed + anchors.left: viewRow.right + anchors.leftMargin: tbSpacing * 2 + anchors.verticalCenter: parent.verticalCenter + } Row { id: connectRow - anchors.rightMargin: verticalMargins + height: cellHeight + spacing: tbSpacing + anchors.rightMargin: tbSpacing anchors.right: parent.right - anchors.top: desktopToolsLoader.top - anchors.verticalCenter: desktopToolsLoader.verticalCenter - height: desktopToolsLoader.height - spacing: cellSpacerSize + anchors.verticalCenter: parent.verticalCenter Menu { id: connectMenu @@ -336,20 +293,53 @@ Rectangle { } } - QGCButton { - id: connectButton - width: getProportionalDimmension(100) - visible: _controller.connectionCount === 0 - text: qsTr("Connect") - menu: connectMenu + Rectangle { + height: cellHeight + width: 1 + color: Qt.rgba(1,1,1,0.45) } - QGCButton { - id: disconnectButton - width: getProportionalDimmension(100) - visible: _controller.connectionCount === 1 - text: qsTr("Disconnect") + QGCToolBarButton { + id: connectButton + width: cellHeight * 1.3 + height: cellHeight + visible: _controller.connectionCount === 0 + source: "/qmlimages/Connect.svg" + checked: false + onClicked: { + checked = false + connectMenu.popup() + /* + console.log("Main Window Width: " + mainWindow.width) + console.log("Toolbar height: " + toolBar.height) + console.log("Default font: " + ScreenTools.defaultFontPixelSize) + console.log("Font (.75): " + ScreenTools.defaultFontPixelSize * 0.75) + console.log("Font (.85): " + ScreenTools.defaultFontPixelSize * 0.85) + console.log("Font 1.5): " + ScreenTools.defaultFontPixelSize * 1.5) + console.log("Default Font Width: " + ScreenTools.defaultFontPixelWidth) + console.log("Default Font Height: " + ScreenTools.defaultFontPixelHeight) + console.log("--") + console.log("Real Font Height: " + ScreenTools.realFontHeight) + console.log("fontHRatio: " + ScreenTools.fontHRatio) + console.log("--") + console.log("cellHeight: " + cellHeight) + console.log("tbFontSmall: " + tbFontSmall); + console.log("tbFontNormal: " + tbFontNormal); + console.log("tbFontLarge: " + tbFontLarge); + console.log("tbSpacing: " + tbSpacing); + */ + } + } + + QGCToolBarButton { + id: disconnectButton + width: cellHeight * 1.3 + height: cellHeight + visible: _controller.connectionCount === 1 + source: "/qmlimages/Disconnect.svg" + checked: false onClicked: { + checked = false _controller.onDisconnect(""); } } @@ -372,131 +362,63 @@ Rectangle { } } - QGCButton { - id: multidisconnectButton - width: getProportionalDimmension(100) - text: "Disconnect" - visible: _controller.connectionCount > 1 - menu: disconnectMenu + QGCToolBarButton { + id: multidisconnectButton + width: cellHeight * 1.3 + height: cellHeight + visible: _controller.connectionCount > 1 + source: "/qmlimages/Disconnect.svg" + checked: false + onClicked: { + checked = false + disconnectMenu.popup() + } } - } // Row + + } // Progress bar Rectangle { id: progressBar - anchors.top: desktopToolsLoader.bottom - height: getProportionalDimmension(3) + anchors.bottom: parent.bottom + height: toolBar.height * 0.05 width: parent.width * _controller.progressBarValue - color: qgcPal.text + color: colorGreen } // Toolbar message area Rectangle { - id: toolBarMessageArea - anchors.leftMargin: horizontalMargins - anchors.rightMargin: horizontalMargins - anchors.topMargin: verticalMargins - anchors.bottomMargin: verticalMargins - anchors.top: progressBar.bottom - anchors.bottom: parent.bottom - anchors.left: parent.left - anchors.right: parent.right - color: qgcPal.windowShadeDark - visible: false - + id: toolBarMessageArea + x: toolBar.parent.width * 0.225 + y: toolBar.parent.height - (ScreenTools.defaultFontPixelHeight * ScreenTools.fontHRatio * 6) + width: toolBar.parent.width * 0.55 + height: ScreenTools.defaultFontPixelHeight * ScreenTools.fontHRatio * 6 + color: Qt.rgba(0,0,0,0.65) + visible: false QGCLabel { - id: toolBarMessage - anchors.fill: parent - wrapMode: Text.WordWrap - color: qgcPal.warningText + id: toolBarMessage + width: toolBarMessageArea.width - toolBarMessageCloseButton.width + wrapMode: Text.WordWrap + color: qgcPal.warningText + lineHeightMode: Text.ProportionalHeight + lineHeight: 1.25 + anchors.left: parent.left + anchors.top: parent.top + anchors.bottom: parent.bottom + anchors.margins: tbSpacing } - QGCButton { - id: toolBarMessageCloseButton - anchors.rightMargin: horizontalMargins - anchors.top: parent.top - anchors.right: parent.right - primary: true - text: "Close Message" - + id: toolBarMessageCloseButton + primary: true + text: "Close Message" + anchors.right: parent.right + anchors.bottom: parent.bottom + anchors.margins: tbSpacing onClicked: { - parent.visible = false - toolBarHolder.height = toolBarHeight + toolBarMessageArea.visible = false _controller.onToolBarMessageClosed() } } } - Component { - id: desktopTools - - //--------------------------------------------------------------------- - //-- Main menu for Non Mobile Devices (Chevron Buttons) - Row { - id: row11 - height: cellHeight - spacing: -getProportionalDimmension(12) - - Connections { - target: ScreenTools - onRepaintRequested: { - setupButton.repaintChevron = true; - planButton.repaintChevron = true; - flyButton.repaintChevron = true; - } - } - Connections { - target:controller - onShowFlyView: { flyButton.checked = true } - onShowPlanView: { planButton.checked = true } - onShowSetupView:{ setupButton.checked = true } - } - - - ExclusiveGroup { id: mainActionGroup } - - QGCToolBarButton { - id: setupButton - width: getProportionalDimmension(90) - height: cellHeight - exclusiveGroup: mainActionGroup - text: "Setup" - - onClicked: { - checked = true - _controller.onSetupView(); - } - z: 1000 - } - - QGCToolBarButton { - id: planButton - width: getProportionalDimmension(90) - height: cellHeight - exclusiveGroup: mainActionGroup - text: "Plan" - - onClicked: { - checked = true - _controller.onPlanView(); - } - z: 900 - } - - QGCToolBarButton { - id: flyButton - width: getProportionalDimmension(90) - height: cellHeight - exclusiveGroup: mainActionGroup - text: "Fly" - checked: true - - onClicked: { - checked = true - _controller.onFlyView(); - } - z: 800 - } - } // Row - } // Component - desktopTools } // Rectangle diff --git a/src/ui/toolbar/MainToolBarActiveVehicleComponent.qml b/src/ui/toolbar/MainToolBarActiveVehicleComponent.qml deleted file mode 100644 index df788d845..000000000 --- a/src/ui/toolbar/MainToolBarActiveVehicleComponent.qml +++ /dev/null @@ -1,426 +0,0 @@ -/*===================================================================== - -QGroundControl Open Source Ground Control Station - -(c) 2009, 2015 QGROUNDCONTROL PROJECT - -This file is part of the QGROUNDCONTROL project - - QGROUNDCONTROL is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - QGROUNDCONTROL is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with QGROUNDCONTROL. If not, see . - -======================================================================*/ - -import QtQuick 2.3 -import QtQuick.Controls 1.2 -import QtQuick.Controls.Styles 1.2 - -import QGroundControl.Controls 1.0 -import QGroundControl.ScreenTools 1.0 - -Row { - height: cellHeight - spacing: cellSpacerSize - - Rectangle { - id: messages - width: (activeVehicle.messageCount > 99) ? getProportionalDimmension(65) : getProportionalDimmension(60) - height: cellHeight - anchors.verticalCenter: parent.verticalCenter - color: getMessageColor() - border.color: "#00000000" - border.width: 0 - property bool showTriangle: false - - Image { - id: messageIcon - source: getMessageIcon(); - height: getProportionalDimmension(16) - fillMode: Image.PreserveAspectFit - anchors.verticalCenter: parent.verticalCenter - anchors.left: parent.left - anchors.leftMargin: getProportionalDimmension(8) - } - - Item { - id: messageTextRect - anchors.verticalCenter: parent.verticalCenter - anchors.right: parent.right - width: messages.width - messageIcon.width - QGCLabel { - id: messageText - text: (activeVehicle.messageCount > 0) ? activeVehicle.messageCount : '' - font.pixelSize: ScreenTools.smallFontPixelSize - font.weight: Font.DemiBold - anchors.verticalCenter: parent.verticalCenter - anchors.horizontalCenter: parent.horizontalCenter - horizontalAlignment: Text.AlignHCenter - color: colorWhite - } - } - - Image { - id: dropDown - source: "/qmlimages/arrow-down.png" - visible: (messages.showTriangle) && (activeVehicle.messageCount > 0) - anchors.bottom: parent.bottom - anchors.right: parent.right - anchors.bottomMargin: getProportionalDimmension(3) - anchors.rightMargin: getProportionalDimmension(3) - } - - Timer { - id: mouseOffTimer - interval: 2000; - running: false; - repeat: false - onTriggered: { - messages.showTriangle = false; - } - } - - MouseArea { - anchors.fill: parent - hoverEnabled: true - onEntered: { - messages.showTriangle = true; - mouseOffTimer.start(); - } - onClicked: { - var p = mapToItem(toolBarHolder, mouseX, mouseY); - _controller.onEnterMessageArea(p.x, p.y); - } - } - - } - - QGCButton { - width: ScreenTools.defaultFontPixelWidth * 13 - height: cellHeight - anchors.verticalCenter: parent.verticalCenter - text: "Vehicle " + activeVehicle.id - - menu: vehicleMenu - - Menu { - id: vehicleMenu - } - - Component { - id: vehicleMenuItemComponent - - MenuItem { - checkable: true - checked: vehicle.active - onTriggered: multiVehicleManager.activeVehicle = vehicle - - property int vehicleId: Number(text.split(" ")[1]) - property var vehicle: multiVehicleManager.getVehicleById(vehicleId) - } - } - - property var vehicleMenuItems: [] - - function updateVehicleMenu() { - // Remove old menu items - for (var i=0; i= 0 ? activeVehicle.satelliteCount : 'NA' - font.pixelSize: activeVehicle.satelliteCount >= 0 ? ScreenTools.defaultFontPixelSize : ScreenTools.smallFontPixelSize - font.weight: Font.DemiBold - anchors.verticalCenter: parent.verticalCenter - anchors.right: parent.right - anchors.rightMargin: getProportionalDimmension(6) - horizontalAlignment: Text.AlignRight - color: colorWhite - } - } - - Rectangle { - id: rssiRC - width: getProportionalDimmension(55) - height: cellHeight - visible: _controller.remoteRSSI <= 100 - anchors.verticalCenter: parent.verticalCenter - color: getRSSIColor(_controller.remoteRSSI); - border.color: "#00000000" - border.width: 0 - Image { - source: "qrc:/res/AntennaRC"; - width: cellHeight * 0.7 - fillMode: Image.PreserveAspectFit - anchors.verticalCenter: parent.verticalCenter - anchors.left: parent.left - anchors.leftMargin: getProportionalDimmension(6) - mipmap: true - smooth: true - } - QGCLabel { - text: _controller.remoteRSSI - anchors.right: parent.right - anchors.rightMargin: getProportionalDimmension(6) - anchors.verticalCenter: parent.verticalCenter - horizontalAlignment: Text.AlignRight - font.pixelSize: ScreenTools.smallFontPixelSize - font.weight: Font.DemiBold - color: colorWhite - } - } - - Rectangle { - id: rssiTelemetry - width: getProportionalDimmension(80) - height: cellHeight - visible: (_controller.telemetryRRSSI > 0) && (_controller.telemetryLRSSI > 0) - anchors.verticalCenter: parent.verticalCenter - color: getRSSIColor(Math.min(_controller.telemetryRRSSI,_controller.telemetryLRSSI)); - border.color: "#00000000" - border.width: 0 - Image { - source: "qrc:/res/AntennaT"; - width: cellHeight * 0.7 - fillMode: Image.PreserveAspectFit - anchors.verticalCenter: parent.verticalCenter - anchors.left: parent.left - anchors.leftMargin: getProportionalDimmension(6) - mipmap: true - smooth: true - } - Column { - anchors.verticalCenter: parent.verticalCenter - anchors.right: parent.right - anchors.rightMargin: getProportionalDimmension(6) - Row { - anchors.right: parent.right - QGCLabel { - text: 'R ' - font.pixelSize: ScreenTools.smallFontPixelSize - font.weight: Font.DemiBold - color: colorWhite - } - QGCLabel { - text: _controller.telemetryRRSSI + 'dB' - width: getProportionalDimmension(30) - horizontalAlignment: Text.AlignRight - font.pixelSize: ScreenTools.smallFontPixelSize - font.weight: Font.DemiBold - color: colorWhite - } - } - Row { - anchors.right: parent.right - QGCLabel { - text: 'L ' - font.pixelSize: ScreenTools.smallFontPixelSize - font.weight: Font.DemiBold - color: colorWhite - } - QGCLabel { - text: _controller.telemetryLRSSI + 'dB' - width: getProportionalDimmension(30) - horizontalAlignment: Text.AlignRight - font.pixelSize: ScreenTools.smallFontPixelSize - font.weight: Font.DemiBold - color: colorWhite - } - } - } - } - - Rectangle { - id: batteryStatus - width: activeVehicle.batteryConsumed < 0.0 ? getProportionalDimmension(60) : getProportionalDimmension(80) - height: cellHeight - anchors.verticalCenter: parent.verticalCenter - color: getBatteryColor(); - border.color: "#00000000" - border.width: 0 - Image { - source: getBatteryIcon(); - height: getProportionalDimmension(20) - fillMode: Image.PreserveAspectFit - anchors.verticalCenter: parent.verticalCenter - anchors.left: parent.left - anchors.leftMargin: getProportionalDimmension(6) - mipmap: true - smooth: true - } - - QGCLabel { - visible: batteryStatus.visible && activeVehicle.batteryConsumed < 0.0 - text: (activeVehicle.batteryVoltage > 0) ? activeVehicle.batteryVoltage.toFixed(1) + 'V' : '---'; - font.pixelSize: ScreenTools.smallFontPixelSize - font.weight: Font.DemiBold - anchors.right: parent.right - anchors.rightMargin: getProportionalDimmension(6) - anchors.verticalCenter: parent.verticalCenter - horizontalAlignment: Text.AlignRight - color: colorWhite - } - - Column { - anchors.verticalCenter: parent.verticalCenter - anchors.right: parent.right - anchors.rightMargin: getProportionalDimmension(6) - visible: batteryStatus.visible && activeVehicle.batteryConsumed >= 0.0 - QGCLabel { - text: (activeVehicle.batteryVoltage > 0) ? activeVehicle.batteryVoltage.toFixed(1) + 'V' : '---'; - width: getProportionalDimmension(30) - horizontalAlignment: Text.AlignRight - font.pixelSize: ScreenTools.smallFontPixelSize - font.weight: Font.DemiBold - color: colorWhite - } - QGCLabel { - text: (activeVehicle.batteryConsumed > 0) ? activeVehicle.batteryConsumed.toFixed(0) + 'mAh' : '---'; - width: getProportionalDimmension(30) - horizontalAlignment: Text.AlignRight - font.pixelSize: ScreenTools.smallFontPixelSize - font.weight: Font.DemiBold - color: colorWhite - } - } - } - - QGCButton { - width: ScreenTools.defaultFontPixelWidth * 11 - height: cellHeight - anchors.verticalCenter: parent.verticalCenter - text: activeVehicle.armed ? "Armed" : "Disarmed" - - menu: Menu { - MenuItem { - enabled: !activeVehicle.armed - text: "Arm" - - onTriggered: activeVehicle.armed = true - } - - MenuItem { - enabled: activeVehicle.armed - text: "Disarm" - - onTriggered: activeVehicle.armed = false - } - } - } - - QGCButton { - width: ScreenTools.defaultFontPixelWidth * 16 - height: cellHeight - anchors.verticalCenter: parent.verticalCenter - text: activeVehicle.flightMode - - menu: activeVehicle.flightModeSetAvailable ? flightModesMenu : null - - Menu { - id: flightModesMenu - } - - Component { - id: flightModeMenuItemComponent - - MenuItem { - checkable: true - checked: activeVehicle.flightMode == text - onTriggered: activeVehicle.flightMode = text - } - } - - property var flightModesMenuItems: [] - - function updateFlightModesMenu() { - if (activeVehicle.flightModeSetAvailable) { - // Remove old menu items - for (var i=0; i + +This file is part of the QGROUNDCONTROL project + + QGROUNDCONTROL is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + QGROUNDCONTROL is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with QGROUNDCONTROL. If not, see . + +======================================================================*/ + +import QtQuick 2.5 +import QtQuick.Controls 1.2 +import QtGraphicalEffects 1.0 +import QtQuick.Controls.Styles 1.2 + +import QGroundControl 1.0 +import QGroundControl.Controls 1.0 +import QGroundControl.ScreenTools 1.0 + +Row { + spacing: tbSpacing * 2 + + function getSatStrength(count) { + if (count < 1) + return 0 + if (count < 4) + return 20 + if (count < 6) + return 40 + if (count < 8) + return 60 + if (count < 10) + return 80 + return 100 + } + + function getMessageColor() { + 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"; + } + + function getBatteryVoltageText() { + if (activeVehicle.batteryVoltage > 0) { + //-- TODO: Need number of cells so I can show cell voltage instead of total voltage + //if (battNumCells && battNumCells.value) { + // return (activeVehicle.batteryVoltage / battNumCells.value).toFixed(2) + 'V' + //} else { + return activeVehicle.batteryVoltage.toFixed(1) + 'V' + //} + } + return 'N/A'; + } + + function getBatteryPercentageText() { + if(activeVehicle.batteryPercent > 98.9) { + return "100%" + } + if(activeVehicle.batteryPercent > 0.1) { + return activeVehicle.batteryPercent.toFixed(0) + "%" + } + return "N/A" + } + + function getBatteryColor() { + if(activeVehicle.batteryPercent > 75) { + return colorGreen + } + if(activeVehicle.batteryPercent > 50) { + return colorOrange + } + if(activeVehicle.batteryPercent > 0.1) { + return colorRed + } + return colorGrey + } + + //------------------------------------------------------------------------- + //-- Message Indicator + Item { + id: messages + width: cellHeight + height: cellHeight + visible: activeVehicle.messageCount + anchors.verticalCenter: parent.verticalCenter + + Item { + id: criticalMessage + anchors.fill: parent + visible: activeVehicle.messageCount > 0 && isMessageImportant + Image { + source: "/qmlimages/Yield.svg" + height: cellHeight * 0.75 + fillMode: Image.PreserveAspectFit + mipmap: true + smooth: true + cache: false + visible: isMessageImportant + anchors.verticalCenter: parent.verticalCenter + anchors.horizontalCenter: parent.horizontalCenter + } + SequentialAnimation { + id: loopAnimation + loops: Animation.Infinite + NumberAnimation { target: criticalMessage; property: "opacity"; duration: 1000; from: 0.25; to: 1 } + NumberAnimation { target: criticalMessage; property: "opacity"; duration: 1000; from: 1; to: 0.25 } + } + onVisibleChanged: { + if(messages.visible) { + loopAnimation.start() + } else { + loopAnimation.stop() + } + } + } + + Item { + anchors.fill: parent + visible: !criticalMessage.visible + Image { + id: messageIcon + source: "/qmlimages/Megaphone.svg" + height: cellHeight * 0.5 + fillMode: Image.PreserveAspectFit + mipmap: true + smooth: true + visible: false + anchors.verticalCenter: parent.verticalCenter + anchors.horizontalCenter: parent.horizontalCenter + } + ColorOverlay { + anchors.fill: messageIcon + source: messageIcon + color: getMessageColor() + } + } + + MouseArea { + anchors.fill: parent + onClicked: { + var p = mapToItem(toolBar, mouseX, mouseY); + _controller.onEnterMessageArea(p.x, p.y); + } + } + } + + //------------------------------------------------------------------------- + //-- GPS Indicator + Item { + id: satelitte + width: gpsRow.width * 1.1 + height: cellHeight + Row { + id: gpsRow + height: parent.height + Image { + id: gpsIcon + source: "/qmlimages/Gps.svg" + fillMode: Image.PreserveAspectFit + mipmap: true + smooth: true + width: cellHeight * 0.65 + height: cellHeight * 0.5 + opacity: activeVehicle.satelliteCount < 1 ? 0.5 : 1 + anchors.verticalCenter: parent.verticalCenter + } + SignalStrength { + size: cellHeight * 0.5 + percent: getSatStrength(activeVehicle.satelliteCount) + anchors.verticalCenter: parent.verticalCenter + } + } + QGCLabel { + text: activeVehicle.satelliteCount + font.pixelSize: tbFontSmall + color: colorWhite + opacity: activeVehicle.satelliteCount < 1 ? 0.5 : 1 + anchors.top: parent.top + anchors.leftMargin: gpsIcon.width + anchors.left: parent.left + } + } + + //------------------------------------------------------------------------- + //-- RC RSSI + Item { + id: rcRssi + width: rssiRow.width * 1.1 + height: cellHeight + Row { + id: rssiRow + height: parent.height + Image { + source: "/qmlimages/RC.svg" + fillMode: Image.PreserveAspectFit + mipmap: true + smooth: true + width: cellHeight * 0.65 + height: cellHeight * 0.5 + opacity: _controller.remoteRSSI < 1 ? 0.5 : 1 + anchors.verticalCenter: parent.verticalCenter + } + SignalStrength { + size: cellHeight * 0.5 + percent: _controller.remoteRSSI + anchors.verticalCenter: parent.verticalCenter + } + } + } + + //------------------------------------------------------------------------- + //-- Battery Indicator + Item { + id: batteryStatus + width: battRow.width * 1.1 + height: cellHeight + opacity: (activeVehicle.batteryVoltage > 0) ? 1 : 0.5 + Row { + id: battRow + height: cellHeight + spacing: tbSpacing + anchors.horizontalCenter: parent.horizontalCenter + Column { + spacing: tbSpacing * 0.5 + anchors.verticalCenter: parent.verticalCenter + Image { + id: batIcon + source: "/qmlimages/Battery.svg" + fillMode: Image.PreserveAspectFit + mipmap: true + smooth: true + height: batPercent.height * 0.85 + anchors.horizontalCenter: parent.horizontalCenter + } + QGCLabel { + text: (activeVehicle.batteryConsumed > 0) ? activeVehicle.batteryConsumed.toFixed(0) + 'mAh' : 'N/A'; + font.pixelSize: tbFontSmall + color: getBatteryColor() + visible: QGroundControl.isAdvancedMode + anchors.horizontalCenter: parent.horizontalCenter + } + } + Column { + anchors.verticalCenter: parent.verticalCenter + QGCLabel { + id: batPercent + text: getBatteryPercentageText() + font.pixelSize: tbFontLarge + color: getBatteryColor() + anchors.horizontalCenter: parent.horizontalCenter + } + QGCLabel { + text: getBatteryVoltageText() + font.pixelSize: tbFontNormal + color: getBatteryColor() + anchors.horizontalCenter: parent.horizontalCenter + } + } + } + } + + //------------------------------------------------------------------------- + //-- Vehicle Selector + QGCButton { + width: ScreenTools.defaultFontPixelSize * 12 + height: cellHeight * 0.75 + text: "Vehicle " + activeVehicle.id + visible: vehicleMenuItems.length > 0 + anchors.verticalCenter: parent.verticalCenter + + menu: vehicleMenu + + Menu { + id: vehicleMenu + } + + Component { + id: vehicleMenuItemComponent + + MenuItem { + checkable: true + checked: vehicle.active + onTriggered: multiVehicleManager.activeVehicle = vehicle + + property int vehicleId: Number(text.split(" ")[1]) + property var vehicle: multiVehicleManager.getVehicleById(vehicleId) + } + } + + property var vehicleMenuItems: [] + + function updateVehicleMenu() { + // Remove old menu items + for (var i = 0; i < vehicleMenuItems.length; i++) { + vehicleMenu.removeItem(vehicleMenuItems[i]) + } + vehicleMenuItems.length = 0 + + // Add new items + for (var i=0; i 0) && (_controller.telemetryLRSSI > 0) + anchors.verticalCenter: parent.verticalCenter + color: getRSSIColor(Math.min(_controller.telemetryRRSSI,_controller.telemetryLRSSI)); + border.color: "#00000000" + border.width: 0 + Image { + source: "qrc:/res/AntennaT"; + width: cellHeight * 0.7 + fillMode: Image.PreserveAspectFit + anchors.verticalCenter: parent.verticalCenter + anchors.left: parent.left + anchors.leftMargin: getProportionalDimmension(6) + mipmap: true + smooth: true + } + Column { + anchors.verticalCenter: parent.verticalCenter + anchors.right: parent.right + anchors.rightMargin: getProportionalDimmension(6) + Row { + anchors.right: parent.right + QGCLabel { + text: 'R ' + font.pixelSize: ScreenTools.smallFontPixelSize + font.weight: Font.DemiBold + color: colorWhite + } + QGCLabel { + text: _controller.telemetryRRSSI + 'dB' + width: getProportionalDimmension(30) + horizontalAlignment: Text.AlignRight + font.pixelSize: ScreenTools.smallFontPixelSize + font.weight: Font.DemiBold + color: colorWhite + } + } + Row { + anchors.right: parent.right + QGCLabel { + text: 'L ' + font.pixelSize: ScreenTools.smallFontPixelSize + font.weight: Font.DemiBold + color: colorWhite + } + QGCLabel { + text: _controller.telemetryLRSSI + 'dB' + width: getProportionalDimmension(30) + horizontalAlignment: Text.AlignRight + font.pixelSize: ScreenTools.smallFontPixelSize + font.weight: Font.DemiBold + color: colorWhite + } + } + } + } + + +*/ + +} // Row diff --git a/src/ui/toolbar/SignalStrength.qml b/src/ui/toolbar/SignalStrength.qml new file mode 100644 index 000000000..d7e9c258f --- /dev/null +++ b/src/ui/toolbar/SignalStrength.qml @@ -0,0 +1,59 @@ +/*===================================================================== + +QGroundControl Open Source Ground Control Station + +(c) 2009, 2015 QGROUNDCONTROL PROJECT + +This file is part of the QGROUNDCONTROL project + + QGROUNDCONTROL is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + QGROUNDCONTROL is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with QGROUNDCONTROL. If not, see . + +======================================================================*/ + +/** + * @file + * @brief QGC Main Tool Signal Strength + * @author Gus Grubba + */ + +import QtQuick 2.4 +import QGroundControl.Controls 1.0 + +Item { + id: signalRoot + property real size: 50 + property real percent: 0 + width: size + height: size + function getIcon() { + if (percent < 20) + return "/qmlimages/Signal0.svg" + if (percent < 40) + return "/qmlimages/Signal20.svg" + if (percent < 60) + return "/qmlimages/Signal40.svg" + if (percent < 80) + return "/qmlimages/Signal60.svg" + if (percent < 100) + return "/qmlimages/Signal80.svg" + return "/qmlimages/Signal100.svg" + } + Image { + source: getIcon() + fillMode: Image.PreserveAspectFit + mipmap: true + smooth: true + anchors.fill: parent + } +} -- 2.22.0