From 3e4843f6a0d94468c692069dbac7a497fe81c55d Mon Sep 17 00:00:00 2001 From: Pierre TILAK <pierre.tilak@aeronavics.com> Date: Tue, 9 Jul 2019 17:48:36 +1200 Subject: [PATCH 1/6] Restore old Instrument Widget Layout The instrument widget layout is now a stack of : - QGCAttitudeWidget - Item that contain ValuesWidget - QGCCompassWidget --- .../Widgets/QGCInstrumentWidgetAlternate.qml | 38 ++++++++++++---------- 1 file changed, 21 insertions(+), 17 deletions(-) diff --git a/src/FlightMap/Widgets/QGCInstrumentWidgetAlternate.qml b/src/FlightMap/Widgets/QGCInstrumentWidgetAlternate.qml index 71df61a..4ab4eba 100644 --- a/src/FlightMap/Widgets/QGCInstrumentWidgetAlternate.qml +++ b/src/FlightMap/Widgets/QGCInstrumentWidgetAlternate.qml @@ -20,13 +20,13 @@ import QGroundControl.Palette 1.0 Rectangle { id: root width: getPreferredInstrumentWidth() - height: _outerRadius * 2 + height: _outerRadius * 4 + _valuesWidget.height radius: _outerRadius color: qgcPal.window border.width: 1 border.color: _isSatellite ? qgcPal.mapWidgetBorderLight : qgcPal.mapWidgetBorderDark - property real _innerRadius: (width - (_topBottomMargin * 3)) / 4 + property real _innerRadius: (width - (_topBottomMargin * 2)) / 2 property real _outerRadius: _innerRadius + _topBottomMargin property real _defaultSize: ScreenTools.defaultFontPixelHeight * (9) property real _sizeRatio: ScreenTools.isTinyScreen ? (width / _defaultSize) * 0.5 : width / _defaultSize @@ -45,27 +45,21 @@ Rectangle { QGCPalette { id: qgcPal } QGCAttitudeWidget { - id: attitude - anchors.leftMargin: _topBottomMargin - anchors.left: parent.left - size: _innerRadius * 2 - vehicle: activeVehicle - anchors.verticalCenter: parent.verticalCenter + id: attitude + anchors.topMargin : _topBottomMargin + anchors.bottomMargin: _topBottomMargin + anchors.top: parent.top + size: _innerRadius * 2 + vehicle: activeVehicle + anchors.horizontalCenter: parent.horizontalCenter } - QGCCompassWidget { - id: compass - anchors.leftMargin: _spacing - anchors.left: attitude.right - size: _innerRadius * 2 - vehicle: activeVehicle - anchors.verticalCenter: parent.verticalCenter - } Item { id: _valuesItem anchors.topMargin: ScreenTools.defaultFontPixelHeight / 4 - anchors.top: parent.bottom + anchors.top: attitude.bottom + anchors.bottom: compass.top width: parent.width height: _valuesWidget.height visible: widgetRoot.showValues @@ -88,4 +82,14 @@ Rectangle { maxHeight: _availableValueHeight } } + + QGCCompassWidget { + id: compass + anchors.bottom : parent.bottom + anchors.bottomMargin: _topBottomMargin + anchors.topMargin: _topBottomMargin + size: _innerRadius * 2 + vehicle: activeVehicle + anchors.horizontalCenter: parent.horizontalCenter + } } From 2c303d69d8c24cf7a1c0edc7cef04ce09b0f67d1 Mon Sep 17 00:00:00 2001 From: Pierre TILAK <pierre.tilak@aeronavics.com> Date: Tue, 9 Jul 2019 18:16:32 +1200 Subject: [PATCH 2/6] Put new InstrumentWidget in QGCInstrumentWidget - Rename QGCInstrumentWidgetAlternate to QGCInstrumentWidget as it's now the default version - Select QGCInstrumentWidget as instrumentLoader source --- src/FlightDisplay/FlightDisplayViewWidgets.qml | 2 +- src/FlightMap/Widgets/QGCInstrumentWidget.qml | 192 +++++++------------------ 2 files changed, 56 insertions(+), 138 deletions(-) diff --git a/src/FlightDisplay/FlightDisplayViewWidgets.qml b/src/FlightDisplay/FlightDisplayViewWidgets.qml index 2a5b31e..f58e2cc 100644 --- a/src/FlightDisplay/FlightDisplayViewWidgets.qml +++ b/src/FlightDisplay/FlightDisplayViewWidgets.qml @@ -74,7 +74,7 @@ Item { break; } } else { - instrumentsLoader.source = "qrc:/qml/QGCInstrumentWidgetAlternate.qml" + instrumentsLoader.source = "qrc:/qml/QGCInstrumentWidget.qml" } } else { instrumentsLoader.source = "" diff --git a/src/FlightMap/Widgets/QGCInstrumentWidget.qml b/src/FlightMap/Widgets/QGCInstrumentWidget.qml index ce76389..71df61a 100644 --- a/src/FlightMap/Widgets/QGCInstrumentWidget.qml +++ b/src/FlightMap/Widgets/QGCInstrumentWidget.qml @@ -7,6 +7,7 @@ * ****************************************************************************/ + import QtQuick 2.3 import QGroundControl 1.0 @@ -17,157 +18,74 @@ import QGroundControl.FlightMap 1.0 import QGroundControl.Palette 1.0 Rectangle { - id: instrumentPanel - height: instrumentColumn.height + (_topBottomMargin * 2) + id: root width: getPreferredInstrumentWidth() - radius: _showLargeCompass ? width / 2 : ScreenTools.defaultFontPixelWidth / 2 - color: _backgroundColor - border.width: _showLargeCompass ? 1 : 0 + height: _outerRadius * 2 + radius: _outerRadius + color: qgcPal.window + border.width: 1 border.color: _isSatellite ? qgcPal.mapWidgetBorderLight : qgcPal.mapWidgetBorderDark - property real _maxHeight: maxHeight - property real _defaultSize: ScreenTools.defaultFontPixelHeight * (9) - property color _backgroundColor: qgcPal.window - property real _spacing: ScreenTools.defaultFontPixelHeight * 0.33 - property real _topBottomMargin: (width * 0.05) / 2 - property real _availableValueHeight: _maxHeight - (outerCompass.height + _spacer1.height + _spacer2.height + (_spacing * 4)) - (_showLargeCompass ? compass.height : 0) - property bool _showLargeCompass: QGroundControl.settingsManager.appSettings.showLargeCompass.value - - readonly property real _outerRingRatio: 0.95 - readonly property real _innerRingRatio: 0.80 - - QGCPalette { id: qgcPal } - - MouseArea { + property real _innerRadius: (width - (_topBottomMargin * 3)) / 4 + property real _outerRadius: _innerRadius + _topBottomMargin + property real _defaultSize: ScreenTools.defaultFontPixelHeight * (9) + property real _sizeRatio: ScreenTools.isTinyScreen ? (width / _defaultSize) * 0.5 : width / _defaultSize + property real _bigFontSize: ScreenTools.defaultFontPointSize * 2.5 * _sizeRatio + property real _normalFontSize: ScreenTools.defaultFontPointSize * 1.5 * _sizeRatio + property real _labelFontSize: ScreenTools.defaultFontPointSize * 0.75 * _sizeRatio + property real _spacing: ScreenTools.defaultFontPixelHeight * 0.33 + property real _topBottomMargin: (width * 0.05) / 2 + property real _availableValueHeight: maxHeight - (root.height + _valuesItem.anchors.topMargin) + + // Prevent all clicks from going through to lower layers + DeadMouseArea { anchors.fill: parent - onClicked: _valuesWidget.showPicker() } - Column { - id: instrumentColumn - anchors.topMargin: _topBottomMargin - anchors.top: parent.top - anchors.left: parent.left - anchors.right: parent.right - spacing: _spacing - - Item { - width: parent.width - height: outerCompass.height - - CompassRing { - id: outerCompass - size: parent.width * _outerRingRatio - vehicle: activeVehicle - anchors.horizontalCenter: parent.horizontalCenter - visible: !_showLargeCompass - - } - - QGCAttitudeWidget { - id: attitudeWidget - size: parent.width * (_showLargeCompass ? _outerRingRatio : _innerRingRatio) - vehicle: activeVehicle - anchors.centerIn: outerCompass - showHeading: !_showLargeCompass - } - - Image { - id: gearThingy - anchors.bottom: outerCompass.bottom - anchors.right: outerCompass.right - source: qgcPal.globalTheme == QGCPalette.Light ? "/res/gear-black.svg" : "/res/gear-white.svg" - mipmap: true - opacity: 0.5 - width: outerCompass.width * 0.15 - sourceSize.width: width - fillMode: Image.PreserveAspectFit - MouseArea { - anchors.fill: parent - hoverEnabled: true - onEntered: gearThingy.opacity = 0.85 - onExited: gearThingy.opacity = 0.5 - onClicked: _valuesWidget.showPicker() - } - } - - Image { - id: healthWarning - anchors.bottom: outerCompass.bottom - anchors.left: outerCompass.left - source: "/qmlimages/Yield.svg" - mipmap: true - visible: activeVehicle ? !_warningsViewed && activeVehicle.unhealthySensors.length > 0 && _valuesWidget.currentPage() != 2 : false - opacity: 0.8 - width: outerCompass.width * 0.15 - sourceSize.width: width - fillMode: Image.PreserveAspectFit - - property bool _warningsViewed: false - - MouseArea { - anchors.fill: parent - hoverEnabled: true - onEntered: healthWarning.opacity = 1 - onExited: healthWarning.opacity = 0.8 - onClicked: { - _valuesWidget.showPage(2) - healthWarning._warningsViewed = true - } - } - - Connections { - target: activeVehicle - onUnhealthySensorsChanged: healthWarning._warningsViewed = false - } - } - } - - Rectangle { - id: _spacer1 - anchors.horizontalCenter: parent.horizontalCenter - height: 1 - width: parent.width * 0.9 - color: qgcPal.text - } + QGCPalette { id: qgcPal } - Item { - width: parent.width - height: _valuesWidget.height + QGCAttitudeWidget { + id: attitude + anchors.leftMargin: _topBottomMargin + anchors.left: parent.left + size: _innerRadius * 2 + vehicle: activeVehicle + anchors.verticalCenter: parent.verticalCenter + } - Rectangle { - anchors.fill: _valuesWidget - color: _backgroundColor - radius: _spacing - visible: !_showLargeCompass - } + QGCCompassWidget { + id: compass + anchors.leftMargin: _spacing + anchors.left: attitude.right + size: _innerRadius * 2 + vehicle: activeVehicle + anchors.verticalCenter: parent.verticalCenter + } - InstrumentSwipeView { - id: _valuesWidget - anchors.margins: 1 - anchors.left: parent.left - anchors.right: parent.right - textColor: qgcPal.text - backgroundColor: _backgroundColor - maxHeight: _availableValueHeight - } + Item { + id: _valuesItem + anchors.topMargin: ScreenTools.defaultFontPixelHeight / 4 + anchors.top: parent.bottom + width: parent.width + height: _valuesWidget.height + visible: widgetRoot.showValues + + // Prevent all clicks from going through to lower layers + DeadMouseArea { + anchors.fill: parent } Rectangle { - id: _spacer2 - anchors.horizontalCenter: parent.horizontalCenter - height: 1 - width: parent.width * 0.9 - color: qgcPal.text - visible: _showLargeCompass + anchors.fill: _valuesWidget + color: qgcPal.window } - QGCCompassWidget { - id: compass - anchors.horizontalCenter: parent.horizontalCenter - size: parent.width * 0.95 - vehicle: activeVehicle - visible: _showLargeCompass + PageView { + id: _valuesWidget + anchors.margins: 1 + anchors.left: parent.left + anchors.right: parent.right + maxHeight: _availableValueHeight } } } From b1fcd835e7cd7244b4f090a8ec0d48e3e18627d5 Mon Sep 17 00:00:00 2001 From: Pierre TILAK <pierre.tilak@aeronavics.com> Date: Wed, 10 Jul 2019 14:14:18 +1200 Subject: [PATCH 3/6] Add Alt Instrument option in Fly View Settings By default the Instrument Panel is the one from master, It can be switched to alternate version by a checkbox in General Settings/Fly View --- src/FlightDisplay/FlightDisplayViewWidgets.qml | 12 +++++++++++- src/Settings/FlyView.SettingsGroup.json | 6 ++++++ src/Settings/FlyViewSettings.cc | 1 + src/Settings/FlyViewSettings.h | 1 + src/ui/preferences/GeneralSettings.qml | 7 +++++++ 5 files changed, 26 insertions(+), 1 deletion(-) diff --git a/src/FlightDisplay/FlightDisplayViewWidgets.qml b/src/FlightDisplay/FlightDisplayViewWidgets.qml index f58e2cc..13b7d54 100644 --- a/src/FlightDisplay/FlightDisplayViewWidgets.qml +++ b/src/FlightDisplay/FlightDisplayViewWidgets.qml @@ -38,6 +38,7 @@ Item { property bool _airspaceEnabled: QGroundControl.airmapSupported ? QGroundControl.settingsManager.airMapSettings.enableAirMap.rawValue : false readonly property real _margins: ScreenTools.defaultFontPixelHeight * 0.5 + readonly property bool _useAlternateInstrumentPanel: QGroundControl.settingsManager.flyViewSettings.alternateInstrumentPanel.value QGCMapPalette { id: mapPal; lightColors: useLightColors } @@ -74,12 +75,21 @@ Item { break; } } else { - instrumentsLoader.source = "qrc:/qml/QGCInstrumentWidget.qml" + if(_useAlternateInstrumentPanel){ + instrumentsLoader.source = "qrc:/qml/QGCInstrumentWidgetAlternate.qml" + } + else{ + instrumentsLoader.source = "qrc:/qml/QGCInstrumentWidget.qml" + } } } else { instrumentsLoader.source = "" } } + Connections { + target: QGroundControl.settingsManager.flyViewSettings.alternateInstrumentPanel + onValueChanged: _setInstrumentWidget() + } Connections { target: QGroundControl.settingsManager.appSettings.virtualJoystick diff --git a/src/Settings/FlyView.SettingsGroup.json b/src/Settings/FlyView.SettingsGroup.json index 4e861da..794b8fa 100644 --- a/src/Settings/FlyView.SettingsGroup.json +++ b/src/Settings/FlyView.SettingsGroup.json @@ -18,5 +18,11 @@ "shortDescription": "Show/Hide Log Replay status bar", "type": "bool", "defaultValue": false +}, +{ + "name": "alternateInstrumentPanel", + "shortDescription": "Use Alternate Instrument Panel instead of the default one", + "type": "bool", + "defaultValue": false } ] diff --git a/src/Settings/FlyViewSettings.cc b/src/Settings/FlyViewSettings.cc index 68ef5dc..2d3d1f8 100644 --- a/src/Settings/FlyViewSettings.cc +++ b/src/Settings/FlyViewSettings.cc @@ -20,3 +20,4 @@ DECLARE_SETTINGGROUP(FlyView, "FlyView") DECLARE_SETTINGSFACT(FlyViewSettings, guidedMinimumAltitude) DECLARE_SETTINGSFACT(FlyViewSettings, guidedMaximumAltitude) DECLARE_SETTINGSFACT(FlyViewSettings, showLogReplayStatusBar) +DECLARE_SETTINGSFACT(FlyViewSettings, alternateInstrumentPanel) diff --git a/src/Settings/FlyViewSettings.h b/src/Settings/FlyViewSettings.h index a6dda7b..ee12163 100644 --- a/src/Settings/FlyViewSettings.h +++ b/src/Settings/FlyViewSettings.h @@ -22,4 +22,5 @@ public: DEFINE_SETTINGFACT(guidedMinimumAltitude) DEFINE_SETTINGFACT(guidedMaximumAltitude) DEFINE_SETTINGFACT(showLogReplayStatusBar) + DEFINE_SETTINGFACT(alternateInstrumentPanel) }; diff --git a/src/ui/preferences/GeneralSettings.qml b/src/ui/preferences/GeneralSettings.qml index add7963..8a07958 100644 --- a/src/ui/preferences/GeneralSettings.qml +++ b/src/ui/preferences/GeneralSettings.qml @@ -461,6 +461,13 @@ Rectangle { property Fact _virtualJoystickCentralized: QGroundControl.settingsManager.appSettings.virtualJoystickCentralized } + FactCheckBox { + text: qsTr("Use Alternate Instrument Panel") + visible: _alternateInstrumentPanel.visible + fact: _alternateInstrumentPanel + + property Fact _alternateInstrumentPanel: QGroundControl.settingsManager.flyViewSettings.alternateInstrumentPanel + } GridLayout { columns: 2 From c8ca71e0253f22093d78bb7c4fe41c499aa79be5 Mon Sep 17 00:00:00 2001 From: Pierre TILAK <pierre.tilak@aeronavics.com> Date: Wed, 10 Jul 2019 14:16:48 +1200 Subject: [PATCH 4/6] Change size of PageView to avoid binding loop --- src/FlightMap/Widgets/QGCInstrumentWidgetAlternate.qml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/FlightMap/Widgets/QGCInstrumentWidgetAlternate.qml b/src/FlightMap/Widgets/QGCInstrumentWidgetAlternate.qml index 4ab4eba..142d6ce 100644 --- a/src/FlightMap/Widgets/QGCInstrumentWidgetAlternate.qml +++ b/src/FlightMap/Widgets/QGCInstrumentWidgetAlternate.qml @@ -79,7 +79,7 @@ Rectangle { anchors.margins: 1 anchors.left: parent.left anchors.right: parent.right - maxHeight: _availableValueHeight + maxHeight: _defaultSize } } From 0d7ec49de99ea5675a7522b72e0e16247081be68 Mon Sep 17 00:00:00 2001 From: Pierre TILAK <pierre.tilak@aeronavics.com> Date: Thu, 11 Jul 2019 15:51:38 +1200 Subject: [PATCH 5/6] Fix Resizing issues, change setting text - Reimplement same behaviour as version 3.1 while resizing the window : Stretch the text area to fit the screen - Change setting text from Alternate Instrument Panel to Vertical Instrument Panel --- src/FlightMap/Widgets/QGCInstrumentWidgetAlternate.qml | 10 +++++----- src/ui/preferences/GeneralSettings.qml | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/FlightMap/Widgets/QGCInstrumentWidgetAlternate.qml b/src/FlightMap/Widgets/QGCInstrumentWidgetAlternate.qml index 142d6ce..2fe5a26 100644 --- a/src/FlightMap/Widgets/QGCInstrumentWidgetAlternate.qml +++ b/src/FlightMap/Widgets/QGCInstrumentWidgetAlternate.qml @@ -19,7 +19,7 @@ import QGroundControl.Palette 1.0 Rectangle { id: root - width: getPreferredInstrumentWidth() + width: getPreferredInstrumentWidth() * 0.7 height: _outerRadius * 4 + _valuesWidget.height radius: _outerRadius color: qgcPal.window @@ -27,7 +27,7 @@ Rectangle { border.color: _isSatellite ? qgcPal.mapWidgetBorderLight : qgcPal.mapWidgetBorderDark property real _innerRadius: (width - (_topBottomMargin * 2)) / 2 - property real _outerRadius: _innerRadius + _topBottomMargin + property real _outerRadius: _innerRadius + _topBottomMargin * 2 property real _defaultSize: ScreenTools.defaultFontPixelHeight * (9) property real _sizeRatio: ScreenTools.isTinyScreen ? (width / _defaultSize) * 0.5 : width / _defaultSize property real _bigFontSize: ScreenTools.defaultFontPointSize * 2.5 * _sizeRatio @@ -35,7 +35,7 @@ Rectangle { property real _labelFontSize: ScreenTools.defaultFontPointSize * 0.75 * _sizeRatio property real _spacing: ScreenTools.defaultFontPixelHeight * 0.33 property real _topBottomMargin: (width * 0.05) / 2 - property real _availableValueHeight: maxHeight - (root.height + _valuesItem.anchors.topMargin) + property real _availableValueHeight: maxHeight - (attitude.height + compass.height) // Prevent all clicks from going through to lower layers DeadMouseArea { @@ -54,10 +54,10 @@ Rectangle { anchors.horizontalCenter: parent.horizontalCenter } - Item { id: _valuesItem anchors.topMargin: ScreenTools.defaultFontPixelHeight / 4 + anchors.bottomMargin: ScreenTools.defaultFontPixelHeight / 4 anchors.top: attitude.bottom anchors.bottom: compass.top width: parent.width @@ -79,7 +79,7 @@ Rectangle { anchors.margins: 1 anchors.left: parent.left anchors.right: parent.right - maxHeight: _defaultSize + maxHeight: _availableValueHeight } } diff --git a/src/ui/preferences/GeneralSettings.qml b/src/ui/preferences/GeneralSettings.qml index 8a07958..08abd0d 100644 --- a/src/ui/preferences/GeneralSettings.qml +++ b/src/ui/preferences/GeneralSettings.qml @@ -462,7 +462,7 @@ Rectangle { property Fact _virtualJoystickCentralized: QGroundControl.settingsManager.appSettings.virtualJoystickCentralized } FactCheckBox { - text: qsTr("Use Alternate Instrument Panel") + text: qsTr("Use Vertical Instrument Panel") visible: _alternateInstrumentPanel.visible fact: _alternateInstrumentPanel From 10461de152da12b3def669d079762b62211101ac Mon Sep 17 00:00:00 2001 From: Pierre TILAK <pierre.tilak@aeronavics.com> Date: Fri, 19 Jul 2019 10:23:37 +1200 Subject: [PATCH 6/6] Change Wording from Alternate to Vertical --- src/Settings/FlyView.SettingsGroup.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Settings/FlyView.SettingsGroup.json b/src/Settings/FlyView.SettingsGroup.json index 794b8fa..ec456eb 100644 --- a/src/Settings/FlyView.SettingsGroup.json +++ b/src/Settings/FlyView.SettingsGroup.json @@ -21,7 +21,7 @@ }, { "name": "alternateInstrumentPanel", - "shortDescription": "Use Alternate Instrument Panel instead of the default one", + "shortDescription": "Use Vertical Instrument Panel instead of the default one", "type": "bool", "defaultValue": false }