7import QGroundControl.Controls
10 property Window window
12 property bool _enabled: !ScreenTools.isMobile && !ScreenTools.isFakeMobile && QGroundControl.corePlugin.options.enableSaveMainWindowPosition
16 category: "MainWindowState"
22 property int visibility
25 function _setDefaultDesktopWindowSize() {
26 window.width = Math.min(250 * Screen.pixelDensity, Screen.width);
27 window.height = Math.min(150 * Screen.pixelDensity, Screen.height);
28 window.x = Screen.virtualX + (Screen.width - window.width) / 2;
29 window.y = Screen.virtualY + (Screen.height - window.height) / 2;
32 Component.onCompleted: {
33 if (ScreenTools.isFakeMobile) {
34 window.width = ScreenTools.screenWidth
35 window.height = ScreenTools.screenHeight
36 } else if (ScreenTools.isMobile) {
37 window.showFullScreen();
38 } else if (QGroundControl.corePlugin.options.enableSaveMainWindowPosition) {
39 window.minimumWidth = Math.min(ScreenTools.defaultFontPixelWidth * 100, Screen.width)
40 window.minimumHeight = Math.min(ScreenTools.defaultFontPixelWidth * 50, Screen.height)
41 if (s.width && s.height) {
44 window.width = s.width;
45 window.height = s.height;
46 window.visibility = s.visibility;
48 _setDefaultDesktopWindowSize()
51 _setDefaultDesktopWindowSize()
57 function onXChanged() { if(_enabled) saveSettingsTimer.restart() }
58 function onYChanged() { if(_enabled) saveSettingsTimer.restart() }
59 function onWidthChanged() { if(_enabled) saveSettingsTimer.restart() }
60 function onHeightChanged() { if(_enabled) saveSettingsTimer.restart() }
61 function onVisibilityChanged() { if(_enabled) saveSettingsTimer.restart() }
68 onTriggered: saveSettings()
71 function saveSettings() {
73 switch(window.visibility) {
74 case ApplicationWindow.Windowed:
77 s.width = window.width;
78 s.height = window.height;
79 s.visibility = window.visibility;
81 case ApplicationWindow.FullScreen:
82 s.visibility = window.visibility;
84 case ApplicationWindow.Maximized:
85 s.visibility = window.visibility;