From 09dc35688398b2dde41817828c4c657143506d3b Mon Sep 17 00:00:00 2001 From: Sky Date: Sun, 3 Nov 2013 00:45:25 +0000 Subject: [PATCH] Main window geometry and state saving/reloading --- MultiMC.cpp | 6 ++++++ gui/mainwindow.cpp | 7 ++++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/MultiMC.cpp b/MultiMC.cpp index d13d1443..bb65050f 100644 --- a/MultiMC.cpp +++ b/MultiMC.cpp @@ -336,6 +336,10 @@ void MultiMC::initGlobalSettings() QUuid uuid = QUuid::createUuid(); m_settings->set("YggdrasilClientToken", uuid.toString()); } + + // Window state and geometry + m_settings->registerSetting(new Setting("MainWindowState", "")); + m_settings->registerSetting(new Setting("MainWindowGeometry", "")); } void MultiMC::initHttpMetaCache() @@ -398,6 +402,8 @@ int main_gui(MultiMC &app) { // show main window MainWindow mainWin; + mainWin.restoreState(QByteArray::fromBase64(MMC->settings()->get("MainWindowState").toByteArray())); + mainWin.restoreGeometry(QByteArray::fromBase64(MMC->settings()->get("MainWindowGeometry").toByteArray())); mainWin.show(); mainWin.checkSetDefaultJava(); return app.exec(); diff --git a/gui/mainwindow.cpp b/gui/mainwindow.cpp index b2fdbe16..00cfacf7 100644 --- a/gui/mainwindow.cpp +++ b/gui/mainwindow.cpp @@ -449,9 +449,10 @@ void MainWindow::on_actionEditInstMods_triggered() void MainWindow::closeEvent(QCloseEvent *event) { // Save the window state and geometry. - // TODO: Make this work with the new settings system. - // settings->getConfig().setValue("MainWindowGeometry", saveGeometry()); - // settings->getConfig().setValue("MainWindowState", saveState()); + + MMC->settings()->set("MainWindowState", saveState().toBase64()); + MMC->settings()->set("MainWindowGeometry", saveGeometry().toBase64()); + QMainWindow::closeEvent(event); QApplication::exit(); }