Patch 2 fixing Window size and position

Guido Lerch guido.lerch at gmail.com
Fri Oct 9 08:50:05 PDT 2015


Addition to the last window size patch for El Captain.

Caviar/ not solved yet.

On Mavericks, when closing out of full screen the window will be maximized.
On El Captain window size, position, state are working as expected.

I am investigating the behaviour on Mavericks now

-- 
Best regards,
Guido
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.subsurface-divelog.org/pipermail/subsurface/attachments/20151009/e62592ed/attachment.html>
-------------- next part --------------
From df72c9ce756cd8548496cb25d23601ec6f367ac6 Mon Sep 17 00:00:00 2001
From: glerch <guido.lerch at gmail.com>
Date: Fri, 9 Oct 2015 17:41:36 +0200
Subject: [PATCH] fixing main windows size and position

My last patch was incomplete and not fully tested on
Mavericks resulting that the window x,y, positions were
not restored. This patch has been tested on El Captain and
Mavericks.

This fix does not solve the windows state fullscreen being
preserved. If you store in full screen on Mavericks the
windows will open maximized.

Signed-off-by: glerch <guido.lerch at gmail.com>
---
 qt-ui/mainwindow.cpp | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/qt-ui/mainwindow.cpp b/qt-ui/mainwindow.cpp
index 8759760..9d9e8bf 100644
--- a/qt-ui/mainwindow.cpp
+++ b/qt-ui/mainwindow.cpp
@@ -1085,11 +1085,10 @@ void MainWindow::initialUiSetup()
 {
 	QSettings settings;
 	settings.beginGroup("MainWindow");
-	QSize sz = settings.value("size", qApp->desktop()->size()).value<QSize>();
 	if (settings.value("maximized", isMaximized()).value<bool>())
 		showMaximized();
 	else
-		resize(sz);
+		restoreGeometry(settings.value("geometry").toByteArray());
 
 	state = (CurrentState)settings.value("lastState", 0).toInt();
 	switch (state) {
@@ -1110,6 +1109,7 @@ void MainWindow::initialUiSetup()
 		break;
 	}
 	settings.endGroup();
+	show();
 }
 
 const char *getSetting(QSettings &s, QString name)
@@ -1203,10 +1203,8 @@ void MainWindow::writeSettings()
 	QSettings settings;
 
 	settings.beginGroup("MainWindow");
-	settings.setValue("lastState", (int)state);
+	settings.setValue("geometry", saveGeometry());
 	settings.setValue("maximized", isMaximized());
-	if (!isMaximized())
-		settings.setValue("size", size());
 	if (state == VIEWALL)
 		saveSplitterSizes();
 	settings.endGroup();
-- 
1.9.5 (Apple Git-50.3)



More information about the subsurface mailing list