From: Rene Gassmoeller Date: Tue, 11 Apr 2017 22:33:25 +0000 (-0600) Subject: Store and restore window state X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=12977cd35c22bd9f533fd8c71bcdc5398695b01a;p=parameter_gui.git Store and restore window state --- diff --git a/mainwindow.cpp b/mainwindow.cpp index 0d70868..40b79e7 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -80,7 +80,10 @@ namespace dealii statusBar()->showMessage(tr("Ready, start editing by double-clicking or hitting F2!")); setWindowTitle(tr("[*]parameterGUI")); - showMaximized(); + gui_settings->beginGroup("MainWindow"); + resize(gui_settings->value("size", QSize(800, 600)).toSize()); + move(gui_settings->value("pos", QPoint(0, 0)).toPoint()); + gui_settings->endGroup(); // if there is a file_name, try to load the file. // a valid file has the xml extension, so we require size() > 3 @@ -372,7 +375,14 @@ namespace dealii // First check, if we have to save modified content. // If not, or the content was saved, accept the event, otherwise ignore it if (maybe_save()) - event->accept(); + { + gui_settings->beginGroup("MainWindow"); + gui_settings->setValue("size", size()); + gui_settings->setValue("pos", pos()); + gui_settings->endGroup(); + + event->accept(); + } else event->ignore(); }