diff --git a/src/QmlControls/MainWindowSavedState.qml b/src/QmlControls/MainWindowSavedState.qml index 97216d609bd7dcd32daafa48b8e53b00212ee111..483e7a904d7179e0fc02783453ac5f3997ad5816 100644 --- a/src/QmlControls/MainWindowSavedState.qml +++ b/src/QmlControls/MainWindowSavedState.qml @@ -12,11 +12,14 @@ import QtQuick.Window 2.11 import QtQuick.Controls 2.4 import Qt.labs.settings 1.0 -import QGroundControl.ScreenTools 1.0 +import QGroundControl 1.0 +import QGroundControl.ScreenTools 1.0 Item { property Window window + property bool _enabled: !ScreenTools.isMobile && QGroundControl.corePlugin.options.enableSaveMainWindowPosition + Settings { id: s category: "MainWindowState" @@ -29,7 +32,7 @@ Item { } Component.onCompleted: { - if (!ScreenTools.isMobile && s.width && s.height) { + if (_enabled && s.width && s.height) { window.x = s.x; window.y = s.y; window.width = s.width; @@ -39,12 +42,12 @@ Item { } Connections { - target: ScreenTools.isMobile ? null : window - onXChanged: saveSettingsTimer.restart() - onYChanged: saveSettingsTimer.restart() - onWidthChanged: saveSettingsTimer.restart() - onHeightChanged: saveSettingsTimer.restart() - onVisibilityChanged: saveSettingsTimer.restart() + target: window + onXChanged: if(_enabled) saveSettingsTimer.restart() + onYChanged: if(_enabled) saveSettingsTimer.restart() + onWidthChanged: if(_enabled) saveSettingsTimer.restart() + onHeightChanged: if(_enabled) saveSettingsTimer.restart() + onVisibilityChanged: if(_enabled) saveSettingsTimer.restart() } Timer { @@ -55,20 +58,22 @@ Item { } function saveSettings() { - switch(window.visibility) { - case ApplicationWindow.Windowed: - s.x = window.x; - s.y = window.y; - s.width = window.width; - s.height = window.height; - s.visibility = window.visibility; - break; - case ApplicationWindow.FullScreen: - s.visibility = window.visibility; - break; - case ApplicationWindow.Maximized: - s.visibility = window.visibility; - break; + if(_enabled) { + switch(window.visibility) { + case ApplicationWindow.Windowed: + s.x = window.x; + s.y = window.y; + s.width = window.width; + s.height = window.height; + s.visibility = window.visibility; + break; + case ApplicationWindow.FullScreen: + s.visibility = window.visibility; + break; + case ApplicationWindow.Maximized: + s.visibility = window.visibility; + break; + } } } } diff --git a/src/api/QGCOptions.h b/src/api/QGCOptions.h index 9099cdd6ddc6309dbb0f207e55b1503d7a3b7432..ba6c56380ab44f695e218e2ddfc0aa841da30df3 100644 --- a/src/api/QGCOptions.h +++ b/src/api/QGCOptions.h @@ -66,6 +66,7 @@ public: Q_PROPERTY(bool showMavlinkLogOptions READ showMavlinkLogOptions CONSTANT) Q_PROPERTY(bool enableMultiVehicleList READ enableMultiVehicleList CONSTANT) Q_PROPERTY(bool enableMapScale READ enableMapScale CONSTANT) + Q_PROPERTY(bool enableSaveMainWindowPosition READ enableSaveMainWindowPosition CONSTANT) /// Should QGC hide its settings menu and colapse it into one single menu (Settings and Vehicle Setup)? /// @return true if QGC should consolidate both menus into one. @@ -127,6 +128,8 @@ public: virtual bool showMavlinkLogOptions () const { return true; } virtual bool enableMultiVehicleList () const { return true; } virtual bool enableMapScale () const { return true; } + /// Desktop builds save the main application size and position on close (and restore it on open) + virtual bool enableSaveMainWindowPosition () const { return true; } #if defined(__mobile__) virtual bool useMobileFileDialog () const { return true;}