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);
30 Component.onCompleted: {
31 if (ScreenTools.isFakeMobile) {
32 window.width = ScreenTools.screenWidth
33 window.height = ScreenTools.screenHeight
34 } else if (ScreenTools.isMobile) {
35 window.showFullScreen();
36 } else if (QGroundControl.corePlugin.options.enableSaveMainWindowPosition) {
37 window.minimumWidth = Math.min(ScreenTools.defaultFontPixelWidth * 100, Screen.width)
38 window.minimumHeight = Math.min(ScreenTools.defaultFontPixelWidth * 50, Screen.height)
39 if (s.width && s.height) {
42 window.width = s.width;
43 window.height = s.height;
44 window.visibility = s.visibility;
46 _setDefaultDesktopWindowSize()
49 _setDefaultDesktopWindowSize()
55 function onXChanged() { if(_enabled) saveSettingsTimer.restart() }
56 function onYChanged() { if(_enabled) saveSettingsTimer.restart() }
57 function onWidthChanged() { if(_enabled) saveSettingsTimer.restart() }
58 function onHeightChanged() { if(_enabled) saveSettingsTimer.restart() }
59 function onVisibilityChanged() { if(_enabled) saveSettingsTimer.restart() }
66 onTriggered: saveSettings()
69 function saveSettings() {
71 switch(window.visibility) {
72 case ApplicationWindow.Windowed:
75 s.width = window.width;
76 s.height = window.height;
77 s.visibility = window.visibility;
79 case ApplicationWindow.FullScreen:
80 s.visibility = window.visibility;
82 case ApplicationWindow.Maximized:
83 s.visibility = window.visibility;