From 3b762e26dff0191b19fa161d223b663a61b999fc Mon Sep 17 00:00:00 2001 From: Konrad Rosenbaum Date: Sun, 22 May 2016 22:36:06 +0200 Subject: [PATCH] restore window size on next login --- src/dialogs/login.cpp | 2 +- src/mwin/overview.cpp | 17 +++++++++++++++++ src/mwin/overview.h | 5 ++++- 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/src/dialogs/login.cpp b/src/dialogs/login.cpp index c07d9fb..b72330b 100644 --- a/src/dialogs/login.cpp +++ b/src/dialogs/login.cpp @@ -148,7 +148,7 @@ void MLogin::startLogin() pd.setLabelText(txt); } ); - mo->showMaximized(); + mo->showRestored(); //make sure the application exits (only) after everything is cleaned up qApp->setQuitOnLastWindowClosed(false); diff --git a/src/mwin/overview.cpp b/src/mwin/overview.cpp index 41231cd..3fa34c1 100644 --- a/src/mwin/overview.cpp +++ b/src/mwin/overview.cpp @@ -202,14 +202,31 @@ void MOverview::runStartupScript() engine.evalFile("startup.js"); } +#define GEOGROUP "magicSmokeClient/MainWindow/state" + void MOverview::closeEvent(QCloseEvent*ce) { //make sure session is deleted req->logout(); + //store geometry + QSettings set; + set.beginGroup(GEOGROUP); + set.setValue("geometry",saveGeometry()); + set.setValue("state",saveState()); //actually close window QMainWindow::closeEvent(ce); } +void MOverview::showRestored() +{ + QSettings set; + set.beginGroup(GEOGROUP); + if(!restoreGeometry(set.value("geometry").toByteArray())||!restoreState(set.value("state").toByteArray())) + showMaximized(); + else + show(); +} + MOverview::~MOverview() { qDebug()<<"destructing overview"<