From e883a51db9bc6870b9dbcbb2e0ab70d92cc337e2 Mon Sep 17 00:00:00 2001 From: Volker Fischer Date: Sun, 14 Jun 2020 08:49:58 +0200 Subject: [PATCH] support for storing/recovering the server window positions (#357) --- ChangeLog | 1 + src/server.cpp | 1 + src/server.h | 3 +++ src/serverdlg.cpp | 17 +++++++++++++++++ src/serverdlg.h | 23 ++++++++++++----------- src/settings.cpp | 8 ++++++++ 6 files changed, 42 insertions(+), 11 deletions(-) diff --git a/ChangeLog b/ChangeLog index 1baa93cb..603224b3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -9,6 +9,7 @@ - support sorting faders by channel instrument, coded by Alberstein8 (#356) +- support for storing/recovering the server window positions (#357) diff --git a/src/server.cpp b/src/server.cpp index 31e9ef6b..f9266e0b 100755 --- a/src/server.cpp +++ b/src/server.cpp @@ -234,6 +234,7 @@ CServer::CServer ( const int iNewMaxNumChan, const bool bNDisconnectAllClientsOnQuit, const bool bNUseDoubleSystemFrameSize, const ELicenceType eNLicenceType ) : + vecWindowPosMain (), // empty array bUseDoubleSystemFrameSize ( bNUseDoubleSystemFrameSize ), iMaxNumChannels ( iNewMaxNumChan ), Socket ( this, iPortNumber ), diff --git a/src/server.h b/src/server.h index db5dd24a..113c4e69 100755 --- a/src/server.h +++ b/src/server.h @@ -251,6 +251,9 @@ public: void SetLicenceType ( const ELicenceType NLiType ) { eLicenceType = NLiType; } ELicenceType GetLicenceType() { return eLicenceType; } + // window position/state settings + QByteArray vecWindowPosMain; + protected: // access functions for actual channels bool IsConnected ( const int iChanNum ) diff --git a/src/serverdlg.cpp b/src/serverdlg.cpp index e8f8c417..ab43358c 100755 --- a/src/serverdlg.cpp +++ b/src/serverdlg.cpp @@ -332,6 +332,14 @@ lvwClients->setMinimumHeight ( 140 ); layout()->setMenuBar ( pMenu ); + // Window positions -------------------------------------------------------- + // main window + if ( !pServer->vecWindowPosMain.isEmpty() && !pServer->vecWindowPosMain.isNull() ) + { + restoreGeometry ( pServer->vecWindowPosMain ); + } + + // Connections ------------------------------------------------------------- // check boxes QObject::connect ( chbRegisterServer, &QCheckBox::stateChanged, @@ -399,6 +407,15 @@ lvwClients->setMinimumHeight ( 140 ); Timer.start ( GUI_CONTRL_UPDATE_TIME ); } +void CServerDlg::closeEvent ( QCloseEvent* Event ) +{ + // store window positions + pServer->vecWindowPosMain = saveGeometry(); + + // default implementation of this event handler routine + Event->accept(); +} + void CServerDlg::OnStartOnOSStartStateChanged ( int value ) { const bool bCurAutoStartMinState = ( value == Qt::Checked ); diff --git a/src/serverdlg.h b/src/serverdlg.h index 80fe109a..e2ddd336 100755 --- a/src/serverdlg.h +++ b/src/serverdlg.h @@ -58,6 +58,7 @@ public: protected: virtual void changeEvent ( QEvent* pEvent ); + virtual void closeEvent ( QCloseEvent* Event ); void UpdateGUIDependencies(); void UpdateSystemTrayIcon ( const bool bIsActive ); @@ -65,20 +66,20 @@ protected: void ModifyAutoStartEntry ( const bool bDoAutoStart ); void UpdateRecorderStatus( QString sessionDir ); - QTimer Timer; - CServer* pServer; - CSettings* pSettings; + QTimer Timer; + CServer* pServer; + CSettings* pSettings; - CVector vecpListViewItems; - QMutex ListViewMutex; + CVector vecpListViewItems; + QMutex ListViewMutex; - QMenuBar* pMenu; + QMenuBar* pMenu; - bool bSystemTrayIconAvaialbe; - QSystemTrayIcon SystemTrayIcon; - QPixmap BitmapSystemTrayInactive; - QPixmap BitmapSystemTrayActive; - QMenu* pSystemTrayIconMenu; + bool bSystemTrayIconAvaialbe; + QSystemTrayIcon SystemTrayIcon; + QPixmap BitmapSystemTrayInactive; + QPixmap BitmapSystemTrayActive; + QMenu* pSystemTrayIconMenu; public slots: void OnAboutToQuit() { pSettings->Save(); } diff --git a/src/settings.cpp b/src/settings.cpp index 5fba0ea9..0920d18b 100755 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -427,6 +427,10 @@ if ( GetFlagIniSet ( IniXMLDocument, "server", "defcentservaddr", bValue ) ) { pServer->SetLicenceType ( static_cast ( iValue ) ); } + + // window position of the main window + pServer->vecWindowPosMain = FromBase64ToByteArray ( + GetIniSetting ( IniXMLDocument, "server", "winposmain_base64" ) ); } } @@ -666,6 +670,10 @@ void CSettings::Save() // licence type SetNumericIniSet ( IniXMLDocument, "server", "licencetype", static_cast ( pServer->GetLicenceType() ) ); + + // window position of the main window + PutIniSetting ( IniXMLDocument, "server", "winposmain_base64", + ToBase64 ( pServer->vecWindowPosMain ) ); } // prepare file name for storing initialization data in XML file and store