diff options
author | Bent Bisballe Nyeng <deva@aasimon.org> | 2018-12-28 12:14:54 +0100 |
---|---|---|
committer | Bent Bisballe Nyeng <deva@aasimon.org> | 2018-12-28 12:14:54 +0100 |
commit | 0ee75305070f79b12cbfa5a31b17c543d0517428 (patch) | |
tree | d49940c5ad2eb22ba2329d3098a1487678fdd63b /src/mainwindow.cc | |
parent | 5e5f62b77f34d8a9c0fdaed1fd5559057c48c077 (diff) |
Save window size and state.
Diffstat (limited to 'src/mainwindow.cc')
-rw-r--r-- | src/mainwindow.cc | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/src/mainwindow.cc b/src/mainwindow.cc index e2fe4b4..cfaece1 100644 --- a/src/mainwindow.cc +++ b/src/mainwindow.cc @@ -40,6 +40,7 @@ #include <QStatusBar> #include <QFileInfo> #include <QFileDialog> +#include <QSettings> MainWindow::MainWindow(QString p) { @@ -96,6 +97,7 @@ MainWindow::MainWindow(QString p) // Setup toolbar QToolBar *toolbar = new QToolBar(); + toolbar->setObjectName("Execution"); addToolBar(Qt::TopToolBarArea, toolbar); { @@ -113,6 +115,8 @@ MainWindow::MainWindow(QString p) connect(act, SIGNAL(triggered()), this, SLOT(reset())); } + loadSettings(); + statusBar()->showMessage(tr("Ready")); updateWindowTitle(); @@ -134,9 +138,35 @@ void MainWindow::closeEvent(QCloseEvent* event) return; } + saveSettings(); event->accept(); } +void MainWindow::loadSettings() +{ + QByteArray state; + QByteArray geometry; + + QSettings settings; + settings.beginGroup("MainWindow"); + state = settings.value("state").toByteArray(); + geometry = settings.value("geometry").toByteArray(); + settings.endGroup(); + + restoreGeometry(geometry); + restoreState(state); +} + +void MainWindow::saveSettings() +{ + QSettings settings; + + settings.beginGroup("MainWindow"); + settings.setValue("state", saveState()); + settings.setValue("geometry", saveGeometry()); + settings.endGroup(); +} + bool MainWindow::checkDirty() { if(dirty) |