From 3e8578f2fdef751cff1c6b60ce9aa5e4e08de274 Mon Sep 17 00:00:00 2001 From: Rosalie Wanders Date: Sun, 22 Jan 2023 12:50:56 +0100 Subject: [PATCH] RMG: store & load maximized state --- Source/RMG/UserInterface/MainWindow.cpp | 21 +++++++++++++++++++-- Source/RMG/UserInterface/MainWindow.hpp | 1 + 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/Source/RMG/UserInterface/MainWindow.cpp b/Source/RMG/UserInterface/MainWindow.cpp index 1879b645..6e29c9b4 100644 --- a/Source/RMG/UserInterface/MainWindow.cpp +++ b/Source/RMG/UserInterface/MainWindow.cpp @@ -169,8 +169,15 @@ void MainWindow::configureUI(QApplication* app) this->setCentralWidget(this->ui_Widgets); QString geometry; + bool maximized; + geometry = QString::fromStdString(CoreSettingsGetStringValue(SettingsID::RomBrowser_Geometry)); - if (!geometry.isEmpty()) + maximized = CoreSettingsGetBoolValue(SettingsID::RomBrowser_Maximized); + if (maximized) + { + this->showMaximized(); + } + else if (!geometry.isEmpty()) { this->restoreGeometry(QByteArray::fromBase64(geometry.toLocal8Bit())); } @@ -294,10 +301,12 @@ void MainWindow::storeGeometry(void) } this->ui_Geometry = this->saveGeometry(); + this->ui_Geometry_Maximized = this->isMaximized(); this->ui_Geometry_Saved = true; std::string geometryStr = this->ui_Geometry.toBase64().toStdString(); CoreSettingsSetValue(SettingsID::RomBrowser_Geometry, geometryStr); + CoreSettingsSetValue(SettingsID::RomBrowser_Maximized, this->ui_Geometry_Maximized); } void MainWindow::loadGeometry(void) @@ -309,7 +318,15 @@ void MainWindow::loadGeometry(void) this->setMinimumSize(0, 0); this->setMaximumSize(QWIDGETSIZE_MAX, QWIDGETSIZE_MAX); - this->restoreGeometry(this->ui_Geometry); + + if (this->ui_Geometry_Maximized) + { + this->showMaximized(); + } + else + { + this->restoreGeometry(this->ui_Geometry); + } if (this->isFullScreen()) { diff --git a/Source/RMG/UserInterface/MainWindow.hpp b/Source/RMG/UserInterface/MainWindow.hpp index 921ad7a4..48e51ed9 100644 --- a/Source/RMG/UserInterface/MainWindow.hpp +++ b/Source/RMG/UserInterface/MainWindow.hpp @@ -62,6 +62,7 @@ class MainWindow : public QMainWindow, private Ui::MainWindow QLabel *ui_StatusBar_Label; QByteArray ui_Geometry; + bool ui_Geometry_Maximized = false; bool ui_Geometry_Saved = false; bool ui_AllowManualResizing = false;