From 719931c5f531c35c6aff7d8314dd2647e2c47816 Mon Sep 17 00:00:00 2001 From: Pierre TILAK Date: Mon, 15 Jul 2019 14:15:04 +1200 Subject: [PATCH] Add setting to enable COG/HOME Compass --- src/FlightMap/Widgets/QGCCompassWidget.qml | 29 ++++++++++++++-------- src/Settings/FlyView.SettingsGroup.json | 12 +++++++++ src/Settings/FlyViewSettings.cc | 2 ++ src/Settings/FlyViewSettings.h | 2 ++ src/ui/preferences/GeneralSettings.qml | 15 +++++++++++ 5 files changed, 50 insertions(+), 10 deletions(-) diff --git a/src/FlightMap/Widgets/QGCCompassWidget.qml b/src/FlightMap/Widgets/QGCCompassWidget.qml index f5725662a..d3036a034 100644 --- a/src/FlightMap/Widgets/QGCCompassWidget.qml +++ b/src/FlightMap/Widgets/QGCCompassWidget.qml @@ -17,10 +17,11 @@ import QtQuick 2.3 import QtGraphicalEffects 1.0 -import QGroundControl.Controls 1.0 -import QGroundControl.ScreenTools 1.0 -import QGroundControl.Vehicle 1.0 -import QGroundControl.Palette 1.0 +import QGroundControl 1.0 +import QGroundControl.Controls 1.0 +import QGroundControl.ScreenTools 1.0 +import QGroundControl.Vehicle 1.0 +import QGroundControl.Palette 1.0 Item { id: root @@ -37,6 +38,9 @@ Item { property real _headingToHome: vehicle ? vehicle.headingToHome.rawValue : 0 property real _courseOverGround:activeVehicle ? activeVehicle.gps.courseOverGround.rawValue : 0 + readonly property bool _showHomeHeadingCompass: QGroundControl.settingsManager.flyViewSettings.showHomeHeadingCompass.value + readonly property bool _showCOGAngleCompass: QGroundControl.settingsManager.flyViewSettings.showCOGAngleCompass.value + QGCPalette { id: qgcPal; colorGroupEnabled: enabled } @@ -67,11 +71,12 @@ Item { Image { id: homePointer width: size * 0.1 - source: "/qmlimages/Home.svg" + source: _showHomeHeadingCompass ? "/qmlimages/Home.svg" : "" mipmap: true fillMode: Image.PreserveAspectFit anchors.centerIn: parent sourceSize.width: width + visible: _showHomeHeadingCompass transform: Translate { x: size/2.3 * Math.sin((-_heading + _headingToHome)*(3.14/180)) @@ -95,17 +100,21 @@ Item { } Image { - function f(){ - console.log(_heading -_courseOverGround) - } - property double test: f() id: cOGPointer - source: "/qmlimages/attitudePointer.svg" + source: _showCOGAngleCompass ? "/qmlimages/attitudePointer.svg" : "" mipmap: true fillMode: Image.PreserveAspectFit anchors.fill: parent sourceSize.height: parent.height + onVisibleChanged: { + if (visible) + console.log("is being displayed") + else + console.log("is being hidden") + } + + transform: Rotation { origin.x: cOGPointer.width / 2 origin.y: cOGPointer.height / 2 diff --git a/src/Settings/FlyView.SettingsGroup.json b/src/Settings/FlyView.SettingsGroup.json index ec456ebdf..cc755ba7c 100644 --- a/src/Settings/FlyView.SettingsGroup.json +++ b/src/Settings/FlyView.SettingsGroup.json @@ -24,5 +24,17 @@ "shortDescription": "Use Vertical Instrument Panel instead of the default one", "type": "bool", "defaultValue": false +}, +{ + "name": "showHomeHeadingCompass", + "shortDescription": "Show/Hide Home heading on the Compass", + "type": "bool", + "defaultValue": false +}, +{ + "name": "showCOGAngleCompass", + "shortDescription": "Show/Hide Course Over Ground angle on the Compass", + "type": "bool", + "defaultValue": false } ] diff --git a/src/Settings/FlyViewSettings.cc b/src/Settings/FlyViewSettings.cc index 2d3d1f8fa..39e32b7fb 100644 --- a/src/Settings/FlyViewSettings.cc +++ b/src/Settings/FlyViewSettings.cc @@ -21,3 +21,5 @@ DECLARE_SETTINGSFACT(FlyViewSettings, guidedMinimumAltitude) DECLARE_SETTINGSFACT(FlyViewSettings, guidedMaximumAltitude) DECLARE_SETTINGSFACT(FlyViewSettings, showLogReplayStatusBar) DECLARE_SETTINGSFACT(FlyViewSettings, alternateInstrumentPanel) +DECLARE_SETTINGSFACT(FlyViewSettings, showHomeHeadingCompass) +DECLARE_SETTINGSFACT(FlyViewSettings, showCOGAngleCompass) diff --git a/src/Settings/FlyViewSettings.h b/src/Settings/FlyViewSettings.h index ee12163b2..09956aa5c 100644 --- a/src/Settings/FlyViewSettings.h +++ b/src/Settings/FlyViewSettings.h @@ -23,4 +23,6 @@ public: DEFINE_SETTINGFACT(guidedMaximumAltitude) DEFINE_SETTINGFACT(showLogReplayStatusBar) DEFINE_SETTINGFACT(alternateInstrumentPanel) + DEFINE_SETTINGFACT(showHomeHeadingCompass) + DEFINE_SETTINGFACT(showCOGAngleCompass) }; diff --git a/src/ui/preferences/GeneralSettings.qml b/src/ui/preferences/GeneralSettings.qml index eda8d14c3..1fdd4fd06 100644 --- a/src/ui/preferences/GeneralSettings.qml +++ b/src/ui/preferences/GeneralSettings.qml @@ -475,6 +475,21 @@ Rectangle { property Fact _alternateInstrumentPanel: QGroundControl.settingsManager.flyViewSettings.alternateInstrumentPanel } + FactCheckBox { + text: qsTr("Show/Hide Home heading on the Compass") + visible: _showHomeHeadingCompass.visible + fact: _showHomeHeadingCompass + + property Fact _showHomeHeadingCompass: QGroundControl.settingsManager.flyViewSettings.showHomeHeadingCompass + } + FactCheckBox { + text: qsTr("Show/Hide Course Over Ground angle on the Compass") + visible: _showCOGAngleCompass.visible + fact: _showCOGAngleCompass + + property Fact _showCOGAngleCompass: QGroundControl.settingsManager.flyViewSettings.showCOGAngleCompass + } + GridLayout { columns: 2 -- 2.22.0