From 75c4f70b6d788496eaa018cbb5887aca9e7e5a99 Mon Sep 17 00:00:00 2001 From: Ladislav Foldyna Date: Tue, 23 Jul 2024 15:11:19 +0200 Subject: [PATCH] Fixed #418 - Windows State/Size does not save in case of fullscreen (2) QApplication::desktop is obsoleted and QT6.x does not implement it. This commit uses QGuiApplication::screens --- ui/MainWindow.cpp | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/ui/MainWindow.cpp b/ui/MainWindow.cpp index f72d1af7..cc65c5ed 100644 --- a/ui/MainWindow.cpp +++ b/ui/MainWindow.cpp @@ -573,7 +573,10 @@ void MainWindow::setLayoutGeometry() { restoreGeometry(layoutProfile.mainGeometry); if ( isMaximized() ) - setGeometry( QApplication::desktop()->availableGeometry( this ) ); + { + const QList &screens = QGuiApplication::screens(); + setGeometry( screens[0]->availableGeometry() ); + } restoreState(layoutProfile.mainState); darkLightModeSwith->setChecked(layoutProfile.darkMode); } @@ -581,7 +584,10 @@ void MainWindow::setLayoutGeometry() { restoreGeometry(settings.value("geometry").toByteArray()); if ( isMaximized() ) - setGeometry( QApplication::desktop()->availableGeometry( this ) ); + { + const QList &screens = QGuiApplication::screens(); + setGeometry( screens[0]->availableGeometry() ); + } restoreState(settings.value("windowState").toByteArray()); // leave dark mode as is } @@ -699,6 +705,11 @@ void MainWindow::setupLayoutMenu() || layoutProfile.mainState != QByteArray() ) { restoreGeometry(layoutProfile.mainGeometry); + if ( isMaximized() ) + { + const QList &screens = QGuiApplication::screens(); + setGeometry( screens[0]->availableGeometry() ); + } restoreState(layoutProfile.mainState); darkLightModeSwith->setChecked(isFusionStyle && layoutProfile.darkMode); }