diff --git a/qgroundcontrol.qrc b/qgroundcontrol.qrc
index fa345bdcab1c10436ffdfe276d0498fd651ea659..566974b776b91b5df5a93dd536f406cb4a1519b3 100644
--- a/qgroundcontrol.qrc
+++ b/qgroundcontrol.qrc
@@ -86,6 +86,7 @@
src/QmlControls/IndicatorButton.qml
src/QmlControls/JoystickThumbPad.qml
src/QmlControls/LogReplayStatusBar.qml
+ src/QmlControls/MainWindowSavedState.qml
src/QmlControls/MAVLinkMessageButton.qml
src/QmlControls/MissionCommandDialog.qml
src/PlanView/MissionItemEditor.qml
diff --git a/src/QmlControls/MainWindowSavedState.qml b/src/QmlControls/MainWindowSavedState.qml
new file mode 100644
index 0000000000000000000000000000000000000000..9515a193db367ab4d97b9b45160ebdcfe3eefc66
--- /dev/null
+++ b/src/QmlControls/MainWindowSavedState.qml
@@ -0,0 +1,74 @@
+/****************************************************************************
+ *
+ * (c) 2009-2016 QGROUNDCONTROL PROJECT
+ *
+ * QGroundControl is licensed according to the terms in the file
+ * COPYING.md in the root of the source code directory.
+ *
+ ****************************************************************************/
+
+import QtQuick 2.11
+import QtQuick.Window 2.11
+import QtQuick.Controls 2.4
+import Qt.labs.settings 1.0
+
+import QGroundControl.ScreenTools 1.0
+
+Item {
+ property Window window
+
+ Settings {
+ id: s
+ category: "MainWindowState"
+
+ property int x
+ property int y
+ property int width
+ property int height
+ property int visibility
+ }
+
+ Component.onCompleted: {
+ if (!ScreenTools.isMobile && s.width && s.height) {
+ window.x = s.x;
+ window.y = s.y;
+ window.width = s.width;
+ window.height = s.height;
+ window.visibility = s.visibility;
+ }
+ }
+
+ Connections {
+ target: ScreenTools.isMobile ? null : window
+ onXChanged: saveSettingsTimer.restart()
+ onYChanged: saveSettingsTimer.restart()
+ onWidthChanged: saveSettingsTimer.restart()
+ onHeightChanged: saveSettingsTimer.restart()
+ onVisibilityChanged: saveSettingsTimer.restart()
+ }
+
+ Timer {
+ id: saveSettingsTimer
+ interval: 1000
+ repeat: false
+ onTriggered: saveSettings()
+ }
+
+ 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;
+ }
+ }
+}
diff --git a/src/QmlControls/QGroundControl/Controls/qmldir b/src/QmlControls/QGroundControl/Controls/qmldir
index 8373c3079d3af0e1dd8be13ecca8a18684afcd56..5d2fb829e5b23a3d7317e55879b6ff280bbba661 100644
--- a/src/QmlControls/QGroundControl/Controls/qmldir
+++ b/src/QmlControls/QGroundControl/Controls/qmldir
@@ -24,6 +24,7 @@ HeightIndicator 1.0 HeightIndicator.qml
IndicatorButton 1.0 IndicatorButton.qml
JoystickThumbPad 1.0 JoystickThumbPad.qml
LogReplayStatusBar 1.0 LogReplayStatusBar.qml
+MainWindowSavedState 1.0 MainWindowSavedState.qml
MAVLinkMessageButton 1.0 MAVLinkMessageButton.qml
MissionCommandDialog 1.0 MissionCommandDialog.qml
MissionItemEditor 1.0 MissionItemEditor.qml
diff --git a/src/ui/MainRootWindow.qml b/src/ui/MainRootWindow.qml
index 34f38cdb7840b7808fba549cedc4ee43d37c6e12..e37fc8352ef423c76d60de4313168575b65ff3a8 100644
--- a/src/ui/MainRootWindow.qml
+++ b/src/ui/MainRootWindow.qml
@@ -122,6 +122,10 @@ ApplicationWindow {
simpleMessageDialog.open()
}
+ MainWindowSavedState {
+ window: mainWindow
+ }
+
MessageDialog {
id: simpleMessageDialog
standardButtons: StandardButton.Ok