From fae3c56c273383bccb6cd87172f266836c97b074 Mon Sep 17 00:00:00 2001 From: Alex Spataru Date: Thu, 18 Nov 2021 23:43:12 -0600 Subject: [PATCH] Fix Windows-specific glitches --- assets/qml/FramelessWindow/CustomWindow.qml | 29 +++++++++++++++++++++ assets/qml/Windows/MainWindow.qml | 24 ----------------- assets/qml/main.qml | 2 +- 3 files changed, 30 insertions(+), 25 deletions(-) diff --git a/assets/qml/FramelessWindow/CustomWindow.qml b/assets/qml/FramelessWindow/CustomWindow.qml index b6fd5147..37e0ee8f 100644 --- a/assets/qml/FramelessWindow/CustomWindow.qml +++ b/assets/qml/FramelessWindow/CustomWindow.qml @@ -103,6 +103,35 @@ Window { property alias minimizeEnabled: _title.minimizeEnabled property alias maximizeEnabled: _title.maximizeEnabled + // + // Ensure that window size & position is valid upon showing + // + Component.onCompleted: { + // Reset window size for whatever reason + if (root.width <= 0 || root.height <= 0) { + root.width = root.minimumWidth + root.height = root.minimumHeight + } + + // Startup verifications to ensure that app is displayed inside the screen + if (root.x < 0 || root.x >= Screen.desktopAvailableWidth) + root.x = 100 + if (root.y < 0 || root.y >= Screen.desktopAvailableHeight) + root.y = 100 + + // Startup verifications to ensure that app fits in current screen + if (root.width > Screen.desktopAvailableWidth) { + root.x = 100 + root.width = Screen.desktopAvailableWidth - root.x + } + + // Startup verifications to ensure that app fits in current screen + if (root.height > Screen.desktopAvailableHeight) { + root.y = 100 + root.height = Screen.desktopAvailableHeight - root.y + } + } + // // Shadow implementation // diff --git a/assets/qml/Windows/MainWindow.qml b/assets/qml/Windows/MainWindow.qml index 11899f1d..7aa43c0e 100644 --- a/assets/qml/Windows/MainWindow.qml +++ b/assets/qml/Windows/MainWindow.qml @@ -82,30 +82,6 @@ FramelessWindow.CustomWindow { // Displays the main window & checks for updates // function showMainWindow() { - // Reset window size for whatever reason - if (root.width <= 0 || root.height <= 0) { - root.width = root.minimumWidth - root.height = root.minimumHeight - } - - // Startup verifications to ensure that app is displayed inside the screen - if (root.x < 0 || root.x >= Screen.desktopAvailableWidth) - root.x = 100 - if (root.y < 0 || root.y >= Screen.desktopAvailableHeight) - root.y = 100 - - // Startup verifications to ensure that app fits in current screen - if (root.width > Screen.desktopAvailableWidth) { - root.x = 100 - root.width = Screen.desktopAvailableWidth - root.x - } - - // Startup verifications to ensure that app fits in current screen - if (root.height > Screen.desktopAvailableHeight) { - root.y = 100 - root.height = Screen.desktopAvailableHeight - root.y - } - // Increment app launch count & hide splash screen ++appLaunchCount Cpp_ModuleManager.hideSplashscreen() diff --git a/assets/qml/main.qml b/assets/qml/main.qml index 35ee3c11..581fbf4d 100644 --- a/assets/qml/main.qml +++ b/assets/qml/main.qml @@ -99,7 +99,7 @@ Item { // Donations dialog // Loader { - asynchronous: true + asynchronous: false sourceComponent: Windows.Donate { Component.onCompleted: app.donations = this }