From 9f0caecf7875f998dc9c85d4f35f985335222d67 Mon Sep 17 00:00:00 2001 From: Arno Date: Mon, 10 May 2010 15:41:08 +0200 Subject: Implemented read/write settings at startup/exit The window position and size is now written to disk on exit and read on startup. Also, the expanded directories from the tree are saved and restored. This means I can get rid of this ugly expand dirs on startup thing. Never liked it very much. --- shemov.cpp | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) (limited to 'shemov.cpp') diff --git a/shemov.cpp b/shemov.cpp index b4b7327..53ae8de 100644 --- a/shemov.cpp +++ b/shemov.cpp @@ -24,6 +24,7 @@ #include #include #include +#include #include #include "shemov.h" @@ -101,10 +102,18 @@ SheMov::SheMov(QWidget *parent, Qt::WindowFlags flags) : QMainWindow(parent, fla QWidget *centralWidget = new QWidget; centralWidget->setLayout(mainLayout); setCentralWidget(centralWidget); - showMaximized(); + readSettings(); + mFSWidget->readSettings(); + show(); mFSWidget->fileView()->setFocus(Qt::ActiveWindowFocusReason); } +void SheMov::closeEvent(QCloseEvent *event){ + mFSWidget->writeSettings(); + writeSettings(); + event->accept(); +} + void SheMov::updateSelectionCount(const QItemSelection & /* sel */, const QItemSelection & /* prev */){ QLocale l; switch (mTab->currentIndex()) { @@ -444,3 +453,22 @@ void SheMov::createExtractMenu(){ } } +void SheMov::writeSettings(){ + QSettings s; + s.setValue("windows/mainpos", pos()); + s.setValue("windows/mainsize", size()); + bool winState = windowState() & Qt::WindowMaximized; + s.setValue("windows/maximized", winState); +} + +void SheMov::readSettings(){ + QSettings s; + QPoint winPos = s.value("windwos/mainpos").toPoint(); + QSize winSize = s.value("windows/mainsize").toSize(); + bool winState = s.value("windows/maximized", false).toBool(); + resize(winSize); + move(winPos); + if(winState){ + setWindowState(Qt::WindowMaximized); + } +} -- cgit v1.2.3-70-g09d2