restore window size on next login
authorKonrad Rosenbaum <konrad@silmor.de>
Sun, 22 May 2016 20:36:06 +0000 (22:36 +0200)
committerKonrad Rosenbaum <konrad@silmor.de>
Sun, 22 May 2016 20:36:06 +0000 (22:36 +0200)
src/dialogs/login.cpp
src/mwin/overview.cpp
src/mwin/overview.h

index c07d9fb..b72330b 100644 (file)
@@ -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);
index 41231cd..3fa34c1 100644 (file)
@@ -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"<<hex<<(long)this;
index 9628d32..f845e2b 100644 (file)
@@ -53,7 +53,7 @@ class MOverview:public MTabWin
                ~MOverview();
        protected:
                /**handle closing the window: close the session too*/
-               void closeEvent(QCloseEvent*);
+               void closeEvent(QCloseEvent*) override;
                
        private slots:
                /**try to log in again*/
@@ -97,6 +97,9 @@ class MOverview:public MTabWin
                void userAudit();
                
        public slots:
+               ///restore the window
+               void showRestored();
+
                /**manage customers*/
                void customerMgmt();