From 365c6d7156d62c4a237e0bd8e832c8548276b802 Mon Sep 17 00:00:00 2001 From: Gus Grubba Date: Sat, 20 Jan 2018 14:44:08 -0500 Subject: [PATCH] Control on Fly View Eliminated flight widget "states" Define flight widget top margin (plugin options) --- qgcresources.qrc | 1 + src/Airmap/AirspaceControl.qml | 19 +++- src/Airmap/images/colapse.svg | 9 ++ .../FlightDisplayViewWidgets.qml | 89 +++++++------------ .../Widgets/QGCInstrumentWidgetAlternate.qml | 1 + src/PlanView/PlanView.qml | 5 +- src/QGCPalette.cc | 2 +- src/QmlControls/PageView.qml | 1 + src/api/QGCOptions.h | 13 +-- 9 files changed, 69 insertions(+), 71 deletions(-) create mode 100644 src/Airmap/images/colapse.svg diff --git a/qgcresources.qrc b/qgcresources.qrc index 5cf8cb3e5..019dfa2f5 100644 --- a/qgcresources.qrc +++ b/qgcresources.qrc @@ -176,6 +176,7 @@ src/Airmap/images/advisory-icon.svg + src/Airmap/images/colapse.svg src/Airmap/images/expand.svg src/Airmap/images/pencil.svg diff --git a/src/Airmap/AirspaceControl.qml b/src/Airmap/AirspaceControl.qml index 5cbd6516c..dea3cddf6 100644 --- a/src/Airmap/AirspaceControl.qml +++ b/src/Airmap/AirspaceControl.qml @@ -18,7 +18,8 @@ Item { width: parent.width height: colapsed ? colapsedRect.height : expandedRect.height - property var colapsed: true + property bool colapsed: true + property bool showColapse: true readonly property real _radius: ScreenTools.defaultFontPixelWidth * 0.5 readonly property color _colorOrange: "#d75e0d" @@ -125,6 +126,22 @@ Item { } } } + QGCColoredImage { + width: height + height: ScreenTools.defaultFontPixelWidth * 2.5 + sourceSize.height: height + source: "qrc:/airmap/colapse.svg" + color: _colorWhite + visible: showColapse + anchors.right: parent.right + anchors.rightMargin: ScreenTools.defaultFontPixelWidth + anchors.verticalCenter: parent.verticalCenter + MouseArea { + anchors.fill: parent + enabled: showColapse + onClicked: colapsed = true + } + } } //-- Contents (Brown Box) Rectangle { diff --git a/src/Airmap/images/colapse.svg b/src/Airmap/images/colapse.svg new file mode 100644 index 000000000..bf33cf0dc --- /dev/null +++ b/src/Airmap/images/colapse.svg @@ -0,0 +1,9 @@ + + + + + + diff --git a/src/FlightDisplay/FlightDisplayViewWidgets.qml b/src/FlightDisplay/FlightDisplayViewWidgets.qml index 4d61d876f..b83ad869f 100644 --- a/src/FlightDisplay/FlightDisplayViewWidgets.qml +++ b/src/FlightDisplay/FlightDisplayViewWidgets.qml @@ -15,19 +15,21 @@ import QtLocation 5.3 import QtPositioning 5.3 import QtQuick.Layouts 1.2 -import QGroundControl 1.0 -import QGroundControl.ScreenTools 1.0 -import QGroundControl.Controls 1.0 -import QGroundControl.Palette 1.0 -import QGroundControl.Vehicle 1.0 -import QGroundControl.FlightMap 1.0 +import QGroundControl 1.0 +import QGroundControl.ScreenTools 1.0 +import QGroundControl.Controls 1.0 +import QGroundControl.Palette 1.0 +import QGroundControl.Vehicle 1.0 +import QGroundControl.FlightMap 1.0 +import QGroundControl.Airmap 1.0 Item { - id: _root + id: widgetRoot property var qgcView property bool useLightColors property var missionController + property bool showValues: true property var _activeVehicle: QGroundControl.multiVehicleManager.activeVehicle property bool _isSatellite: _mainIsMap ? (_flightMap ? _flightMap.isSatelliteMap : true) : true @@ -51,28 +53,14 @@ Item { if(QGroundControl.corePlugin.options.instrumentWidget) { if(QGroundControl.corePlugin.options.instrumentWidget.source.toString().length) { instrumentsLoader.source = QGroundControl.corePlugin.options.instrumentWidget.source - switch(QGroundControl.corePlugin.options.instrumentWidget.widgetPosition) { - case CustomInstrumentWidget.POS_TOP_RIGHT: - instrumentsLoader.state = "topMode" - break; - case CustomInstrumentWidget.POS_BOTTOM_RIGHT: - instrumentsLoader.state = "bottomMode" - break; - case CustomInstrumentWidget.POS_CENTER_RIGHT: - default: - instrumentsLoader.state = "centerMode" - break; - } } else { // Note: We currently show alternate instruments all the time. This is a trial change for daily builds. // Leaving non-alternate code in for now in case the trial fails. var useAlternateInstruments = true//QGroundControl.settingsManager.appSettings.virtualJoystick.value || ScreenTools.isTinyScreen if(useAlternateInstruments) { instrumentsLoader.source = "qrc:/qml/QGCInstrumentWidgetAlternate.qml" - instrumentsLoader.state = "topMode" } else { instrumentsLoader.source = "qrc:/qml/QGCInstrumentWidget.qml" - instrumentsLoader.state = QGroundControl.settingsManager.appSettings.showLargeCompass.value == 1 ? "centerMode" : "topMode" } } } else { @@ -130,43 +118,30 @@ Item { text: "The vehicle has failed a pre-arm check. In order to arm the vehicle, resolve the failure or disable the arming check via the Safety tab on the Vehicle Setup page." } } - - //-- Instrument Panel - Loader { - id: instrumentsLoader - anchors.margins: ScreenTools.defaultFontPixelHeight / 2 + Column { + id: instrumentsColumn + spacing: ScreenTools.defaultFontPixelHeight * 0.25 + anchors.top: parent.top + anchors.topMargin: QGroundControl.corePlugin.options.instrumentWidget.widgetTopMargin + (ScreenTools.defaultFontPixelHeight * 0.5) + anchors.margins: ScreenTools.defaultFontPixelHeight * 0.5 anchors.right: parent.right - z: QGroundControl.zOrderWidgets - property var qgcView: _root.qgcView - property real maxHeight:parent.height - (anchors.margins * 2) - states: [ - State { - name: "topMode" - AnchorChanges { - target: instrumentsLoader - anchors.verticalCenter: undefined - anchors.bottom: undefined - anchors.top: _root ? _root.top : undefined - } - }, - State { - name: "centerMode" - AnchorChanges { - target: instrumentsLoader - anchors.top: undefined - anchors.bottom: undefined - anchors.verticalCenter: _root ? _root.verticalCenter : undefined - } - }, - State { - name: "bottomMode" - AnchorChanges { - target: instrumentsLoader - anchors.top: undefined - anchors.verticalCenter: undefined - anchors.bottom: _root ? _root.bottom : undefined - } + //------------------------------------------------------- + // Airmap Airspace Control + AirspaceControl { + id: airspaceControl + width: getPreferredInstrumentWidth() + anchors.margins: ScreenTools.defaultFontPixelHeight * 0.5 + onColapsedChanged: { + widgetRoot.showValues = colapsed } - ] + } + //------------------------------------------------------- + //-- Instrument Panel + Loader { + id: instrumentsLoader + anchors.margins: ScreenTools.defaultFontPixelHeight * 0.5 + property var qgcView: widgetRoot.qgcView + property real maxHeight: widgetRoot ? widgetRoot.height - instrumentsColumn.y - airspaceControl.height - (ScreenTools.defaultFontPixelHeight * 4) : 0 + } } } diff --git a/src/FlightMap/Widgets/QGCInstrumentWidgetAlternate.qml b/src/FlightMap/Widgets/QGCInstrumentWidgetAlternate.qml index 290fec81f..93ebc493b 100644 --- a/src/FlightMap/Widgets/QGCInstrumentWidgetAlternate.qml +++ b/src/FlightMap/Widgets/QGCInstrumentWidgetAlternate.qml @@ -66,6 +66,7 @@ Rectangle { anchors.top: parent.bottom width: parent.width height: _valuesWidget.height + visible: widgetRoot.showValues Rectangle { anchors.fill: _valuesWidget diff --git a/src/PlanView/PlanView.qml b/src/PlanView/PlanView.qml index bac7574be..fc6c4d441 100644 --- a/src/PlanView/PlanView.qml +++ b/src/PlanView/PlanView.qml @@ -512,8 +512,9 @@ QGCView { //------------------------------------------------------- // Airmap Airspace Control AirspaceControl { - id: airspaceControl - width: parent.width + id: airspaceControl + width: parent.width + showColapse: false onColapsedChanged: { if(!airspaceControl.colasped) { planControlColapsed = true diff --git a/src/QGCPalette.cc b/src/QGCPalette.cc index 5af46e337..70a6098ea 100644 --- a/src/QGCPalette.cc +++ b/src/QGCPalette.cc @@ -73,7 +73,7 @@ void QGCPalette::_buildMap(void) DECLARE_QGC_COLOR(alertBackground, "#eecc44", "#eecc44", "#eecc44", "#eecc44") DECLARE_QGC_COLOR(alertBorder, "#808080", "#808080", "#808080", "#808080") DECLARE_QGC_COLOR(alertText, "#000000", "#000000", "#000000", "#000000") - DECLARE_QGC_COLOR(missionItemEditor, "#585858", "#a39fd3", "#585858", "#4e4480") + DECLARE_QGC_COLOR(missionItemEditor, "#585858", "#dbfef8", "#585858", "#585d83") // Colors are not affecting by theming DECLARE_QGC_COLOR(mapWidgetBorderLight, "#ffffff", "#ffffff", "#ffffff", "#ffffff") diff --git a/src/QmlControls/PageView.qml b/src/QmlControls/PageView.qml index 6dfdc6cb4..6dda2997c 100644 --- a/src/QmlControls/PageView.qml +++ b/src/QmlControls/PageView.qml @@ -10,6 +10,7 @@ Rectangle { id: _root height: pageFlickable.y + pageFlickable.height + _margins color: qgcPal.window + radius: ScreenTools.defaultFontPixelWidth * 0.5 property var qgcView ///< QGCView to use for showing dialogs property real maxHeight ///< Maximum height that should be taken, smaller than this is ok diff --git a/src/api/QGCOptions.h b/src/api/QGCOptions.h index 9d06d00bd..3e2607409 100644 --- a/src/api/QGCOptions.h +++ b/src/api/QGCOptions.h @@ -121,18 +121,11 @@ class CustomInstrumentWidget : public QObject { Q_OBJECT public: - //-- Widget Position - enum Pos { - POS_TOP_RIGHT = 0, - POS_CENTER_RIGHT = 1, - POS_BOTTOM_RIGHT = 2, - }; - Q_ENUMS(Pos) CustomInstrumentWidget(QObject* parent = NULL); Q_PROPERTY(QUrl source READ source CONSTANT) - Q_PROPERTY(Pos widgetPosition READ widgetPosition NOTIFY widgetPositionChanged) + Q_PROPERTY(double widgetTopMargin READ widgetTopMargin NOTIFY widgetTopMarginChanged) virtual QUrl source () { return QUrl(); } - virtual Pos widgetPosition () { return POS_CENTER_RIGHT; } + virtual double widgetTopMargin () { return 0.0; } signals: - void widgetPositionChanged (); + void widgetTopMarginChanged(); }; -- 2.22.0