[PATCH] MainWindow: store the window maximized state

Lubomir I. Ivanov neolit123 at gmail.com
Mon Dec 2 02:32:27 UTC 2013

From: "Lubomir I. Ivanov" <neolit123 at gmail.com>

We add the "maximized" entry for the settings group "MainWindow",
and store it on close, so that the window state is the same on
the next run. But then also, we only store the window size and resize
to that size if not maximized. This attempts to preserve a "restored"
window size.

Signed-off-by: Lubomir I. Ivanov <neolit123 at gmail.com>
 qt-ui/mainwindow.cpp | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/qt-ui/mainwindow.cpp b/qt-ui/mainwindow.cpp
index 67ec07e..4929dd9 100644
--- a/qt-ui/mainwindow.cpp
+++ b/qt-ui/mainwindow.cpp
@@ -594,7 +594,10 @@ void MainWindow::initialUiSetup()
 	QSettings settings;
 	QSize sz = settings.value("size", qApp->desktop()->size()).value<QSize>();
-	resize(sz);
+	if (settings.value("maximized", isMaximized()).value<bool>())
+		showMaximized();
+	else
+		resize(sz);
 	state = (CurrentState) settings.value("lastState", 0).toInt();
@@ -670,7 +673,9 @@ void MainWindow::writeSettings()
 	settings.setValue("lastState", (int) state);
-	settings.setValue("size",size());
+	settings.setValue("maximized", isMaximized());
+	if (!isMaximized())
+		settings.setValue("size", size());
 	if (state == VIEWALL){

More information about the subsurface mailing list