support for storing/recovering the server window positions (#357)

This commit is contained in:
Volker Fischer 2020-06-14 08:49:58 +02:00
parent 2285148cb8
commit e883a51db9
6 changed files with 42 additions and 11 deletions

View File

@ -9,6 +9,7 @@
- support sorting faders by channel instrument, coded by Alberstein8 (#356)
- support for storing/recovering the server window positions (#357)

View File

@ -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 ),

View File

@ -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 )

View File

@ -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 );

View File

@ -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<QTreeWidgetItem*> vecpListViewItems;
QMutex ListViewMutex;
CVector<QTreeWidgetItem*> 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(); }

View File

@ -427,6 +427,10 @@ if ( GetFlagIniSet ( IniXMLDocument, "server", "defcentservaddr", bValue ) )
{
pServer->SetLicenceType ( static_cast<ELicenceType> ( 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<int> ( 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