From 0ee75305070f79b12cbfa5a31b17c543d0517428 Mon Sep 17 00:00:00 2001 From: Bent Bisballe Nyeng Date: Fri, 28 Dec 2018 12:14:54 +0100 Subject: Save window size and state. --- src/mainwindow.cc | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'src/mainwindow.cc') 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 #include #include +#include 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) -- cgit v1.2.3