Skip to content
Snippets Groups Projects
Commit b5c71b20 authored by Oliver Bock's avatar Oliver Bock
Browse files

Save/restore window state and layout (on quit/startup)

parent 5d8927f0
Branches
Tags
No related merge requests found
...@@ -19,6 +19,8 @@ ...@@ -19,6 +19,8 @@
******************************************************************************/ ******************************************************************************/
#include "pulsatingscience.h" #include "pulsatingscience.h"
#include <QSettings>
#ifdef __APPLE__ #ifdef __APPLE__
#include "/System/Library/Frameworks/Carbon.framework/Versions/A/Headers/Carbon.h" #include "/System/Library/Frameworks/Carbon.framework/Versions/A/Headers/Carbon.h"
...@@ -110,6 +112,16 @@ PulsatingScience::PulsatingScience(QWidget *parent) : QMainWindow(parent) ...@@ -110,6 +112,16 @@ PulsatingScience::PulsatingScience(QWidget *parent) : QMainWindow(parent)
connect(m_hiddenShortcut, SIGNAL(activated()), connect(m_hiddenShortcut, SIGNAL(activated()),
this, SLOT(toggleHiddenDemoMode())); this, SLOT(toggleHiddenDemoMode()));
// restore previously saved window and splitter layout
QCoreApplication::setOrganizationName("Max-Planck-Insitut für Gravitationsphysik");
QCoreApplication::setOrganizationDomain("aei.mpg.de");
QCoreApplication::setApplicationName("Pulsating Science");
QSettings settings;
restoreGeometry(settings.value("windowGeometry").toByteArray());
restoreState(settings.value("windowState").toByteArray());
ui.splitter->restoreState(settings.value("splitterSizes").toByteArray());
} }
PulsatingScience::~PulsatingScience() PulsatingScience::~PulsatingScience()
...@@ -161,6 +173,12 @@ void PulsatingScience::closeEvent(QCloseEvent *event) ...@@ -161,6 +173,12 @@ void PulsatingScience::closeEvent(QCloseEvent *event)
event->ignore(); event->ignore();
} }
else { else {
// save splitter layout
QSettings settings;
settings.setValue("windowGeometry", saveGeometry());
settings.setValue("windowState", saveState());
settings.setValue("splitterSizes", ui.splitter->saveState());
event->accept(); event->accept();
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment