Skip to content

Commit ede13b2

Browse files
committed
Add full window state saving
Saving and restoring of window sizes and states (normal and maximized) has been added, as well as the position of internal window elements, including toolbars. Fixes #69
1 parent 57d5bf2 commit ede13b2

File tree

1 file changed

+5
-9
lines changed

1 file changed

+5
-9
lines changed

omodsim/mainwindow.cpp

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1840,13 +1840,7 @@ void MainWindow::loadSettings()
18401840

18411841
QSettings m(filepath, QSettings::IniFormat, this);
18421842

1843-
const auto geometry = m.value("WindowGeometry", this->geometry()).toRect();
1844-
setGeometry(geometry);
1845-
1846-
const bool isMaximized = m.value("WindowMaximized").toBool();
1847-
if(isMaximized) {
1848-
showMaximized();
1849-
}
1843+
restoreGeometry(m.value("WindowGeometry").toByteArray());
18501844

18511845
const auto viewMode = (QMdiArea::ViewMode)qBound(0, m.value("ViewMode", QMdiArea::SubWindowView).toInt(), 1);
18521846
ui->mdiArea->setViewMode(viewMode);
@@ -1901,6 +1895,8 @@ void MainWindow::loadSettings()
19011895
}
19021896
}
19031897
}
1898+
1899+
restoreState(m.value("WindowState").toByteArray());
19041900
}
19051901

19061902
///
@@ -1934,8 +1930,8 @@ void MainWindow::saveSettings()
19341930
m.clear();
19351931
m.sync();
19361932

1937-
m.setValue("WindowMaximized", isMaximized());
1938-
m.setValue("WindowGeometry", isMaximized()? normalGeometry() : geometry());
1933+
m.setValue("WindowGeometry", saveGeometry());
1934+
m.setValue("WindowState", saveState());
19391935

19401936
const auto frm = currentMdiChild();
19411937
if(frm) m.setValue("ActiveWindow", frm->windowTitle());

0 commit comments

Comments
 (0)