From ce911c01f016cbaf7998bd8e727873ae4b90383d Mon Sep 17 00:00:00 2001 From: Gus Grubba Date: Tue, 4 Apr 2017 22:31:56 -0400 Subject: [PATCH] Enable (custom) Fly View overlay Added top/bottom alignment state to map scale Allow disabling instrument widget altogether Added an otherwise redundant row to PlanToolbar so it matches the same button position as the main toolbar Fixed typo (Math.max()) in ScreenTools Fixed Javascript Exception in OfflineMap Increased the import window size in OfflineMap Added function to MainWindow to disable toolbar for a truly modal dialog Added code so clicking on an open toolbar indicator will cause it to close --- src/FlightDisplay/FlightDisplayView.qml | 15 +++++ src/FlightDisplay/FlightDisplayViewMap.qml | 28 ++++++++- .../FlightDisplayViewWidgets.qml | 46 +++++++------- src/PlanView/PlanToolBar.qml | 22 ++++--- src/QmlControls/ScreenTools.qml | 2 +- .../QMLControl/OfflineMap.qml | 6 +- src/api/QGCOptions.h | 5 +- src/ui/MainWindowInner.qml | 61 ++++++++++++++----- 8 files changed, 133 insertions(+), 52 deletions(-) diff --git a/src/FlightDisplay/FlightDisplayView.qml b/src/FlightDisplay/FlightDisplayView.qml index 85ba5f0de6..1dc71f75cc 100644 --- a/src/FlightDisplay/FlightDisplayView.qml +++ b/src/FlightDisplay/FlightDisplayView.qml @@ -114,6 +114,9 @@ QGCView { Component.onCompleted: { setStates() px4JoystickCheck() + if(QGroundControl.corePlugin.options.flyViewOverlay.toString().length) { + flyViewOverlay.source = QGroundControl.corePlugin.options.flyViewOverlay + } } QGCMapPalette { id: mapPal; lightColors: _mainIsMap ? _flightMap.isSatelliteMap : true } @@ -157,6 +160,7 @@ QGCView { flightWidgets: flightDisplayViewWidgets rightPanelWidth: ScreenTools.defaultFontPixelHeight * 9 qgcView: root + scaleState: (_mainIsMap && flyViewOverlay.item) ? (flyViewOverlay.item.scaleState ? flyViewOverlay.item.scaleState : "bottomMode") : "bottomMode" } } @@ -259,6 +263,17 @@ QGCView { visible: singleVehicleView.checked } + //------------------------------------------------------------------------- + //-- Loader helper for plugins to overlay elements over the fly view + Loader { + id: flyViewOverlay + z: flightDisplayViewWidgets.z + 1 + height: ScreenTools.availableHeight + anchors.left: parent.left + anchors.right: altitudeSlider.visible ? altitudeSlider.left : parent.right + anchors.bottom: parent.bottom + } + // Button to start/stop video recording Item { z: _flightVideoPipControl.z + 1 diff --git a/src/FlightDisplay/FlightDisplayViewMap.qml b/src/FlightDisplay/FlightDisplayViewMap.qml index 4af77838ed..648b0084b4 100644 --- a/src/FlightDisplay/FlightDisplayViewMap.qml +++ b/src/FlightDisplay/FlightDisplayViewMap.qml @@ -30,6 +30,8 @@ FlightMap { allowGCSLocationCenter: !userPanned allowVehicleLocationCenter: !_keepVehicleCentered + property alias scaleState: mapScale.state + property var missionController property var guidedActionsController property var flightWidgets @@ -299,11 +301,31 @@ FlightMap { } MapScale { - anchors.bottomMargin: ScreenTools.defaultFontPixelHeight * (0.66) - anchors.rightMargin: ScreenTools.defaultFontPixelHeight * (0.33) - anchors.bottom: parent.bottom + id: mapScale anchors.right: parent.right + anchors.margins: ScreenTools.defaultFontPixelHeight * (0.33) + anchors.topMargin: ScreenTools.defaultFontPixelHeight * (0.33) + state === "bottomMode" ? 0 : ScreenTools.toolbarHeight + anchors.bottomMargin: ScreenTools.defaultFontPixelHeight * (0.33) mapControl: flightMap visible: !ScreenTools.isTinyScreen + state: "bottomMode" + states: [ + State { + name: "topMode" + AnchorChanges { + target: mapScale + anchors.top: parent.top + anchors.bottom: undefined + } + }, + State { + name: "bottomMode" + AnchorChanges { + target: mapScale + anchors.top: undefined + anchors.bottom: parent.bottom + } + } + ] } } diff --git a/src/FlightDisplay/FlightDisplayViewWidgets.qml b/src/FlightDisplay/FlightDisplayViewWidgets.qml index e9bd51db90..d2d5fde6f4 100644 --- a/src/FlightDisplay/FlightDisplayViewWidgets.qml +++ b/src/FlightDisplay/FlightDisplayViewWidgets.qml @@ -47,29 +47,33 @@ Item { } function _setInstrumentWidget() { - 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 { - var useAlternateInstruments = QGroundControl.settingsManager.appSettings.virtualJoystick.value || ScreenTools.isTinyScreen - if(useAlternateInstruments) { - instrumentsLoader.source = "qrc:/qml/QGCInstrumentWidgetAlternate.qml" - instrumentsLoader.state = "topMode" + 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 { - instrumentsLoader.source = "qrc:/qml/QGCInstrumentWidget.qml" - instrumentsLoader.state = QGroundControl.settingsManager.appSettings.showLargeCompass.value == 1 ? "centerMode" : "topMode" + var useAlternateInstruments = 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 { + instrumentsLoader.source = "" } } diff --git a/src/PlanView/PlanToolBar.qml b/src/PlanView/PlanToolBar.qml index 6f40ec50a0..1cc3873f1d 100644 --- a/src/PlanView/PlanToolBar.qml +++ b/src/PlanView/PlanToolBar.qml @@ -19,6 +19,7 @@ Rectangle { z: toolBar.z + 1 color: qgcPal.globalTheme === QGCPalette.Light ? Qt.rgba(1,1,1,0.8) : Qt.rgba(0,0,0,0.75) visible: false + anchors.bottomMargin: 1 signal showFlyView @@ -79,13 +80,11 @@ Rectangle { onReleased: { mouse.accepted = true; } } - RowLayout { - anchors.top: parent.top - anchors.bottom: parent.bottom - anchors.left: parent.left - anchors.right: uploadButton.visible ? uploadButton.left : uploadButton.right - spacing: ScreenTools.defaultFontPixelWidth * 2 - + Row { + anchors.bottomMargin: 1 + anchors.left: parent.left + anchors.top: parent.top + anchors.bottom: parent.bottom QGCToolBarButton { id: settingsButton anchors.top: parent.top @@ -93,7 +92,6 @@ Rectangle { source: "/qmlimages/PaperPlane.svg" logo: true checked: false - onClicked: { checked = false if (missionController.uploadOnSwitch()) { @@ -101,6 +99,14 @@ Rectangle { } } } + } + + + Row { + anchors.top: parent.top + anchors.bottom: parent.bottom + spacing: _margins * 2 + anchors.horizontalCenter: parent.horizontalCenter GridLayout { anchors.verticalCenter: parent.verticalCenter diff --git a/src/QmlControls/ScreenTools.qml b/src/QmlControls/ScreenTools.qml index 4fd7bd4294..a7b8db48e2 100644 --- a/src/QmlControls/ScreenTools.qml +++ b/src/QmlControls/ScreenTools.qml @@ -70,7 +70,7 @@ Item { property real implicitTextFieldHeight: Math.round(defaultFontPixelHeight * (isMobile ? 2.0 : 1.6)) property real implicitComboBoxHeight: Math.round(defaultFontPixelHeight * (isMobile ? 2.0 : 1.6)) property real implicitComboBoxWidth: Math.round(defaultFontPixelWidth * (isMobile ? 7.0 : 5.0)) - property real implicitSliderHeight: isMobile ? Math.Max(defaultFontPixelHeight, minTouchPixels) : defaultFontPixelHeight + property real implicitSliderHeight: isMobile ? Math.max(defaultFontPixelHeight, minTouchPixels) : defaultFontPixelHeight readonly property string normalFontFamily: "opensans" readonly property string demiboldFontFamily: "opensans-demibold" diff --git a/src/QtLocationPlugin/QMLControl/OfflineMap.qml b/src/QtLocationPlugin/QMLControl/OfflineMap.qml index a2865a26f7..7bb3c7713e 100644 --- a/src/QtLocationPlugin/QMLControl/OfflineMap.qml +++ b/src/QtLocationPlugin/QMLControl/OfflineMap.qml @@ -1043,8 +1043,8 @@ QGCView { anchors.horizontalCenter: parent.horizontalCenter } BusyIndicator { - visible: QGroundControl.mapEngineManager.exporting - running: QGroundControl.mapEngineManager.exporting + visible: QGroundControl.mapEngineManager ? QGroundControl.mapEngineManager.exporting : false + running: QGroundControl.mapEngineManager ? QGroundControl.mapEngineManager.exporting : false width: exportCloseButton.height height: exportCloseButton.height anchors.horizontalCenter: parent.horizontalCenter @@ -1072,7 +1072,7 @@ QGCView { color: "black" anchors.centerIn: parent Rectangle { - width: parent.width * 0.45 + width: parent.width * 0.5 height: importCol.height * 1.5 radius: ScreenTools.defaultFontPixelWidth color: qgcPal.windowShadeDark diff --git a/src/api/QGCOptions.h b/src/api/QGCOptions.h index 0a16ecfe46..85c8a26e3c 100644 --- a/src/api/QGCOptions.h +++ b/src/api/QGCOptions.h @@ -28,6 +28,7 @@ public: Q_PROPERTY(double toolbarHeightMultiplier READ toolbarHeightMultiplier CONSTANT) Q_PROPERTY(bool enablePlanViewSelector READ enablePlanViewSelector CONSTANT) Q_PROPERTY(CustomInstrumentWidget* instrumentWidget READ instrumentWidget CONSTANT) + Q_PROPERTY(QUrl flyViewOverlay READ flyViewOverlay CONSTANT) Q_PROPERTY(bool showSensorCalibrationCompass READ showSensorCalibrationCompass NOTIFY showSensorCalibrationCompassChanged) Q_PROPERTY(bool showSensorCalibrationGyro READ showSensorCalibrationGyro NOTIFY showSensorCalibrationGyroChanged) Q_PROPERTY(bool showSensorCalibrationAccel READ showSensorCalibrationAccel NOTIFY showSensorCalibrationAccelChanged) @@ -56,6 +57,8 @@ public: /// @return An alternate widget (see QGCInstrumentWidget.qml, the default widget) virtual CustomInstrumentWidget* instrumentWidget(); + /// Allows access to the full fly view window + virtual QUrl flyViewOverlay () const { return QUrl(); } /// By returning false you can hide the following sensor calibration pages virtual bool showSensorCalibrationCompass () const { return true; } virtual bool showSensorCalibrationGyro () const { return true; } @@ -82,7 +85,7 @@ signals: void showSensorCalibrationLevelChanged (bool show); void showSensorCalibrationAirspeedChanged (bool show); void showFirmwareUpgradeChanged (bool show); - void guidedBarShowEmergencyStopChanged (bool show); + void guidedBarShowEmergencyStopChanged (bool show); void guidedBarShowOrbitChanged (bool show); private: diff --git a/src/ui/MainWindowInner.qml b/src/ui/MainWindowInner.qml index a815d85c33..a044a712c8 100644 --- a/src/ui/MainWindowInner.qml +++ b/src/ui/MainWindowInner.qml @@ -47,6 +47,14 @@ Item { } } + function disableToolbar() { + toolbarBlocker.enabled = true + } + + function enableToolbar() { + toolbarBlocker.enabled = false + } + function hideAllViews() { for (var i=0; i<_viewList.length; i++) { _viewList[i].visible = false @@ -55,6 +63,7 @@ Item { } function showSettingsView() { + rootLoader.sourceComponent = null if(currentPopUp) { currentPopUp.close() } @@ -69,6 +78,7 @@ Item { } function showSetupView() { + rootLoader.sourceComponent = null if(currentPopUp) { currentPopUp.close() } @@ -83,6 +93,7 @@ Item { } function showPlanView() { + rootLoader.sourceComponent = null if(currentPopUp) { currentPopUp.close() } @@ -96,6 +107,7 @@ Item { } function showFlyView() { + rootLoader.sourceComponent = null if(currentPopUp) { currentPopUp.close() } @@ -106,6 +118,7 @@ Item { } function showAnalyzeView() { + rootLoader.sourceComponent = null if(currentPopUp) { currentPopUp.close() } @@ -206,30 +219,40 @@ Item { } function showMessageArea() { + rootLoader.sourceComponent = null + var currentlyVisible = messageArea.visible if(currentPopUp) { currentPopUp.close() } - if(QGroundControl.multiVehicleManager.activeVehicleAvailable) { - messageText.text = formatMessage(activeVehicle.formatedMessages) - //-- Hack to scroll to last message - for (var i = 0; i < activeVehicle.messageCount; i++) - messageFlick.flick(0,-5000) - activeVehicle.resetMessages() - } else { - messageText.text = qsTr("No Messages") + if(!currentlyVisible) { + if(QGroundControl.multiVehicleManager.activeVehicleAvailable) { + messageText.text = formatMessage(activeVehicle.formatedMessages) + //-- Hack to scroll to last message + for (var i = 0; i < activeVehicle.messageCount; i++) + messageFlick.flick(0,-5000) + activeVehicle.resetMessages() + } else { + messageText.text = qsTr("No Messages") + } + currentPopUp = messageArea + messageArea.visible = true } - currentPopUp = messageArea - messageArea.visible = true } function showPopUp(dropItem, centerX) { + rootLoader.sourceComponent = null + var oldIndicator = indicatorDropdown.sourceComponent if(currentPopUp) { currentPopUp.close() } - indicatorDropdown.centerX = centerX - indicatorDropdown.sourceComponent = dropItem - indicatorDropdown.visible = true - currentPopUp = indicatorDropdown + if(oldIndicator !== dropItem) { + console.log(oldIndicator) + console.log(dropItem) + indicatorDropdown.centerX = centerX + indicatorDropdown.sourceComponent = dropItem + indicatorDropdown.visible = true + currentPopUp = indicatorDropdown + } } //-- Main UI @@ -242,13 +265,21 @@ Item { anchors.top: parent.top opacity: planToolBar.visible ? 0 : 1 z: QGroundControl.zOrderTopMost - Component.onCompleted: ScreenTools.availableHeight = parent.height - toolBar.height onShowSettingsView: mainWindow.showSettingsView() onShowSetupView: mainWindow.showSetupView() onShowPlanView: mainWindow.showPlanView() onShowFlyView: mainWindow.showFlyView() onShowAnalyzeView: mainWindow.showAnalyzeView() + //-- Entire tool bar area disable on cammand + MouseArea { + id: toolbarBlocker + anchors.fill: parent + enabled: false + onWheel: { wheel.accepted = true; } + onPressed: { mouse.accepted = true; } + onReleased: { mouse.accepted = true; } + } } PlanToolBar { -- GitLab