From 67c306b5278753bd5cc4eefc1dbeac8cc08e7913 Mon Sep 17 00:00:00 2001 From: glerch Date: Fri, 9 Oct 2015 18:03:12 +0200 Subject: Fix main window size, position, and state Now size, position and state should be preserved correctly. Signed-off-by: glerch Signed-off-by: Dirk Hohndel --- qt-ui/mainwindow.cpp | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'qt-ui/mainwindow.cpp') diff --git a/qt-ui/mainwindow.cpp b/qt-ui/mainwindow.cpp index d0f2f9127..f9bfd775b 100644 --- a/qt-ui/mainwindow.cpp +++ b/qt-ui/mainwindow.cpp @@ -1085,11 +1085,12 @@ void MainWindow::initialUiSetup() { QSettings settings; settings.beginGroup("MainWindow"); - QSize sz = settings.value("size", qApp->desktop()->size()).value(); - if (settings.value("maximized", isMaximized()).value()) + if (settings.value("maximized", isMaximized()).value()) { showMaximized(); - else - resize(sz); + } else { + restoreGeometry(settings.value("geometry").toByteArray()); + restoreState(settings.value("windowState", 0).toByteArray()); + } state = (CurrentState)settings.value("lastState", 0).toInt(); switch (state) { @@ -1110,6 +1111,7 @@ void MainWindow::initialUiSetup() break; } settings.endGroup(); + show(); } const char *getSetting(QSettings &s, QString name) @@ -1203,10 +1205,10 @@ void MainWindow::writeSettings() QSettings settings; settings.beginGroup("MainWindow"); - settings.setValue("lastState", (int)state); + settings.setValue("geometry", saveGeometry()); + settings.setValue("windowState", saveState()); settings.setValue("maximized", isMaximized()); - if (!isMaximized()) - settings.setValue("size", size()); + settings.setValue("lastState", (int)state); if (state == VIEWALL) saveSplitterSizes(); settings.endGroup(); -- cgit v1.2.3-70-g09d2