From fe60f712b1aa689e26a346d427e5d0758864cf64 Mon Sep 17 00:00:00 2001 From: dogmaphobic Date: Tue, 27 Oct 2015 12:54:15 -0400 Subject: [PATCH 1/4] More work on the Fly View --- src/FlightDisplay/FlightDisplayViewWidgets.qml | 6 +- src/FlightMap/Images/compassInstrumentDial.svg | 149 +++++++++++++------------ src/FlightMap/Widgets/QGCCompassWidget.qml | 4 +- src/FlightMap/Widgets/QGCInstrumentWidget.qml | 129 ++++++++++++++++++--- 4 files changed, 197 insertions(+), 91 deletions(-) diff --git a/src/FlightDisplay/FlightDisplayViewWidgets.qml b/src/FlightDisplay/FlightDisplayViewWidgets.qml index eb3dae4..b5d534d 100644 --- a/src/FlightDisplay/FlightDisplayViewWidgets.qml +++ b/src/FlightDisplay/FlightDisplayViewWidgets.qml @@ -77,13 +77,17 @@ Item { //-- Instrument Pannel QGCInstrumentWidget { anchors.margins: ScreenTools.defaultFontPixelHeight - anchors.bottom: parent.bottom anchors.right: parent.right + anchors.bottom: parent.bottom size: ScreenTools.defaultFontPixelSize * (9) active: _activeVehicle != null heading: _heading rollAngle: _roll pitchAngle: _pitch + altitude: _altitudeWGS84 + groundSpeed: _groundSpeed + airSpeed: _airSpeed + climbRate: _climbRate isSatellite: _mainIsMap ? _flightMap ? _flightMap.isSatelliteMap : true : true z: QGroundControl.zOrderWidgets } diff --git a/src/FlightMap/Images/compassInstrumentDial.svg b/src/FlightMap/Images/compassInstrumentDial.svg index f265280..dbef2e0 100644 --- a/src/FlightMap/Images/compassInstrumentDial.svg +++ b/src/FlightMap/Images/compassInstrumentDial.svg @@ -1,84 +1,87 @@ - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + viewBox="-161 253 288 288" enable-background="new -161 253 288 288" xml:space="preserve"> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - + - + - + - - - - + + + + diff --git a/src/FlightMap/Widgets/QGCCompassWidget.qml b/src/FlightMap/Widgets/QGCCompassWidget.qml index 251acc9..28fc249 100644 --- a/src/FlightMap/Widgets/QGCCompassWidget.qml +++ b/src/FlightMap/Widgets/QGCCompassWidget.qml @@ -49,9 +49,7 @@ Item { id: borderRect anchors.fill: parent radius: width / 2 - color: "#202020" - border.color: "black" - border.width: 2 + color: "black" } Item { diff --git a/src/FlightMap/Widgets/QGCInstrumentWidget.qml b/src/FlightMap/Widgets/QGCInstrumentWidget.qml index c7d3bc2..0789e3b 100644 --- a/src/FlightMap/Widgets/QGCInstrumentWidget.qml +++ b/src/FlightMap/Widgets/QGCInstrumentWidget.qml @@ -39,7 +39,10 @@ Item { property alias heading: compass.heading property alias rollAngle: attitude.rollAngle property alias pitchAngle: attitude.pitchAngle - + property real altitude: 0 + property real groundSpeed: 0 + property real airSpeed: 0 + property real climbRate: 0 property real size: ScreenTools.defaultFontPixelSize * (10) property bool isSatellite: false property bool active: false @@ -49,29 +52,127 @@ Item { //-- Instrument Pannel Rectangle { id: instrumentPannel - anchors.right: parent.right - anchors.bottom: parent.bottom - height: root.size - width: instruments.width + ScreenTools.defaultFontPixelSize + height: instruments.height + ScreenTools.defaultFontPixelSize + width: root.size radius: root.size / 2 visible: _isVisible - color: isSatellite ? Qt.rgba(1,1,1,0.5) : Qt.rgba(0,0,0,0.5) - Row { + color: isSatellite ? Qt.rgba(1,1,1,0.75) : Qt.rgba(0,0,0,0.75) + anchors.right: parent.right + anchors.bottom: parent.bottom + Column { id: instruments - height: parent.height - spacing: ScreenTools.defaultFontPixelSize / 2 - anchors.horizontalCenter: parent.horizontalCenter + width: parent.width + spacing: ScreenTools.defaultFontPixelSize * 0.33 + anchors.verticalCenter: parent.verticalCenter + //-- Attitude Indicator QGCAttitudeWidget { id: attitude - size: parent.height * 0.9 + size: parent.width * 0.9 active: root.active - anchors.verticalCenter: parent.verticalCenter + anchors.horizontalCenter: parent.horizontalCenter + } + //-- Altitude + Rectangle { + height: 1 + width: parent.width * 0.9 + color: isSatellite ? Qt.rgba(0,0,0,0.25) : Qt.rgba(1,1,1,0.25) + anchors.horizontalCenter: parent.horizontalCenter + } + Row { + width: root.size * 0.8 + anchors.horizontalCenter: parent.horizontalCenter + QGCLabel { + text: "H" + width: parent.width * 0.45 + color: isSatellite ? "black" : "white" + horizontalAlignment: TextEdit.AlignHCenter + } + QGCLabel { + text: altitude + font.weight: Font.DemiBold + color: isSatellite ? "black" : "white" + } + } + //-- Ground Speed + Rectangle { + height: 1 + width: parent.width * 0.9 + color: isSatellite ? Qt.rgba(0,0,0,0.25) : Qt.rgba(1,1,1,0.25) + anchors.horizontalCenter: parent.horizontalCenter + } + Row { + width: root.size * 0.8 + anchors.horizontalCenter: parent.horizontalCenter + QGCLabel { + text: "GS" + width: parent.width * 0.45 + color: isSatellite ? "black" : "white" + horizontalAlignment: TextEdit.AlignHCenter + } + QGCLabel { + text: groundSpeed + font.weight: Font.DemiBold + color: isSatellite ? "black" : "white" + } + } + //-- Air Speed + Rectangle { + height: 1 + width: parent.width * 0.9 + color: isSatellite ? Qt.rgba(0,0,0,0.25) : Qt.rgba(1,1,1,0.25) + anchors.horizontalCenter: parent.horizontalCenter + visible: airSpeed > 0 + } + Row { + width: root.size * 0.8 + anchors.horizontalCenter: parent.horizontalCenter + visible: airSpeed > 0 + QGCLabel { + text: "AS" + width: parent.width * 0.45 + color: isSatellite ? "black" : "white" + horizontalAlignment: TextEdit.AlignHCenter + } + QGCLabel { + text: airSpeed + font.weight: Font.DemiBold + color: isSatellite ? "black" : "white" + } + } + //-- Climb Rate + Rectangle { + height: 1 + width: parent.width * 0.9 + color: isSatellite ? Qt.rgba(0,0,0,0.25) : Qt.rgba(1,1,1,0.25) + anchors.horizontalCenter: parent.horizontalCenter + } + Row { + width: root.size * 0.8 + anchors.horizontalCenter: parent.horizontalCenter + QGCLabel { + text: "VS" + width: parent.width * 0.45 + color: isSatellite ? "black" : "white" + horizontalAlignment: TextEdit.AlignHCenter + } + QGCLabel { + text: climbRate + font.weight: Font.DemiBold + color: isSatellite ? "black" : "white" + } + } + //-- Compass + Rectangle { + height: 1 + width: parent.width * 0.9 + color: isSatellite ? Qt.rgba(0,0,0,0.25) : Qt.rgba(1,1,1,0.25) + anchors.horizontalCenter: parent.horizontalCenter } QGCCompassWidget { id: compass - size: parent.height * 0.9 + size: parent.width * 0.9 active: root.active - anchors.verticalCenter: parent.verticalCenter + anchors.horizontalCenter: parent.horizontalCenter } } MouseArea { From 8a9f0c1ae3c2107e3de4118155c89d5050af633e Mon Sep 17 00:00:00 2001 From: dogmaphobic Date: Tue, 27 Oct 2015 13:15:01 -0400 Subject: [PATCH 2/4] Controls work better aesthetically when centered on the screen. --- src/FlightDisplay/FlightDisplayViewWidgets.qml | 30 ++++++++++++------------ src/FlightMap/Widgets/QGCInstrumentWidget.qml | 32 +++++++++++++------------- 2 files changed, 31 insertions(+), 31 deletions(-) diff --git a/src/FlightDisplay/FlightDisplayViewWidgets.qml b/src/FlightDisplay/FlightDisplayViewWidgets.qml index b5d534d..d2d9a9a 100644 --- a/src/FlightDisplay/FlightDisplayViewWidgets.qml +++ b/src/FlightDisplay/FlightDisplayViewWidgets.qml @@ -76,20 +76,20 @@ Item { //-- Instrument Pannel QGCInstrumentWidget { - anchors.margins: ScreenTools.defaultFontPixelHeight - anchors.right: parent.right - anchors.bottom: parent.bottom - size: ScreenTools.defaultFontPixelSize * (9) - active: _activeVehicle != null - heading: _heading - rollAngle: _roll - pitchAngle: _pitch - altitude: _altitudeWGS84 - groundSpeed: _groundSpeed - airSpeed: _airSpeed - climbRate: _climbRate - isSatellite: _mainIsMap ? _flightMap ? _flightMap.isSatelliteMap : true : true - z: QGroundControl.zOrderWidgets + anchors.margins: ScreenTools.defaultFontPixelHeight + anchors.right: parent.right + anchors.verticalCenter: parent.verticalCenter + size: ScreenTools.defaultFontPixelSize * (9) + active: _activeVehicle != null + heading: _heading + rollAngle: _roll + pitchAngle: _pitch + altitude: _altitudeWGS84 + groundSpeed: _groundSpeed + airSpeed: _airSpeed + climbRate: _climbRate + isSatellite: _mainIsMap ? _flightMap ? _flightMap.isSatelliteMap : true : true + z: QGroundControl.zOrderWidgets } //-- Vertical Tool Buttons @@ -97,7 +97,7 @@ Item { id: toolColumn anchors.margins: ScreenTools.defaultFontPixelHeight anchors.left: parent.left - anchors.top: parent.top + anchors.verticalCenter: parent.verticalCenter spacing: ScreenTools.defaultFontPixelHeight //-- Map Center Control diff --git a/src/FlightMap/Widgets/QGCInstrumentWidget.qml b/src/FlightMap/Widgets/QGCInstrumentWidget.qml index 0789e3b..869094f 100644 --- a/src/FlightMap/Widgets/QGCInstrumentWidget.qml +++ b/src/FlightMap/Widgets/QGCInstrumentWidget.qml @@ -51,14 +51,14 @@ Item { //-- Instrument Pannel Rectangle { - id: instrumentPannel - height: instruments.height + ScreenTools.defaultFontPixelSize - width: root.size - radius: root.size / 2 - visible: _isVisible - color: isSatellite ? Qt.rgba(1,1,1,0.75) : Qt.rgba(0,0,0,0.75) - anchors.right: parent.right - anchors.bottom: parent.bottom + id: instrumentPannel + height: instruments.height + ScreenTools.defaultFontPixelSize + width: root.size + radius: root.size / 2 + visible: _isVisible + color: isSatellite ? Qt.rgba(1,1,1,0.75) : Qt.rgba(0,0,0,0.75) + anchors.right: parent.right + anchors.verticalCenter: parent.verticalCenter Column { id: instruments width: parent.width @@ -185,14 +185,14 @@ Item { //-- Show Instruments Rectangle { - id: openButton - anchors.right: parent.right - anchors.bottom: parent.bottom - height: ScreenTools.defaultFontPixelSize * 2 - width: ScreenTools.defaultFontPixelSize * 2 - radius: ScreenTools.defaultFontPixelSize / 3 - visible: !_isVisible - color: isSatellite ? Qt.rgba(1,1,1,0.5) : Qt.rgba(0,0,0,0.5) + id: openButton + anchors.right: parent.right + anchors.verticalCenter: parent.verticalCenter + height: ScreenTools.defaultFontPixelSize * 2 + width: ScreenTools.defaultFontPixelSize * 2 + radius: ScreenTools.defaultFontPixelSize / 3 + visible: !_isVisible + color: isSatellite ? 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 From f26504f525412d8139e6569496ac26139545310c Mon Sep 17 00:00:00 2001 From: dogmaphobic Date: Tue, 27 Oct 2015 13:53:21 -0400 Subject: [PATCH 3/4] Saving and Restoring "Map Is Main" --- src/FlightDisplay/FlightDisplayView.qml | 4 ++- src/FlightMap/Widgets/QGCInstrumentWidget.qml | 8 ++--- src/QmlControls/QGroundControlQmlGlobal.cc | 44 ++++++++++++++++++++++----- src/QmlControls/QGroundControlQmlGlobal.h | 5 +++ 4 files changed, 49 insertions(+), 12 deletions(-) diff --git a/src/FlightDisplay/FlightDisplayView.qml b/src/FlightDisplay/FlightDisplayView.qml index 0265d17..26efdb2 100644 --- a/src/FlightDisplay/FlightDisplayView.qml +++ b/src/FlightDisplay/FlightDisplayView.qml @@ -56,8 +56,9 @@ Item { readonly property string _mapName: "FlightDisplayView" readonly property string _showMapBackgroundKey: "/showMapBackground" + readonly property string _mainIsMapKey: "MainFlyWindowIsMap" - property bool _mainIsMap: !_controller.hasVideo + property bool _mainIsMap: QGroundControl.loadBoolGlobalSetting(_mainIsMapKey, true) property real _roll: _activeVehicle ? (isNaN(_activeVehicle.roll) ? _defaultRoll : _activeVehicle.roll) : _defaultRoll property real _pitch: _activeVehicle ? (isNaN(_activeVehicle.pitch) ? _defaultPitch : _activeVehicle.pitch) : _defaultPitch @@ -158,6 +159,7 @@ Item { _mainIsMap = !_mainIsMap pip.visible = false reloadContents(); + QGroundControl.saveBoolGlobalSetting(_mainIsMapKey, _mainIsMap) } } } diff --git a/src/FlightMap/Widgets/QGCInstrumentWidget.qml b/src/FlightMap/Widgets/QGCInstrumentWidget.qml index 869094f..3e7b833 100644 --- a/src/FlightMap/Widgets/QGCInstrumentWidget.qml +++ b/src/FlightMap/Widgets/QGCInstrumentWidget.qml @@ -88,7 +88,7 @@ Item { horizontalAlignment: TextEdit.AlignHCenter } QGCLabel { - text: altitude + text: altitude.toFixed(1) font.weight: Font.DemiBold color: isSatellite ? "black" : "white" } @@ -110,7 +110,7 @@ Item { horizontalAlignment: TextEdit.AlignHCenter } QGCLabel { - text: groundSpeed + text: groundSpeed.toFixed(1) font.weight: Font.DemiBold color: isSatellite ? "black" : "white" } @@ -134,7 +134,7 @@ Item { horizontalAlignment: TextEdit.AlignHCenter } QGCLabel { - text: airSpeed + text: airSpeed.toFixed(1) font.weight: Font.DemiBold color: isSatellite ? "black" : "white" } @@ -156,7 +156,7 @@ Item { horizontalAlignment: TextEdit.AlignHCenter } QGCLabel { - text: climbRate + text: climbRate.toFixed(1) font.weight: Font.DemiBold color: isSatellite ? "black" : "white" } diff --git a/src/QmlControls/QGroundControlQmlGlobal.cc b/src/QmlControls/QGroundControlQmlGlobal.cc index 8912f37..a9f26fb 100644 --- a/src/QmlControls/QGroundControlQmlGlobal.cc +++ b/src/QmlControls/QGroundControlQmlGlobal.cc @@ -1,24 +1,24 @@ /*===================================================================== - + QGroundControl Open Source Ground Control Station - + (c) 2009 - 2014 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 @@ -26,6 +26,8 @@ #include "QGroundControlQmlGlobal.h" +static const char* kQmlGlobalKeyName = "QGCQml"; + QGroundControlQmlGlobal::QGroundControlQmlGlobal(QObject* parent) : QObject(parent) , _homePositionManager(HomePositionManager::instance()) @@ -38,3 +40,31 @@ QGroundControlQmlGlobal::~QGroundControlQmlGlobal() { } + +void QGroundControlQmlGlobal::saveGlobalSetting (const QString& key, const QString& value) +{ + QSettings settings; + settings.beginGroup(kQmlGlobalKeyName); + settings.setValue(key, value); +} + +QString QGroundControlQmlGlobal::loadGlobalSetting (const QString& key, const QString& defaultValue) +{ + QSettings settings; + settings.beginGroup(kQmlGlobalKeyName); + return settings.value(key, defaultValue).toString(); +} + +void QGroundControlQmlGlobal::saveBoolGlobalSetting (const QString& key, bool value) +{ + QSettings settings; + settings.beginGroup(kQmlGlobalKeyName); + settings.setValue(key, value); +} + +bool QGroundControlQmlGlobal::loadBoolGlobalSetting (const QString& key, bool defaultValue) +{ + QSettings settings; + settings.beginGroup(kQmlGlobalKeyName); + return settings.value(key, defaultValue).toBool(); +} diff --git a/src/QmlControls/QGroundControlQmlGlobal.h b/src/QmlControls/QGroundControlQmlGlobal.h index 3a12605..5265521 100644 --- a/src/QmlControls/QGroundControlQmlGlobal.h +++ b/src/QmlControls/QGroundControlQmlGlobal.h @@ -47,6 +47,11 @@ 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 + 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); + Q_INVOKABLE bool loadBoolGlobalSetting (const QString& key, bool defaultValue); + // Property accesors HomePositionManager* homePositionManager () { return _homePositionManager; } From f8a869f80b35b9ea6693b2e8efce5e3cab640bd6 Mon Sep 17 00:00:00 2001 From: dogmaphobic Date: Tue, 27 Oct 2015 14:13:58 -0400 Subject: [PATCH 4/4] Making Altitude text Larger than the rest. --- src/FlightMap/Widgets/QGCInstrumentWidget.qml | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/FlightMap/Widgets/QGCInstrumentWidget.qml b/src/FlightMap/Widgets/QGCInstrumentWidget.qml index 3e7b833..329dfd7 100644 --- a/src/FlightMap/Widgets/QGCInstrumentWidget.qml +++ b/src/FlightMap/Widgets/QGCInstrumentWidget.qml @@ -83,14 +83,18 @@ Item { anchors.horizontalCenter: parent.horizontalCenter QGCLabel { text: "H" + font.pixelSize: ScreenTools.defaultFontPixelSize * 1.25 width: parent.width * 0.45 color: isSatellite ? "black" : "white" horizontalAlignment: TextEdit.AlignHCenter } QGCLabel { text: altitude.toFixed(1) + font.pixelSize: ScreenTools.defaultFontPixelSize * 1.25 font.weight: Font.DemiBold + width: parent.width * 0.549 color: isSatellite ? "black" : "white" + horizontalAlignment: TextEdit.AlignHCenter } } //-- Ground Speed @@ -105,14 +109,18 @@ Item { anchors.horizontalCenter: parent.horizontalCenter QGCLabel { text: "GS" + font.pixelSize: ScreenTools.defaultFontPixelSize * 0.75 width: parent.width * 0.45 color: isSatellite ? "black" : "white" horizontalAlignment: TextEdit.AlignHCenter } QGCLabel { text: groundSpeed.toFixed(1) + font.pixelSize: ScreenTools.defaultFontPixelSize * 0.75 font.weight: Font.DemiBold + width: parent.width * 0.549 color: isSatellite ? "black" : "white" + horizontalAlignment: TextEdit.AlignHCenter } } //-- Air Speed @@ -129,14 +137,18 @@ Item { visible: airSpeed > 0 QGCLabel { text: "AS" + font.pixelSize: ScreenTools.defaultFontPixelSize * 0.75 width: parent.width * 0.45 color: isSatellite ? "black" : "white" horizontalAlignment: TextEdit.AlignHCenter } QGCLabel { text: airSpeed.toFixed(1) + font.pixelSize: ScreenTools.defaultFontPixelSize * 0.75 font.weight: Font.DemiBold + width: parent.width * 0.549 color: isSatellite ? "black" : "white" + horizontalAlignment: TextEdit.AlignHCenter } } //-- Climb Rate @@ -151,14 +163,18 @@ Item { anchors.horizontalCenter: parent.horizontalCenter QGCLabel { text: "VS" + font.pixelSize: ScreenTools.defaultFontPixelSize * 0.75 width: parent.width * 0.45 color: isSatellite ? "black" : "white" horizontalAlignment: TextEdit.AlignHCenter } QGCLabel { text: climbRate.toFixed(1) + font.pixelSize: ScreenTools.defaultFontPixelSize * 0.75 font.weight: Font.DemiBold + width: parent.width * 0.549 color: isSatellite ? "black" : "white" + horizontalAlignment: TextEdit.AlignHCenter } } //-- Compass