diff --git a/src/ui/MainWindowInner.qml b/src/ui/MainWindowInner.qml index 5c65af88ddddbbff9bb0166aa6dbc42ce68c401b..3da528ea60507a673fa479715824eaeb08604390 100644 --- a/src/ui/MainWindowInner.qml +++ b/src/ui/MainWindowInner.qml @@ -40,8 +40,9 @@ Item { signal reallyClose - readonly property string _planViewSource: "MissionEditor.qml" - readonly property string _setupViewSource: "SetupView.qml" + readonly property string _planViewSource: "MissionEditor.qml" + readonly property string _setupViewSource: "SetupView.qml" + readonly property string _preferencesSource: "MainWindowLeftPanel.qml" QGCPalette { id: qgcPal; colorGroupEnabled: true } @@ -68,6 +69,7 @@ Item { currentPopUp.close() } ScreenTools.availableHeight = parent.height - toolBar.height + preferencesPanel.visible = false flightView.visible = true setupViewLoader.visible = false planViewLoader.visible = false @@ -82,6 +84,7 @@ Item { planViewLoader.source = _planViewSource } ScreenTools.availableHeight = parent.height - toolBar.height + preferencesPanel.visible = false flightView.visible = false setupViewLoader.visible = false planViewLoader.visible = true @@ -97,12 +100,28 @@ Item { if (setupViewLoader.source != _setupViewSource) { setupViewLoader.source = _setupViewSource } + preferencesPanel.visible = false flightView.visible = false setupViewLoader.visible = true planViewLoader.visible = false toolBar.checkSetupButton() } + function showPreferences() { + if(currentPopUp) { + currentPopUp.close() + } + //-- In preferences view, the full height is available. Set to 0 so it is ignored. + ScreenTools.availableHeight = 0 + if (preferencesPanel.source != _preferencesSource) { + preferencesPanel.source = _preferencesSource + } + flightView.visible = false + setupViewLoader.visible = false + planViewLoader.visible = false + preferencesPanel.visible = true + } + // The following are use for unit testing only function showSetupFirmware() { @@ -182,11 +201,9 @@ Item { } } - //-- Detect tablet position Connections { target: QGroundControl.qgcPositionManger - onLastPositionUpdated: { if(valid) { if(lastPosition.latitude) { @@ -213,22 +230,6 @@ Item { } } - function showLeftMenu() { - if(!leftPanel.visible) { - leftPanel.visible = true - leftPanel.item.animateShowDialog.start() - } else if(leftPanel.visible && !leftPanel.item.animateShowDialog.running) { - //-- If open, toggle it closed - hideLeftMenu() - } - } - - function hideLeftMenu() { - if(leftPanel.visible && !leftPanel.item.animateHideDialog.running) { - leftPanel.item.animateHideDialog.start() - } - } - function formatMessage(message) { message = message.replace(new RegExp("<#E>", "g"), "color: #f95e5e; font: " + (ScreenTools.defaultFontPointSize.toFixed(0) - 1) + "pt monospace;"); message = message.replace(new RegExp("<#I>", "g"), "color: #f9b55e; font: " + (ScreenTools.defaultFontPointSize.toFixed(0) - 1) + "pt monospace;"); @@ -273,12 +274,17 @@ Item { //-- Left Settings Menu Loader { - id: leftPanel + id: preferencesPanel anchors.fill: parent visible: false z: QGroundControl.zOrderTopMost + 100 active: visible - source: "MainWindowLeftPanel.qml" + onVisibleChanged: { + console.log("Visible: " + visible) + if(!visible) { + source = "" + } + } } //-- Main UI @@ -290,12 +296,13 @@ Item { anchors.right: parent.right anchors.top: parent.top mainWindow: mainWindow - opaqueBackground: leftPanel.visible + opaqueBackground: preferencesPanel.visible isBackgroundDark: flightView.isBackgroundDark z: QGroundControl.zOrderTopMost onShowSetupView: mainWindow.showSetupView() onShowPlanView: mainWindow.showPlanView() onShowFlyView: mainWindow.showFlyView() + onShowPreferences: mainWindow.showPreferences() Component.onCompleted: { ScreenTools.availableHeight = parent.height - toolBar.height } diff --git a/src/ui/MainWindowLeftPanel.qml b/src/ui/MainWindowLeftPanel.qml index aad0a8c4a5824386418c61c1cdb77dd809baf728..cdf8c21e02f783995430025359939aa698ea5d11 100644 --- a/src/ui/MainWindowLeftPanel.qml +++ b/src/ui/MainWindowLeftPanel.qml @@ -37,69 +37,17 @@ Item { id: settingsMenu anchors.fill: parent - property alias animateShowDialog: __animateShowDialog - property alias animateHideDialog: __animateHideDialog - - readonly property int __animationDuration: 100 readonly property real __closeButtonSize: ScreenTools.defaultFontPixelHeight * 1.5 readonly property real _margins: ScreenTools.defaultFontPixelHeight * 0.5 readonly property real _buttonHeight: ScreenTools.isTinyScreen ? ScreenTools.defaultFontPixelHeight * 3 : ScreenTools.defaultFontPixelHeight * 2 QGCPalette { id: qgcPal } - onVisibleChanged: { - //-- Unselect any selected button - panelActionGroup.current = null - //-- Destroy panel contents if not visible - if(!visible) { - __rightPanel.source = "" - } - } - - function closeSettings() { - __rightPanel.source = "" - mainWindow.hideLeftMenu() - } - - ParallelAnimation { - id: __animateShowDialog - NumberAnimation { - target: __transparentSection - properties: "opacity" - from: 0.0 - to: 0.8 - duration: settingsMenu.__animationDuration - } - NumberAnimation { - target: __transparentSection - properties: "width" - from: 1 - to: mainWindow.width - duration: settingsMenu.__animationDuration - } - } - - ParallelAnimation { - id: __animateHideDialog - NumberAnimation { - target: __transparentSection - properties: "opacity" - from: 0.8 - to: 0.0 - duration: settingsMenu.__animationDuration - } - NumberAnimation { - target: __transparentSection - properties: "width" - from: mainWindow.width - to: 1 - duration: settingsMenu.__animationDuration - } - onRunningChanged: { - if (!running) { - parent.visible = false - } - } + Component.onCompleted: { + //-- Default to General Settings + __rightPanel.source = "GeneralSettings.qml" + _generalButton.checked = true + panelActionGroup.current = _generalButton } // This covers the screen with a transparent section @@ -111,14 +59,6 @@ Item { opacity: 0.0 color: qgcPal.window visible: __rightPanel.source == "" - // Dismiss if clicked outside menu area - MouseArea { - anchors.fill: parent - onClicked: { - if (!__animateShowDialog.running) - mainWindow.hideLeftMenu() - } - } } //-- Top Separator @@ -164,6 +104,7 @@ Item { } QGCButton { + id: _generalButton height: _buttonHeight anchors.left: parent.left anchors.right: parent.right @@ -266,18 +207,6 @@ Item { } } - //-- Clicking in tool bar area dismiss it all - MouseArea { - anchors.top: parent.top - anchors.left: parent.left - anchors.right: parent.right - height: toolBar.height - onClicked: { - if (!__animateShowDialog.running) - mainWindow.hideLeftMenu() - } - } - //-- Vertical Separator Rectangle { id: __verticalSeparator diff --git a/src/ui/preferences/LinkSettings.qml b/src/ui/preferences/LinkSettings.qml index d744b516ba3674ac1fbf74406e41b53db256d9ad..06034c7331c046affa378478ecc1a84442bcbd8d 100644 --- a/src/ui/preferences/LinkSettings.qml +++ b/src/ui/preferences/LinkSettings.qml @@ -151,7 +151,6 @@ Rectangle { enabled: _currentSelection && !_currentSelection.link onClicked: { QGroundControl.linkManager.createConnectedLink(_currentSelection) - settingsMenu.closeSettings() } } QGCButton { diff --git a/src/ui/toolbar/MainToolBar.qml b/src/ui/toolbar/MainToolBar.qml index e1dc92657b7072aee29fac5d879b084fbe95f3aa..d3f89ca9b3a9d99c99af95ab70356015e9fd372c 100644 --- a/src/ui/toolbar/MainToolBar.qml +++ b/src/ui/toolbar/MainToolBar.qml @@ -58,6 +58,7 @@ Rectangle { readonly property var colorBlue: "#636efe" readonly property var colorWhite: "#ffffff" + signal showPreferences() signal showSetupView() signal showPlanView() signal showFlyView() @@ -347,8 +348,8 @@ Rectangle { } */ MouseArea { - anchors.fill: parent - onClicked: mainWindow.showLeftMenu() + anchors.fill: parent + onClicked: toolBar.showPreferences() } }