From 8ae66fd1a5f4ff88a1b63cd08df88452732469e7 Mon Sep 17 00:00:00 2001 From: Volker Fischer Date: Mon, 26 Aug 2013 19:59:18 +0000 Subject: [PATCH] store window positions and visability state --- src/client.cpp | 7 ++++++ src/client.h | 9 +++++++ src/clientdlg.cpp | 53 +++++++++++++++++++++++++++++++++++++++- src/settings.cpp | 62 +++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 130 insertions(+), 1 deletion(-) diff --git a/src/client.cpp b/src/client.cpp index 64f4eeb5..c128c2eb 100755 --- a/src/client.cpp +++ b/src/client.cpp @@ -31,6 +31,13 @@ CClient::CClient ( const quint16 iPortNumber ) : ChannelInfo (), vecStoredFaderTags ( MAX_NUM_STORED_FADER_LEVELS, "" ), vecStoredFaderLevels ( MAX_NUM_STORED_FADER_LEVELS, AUD_MIX_FADER_MAX ), + vecWindowPosMain (), // empty array + vecWindowPosSettings (), // empty array + vecWindowPosChat (), // empty array + vecWindowPosConnect (), // empty array + bWindowWasShownSettings ( false ), + bWindowWasShownChat ( false ), + bWindowWasShownConnect ( false ), Channel ( false ), /* we need a client channel -> "false" */ eAudioCompressionType ( CT_OPUS ), iCeltNumCodedBytes ( CELT_NUM_BYTES_MONO_LOW_QUALITY ), diff --git a/src/client.h b/src/client.h index afc15a0c..155652f7 100755 --- a/src/client.h +++ b/src/client.h @@ -266,6 +266,15 @@ public: CVector vecStoredFaderTags; CVector vecStoredFaderLevels; + // window position/state settings + QByteArray vecWindowPosMain; + QByteArray vecWindowPosSettings; + QByteArray vecWindowPosChat; + QByteArray vecWindowPosConnect; + bool bWindowWasShownSettings; + bool bWindowWasShownChat; + bool bWindowWasShownConnect; + #ifdef LLCON_VST_PLUGIN // VST version must have direct access to sound object CSound* GetSound() { return &Sound; } diff --git a/src/clientdlg.cpp b/src/clientdlg.cpp index 63e91258..a3a6f9e9 100755 --- a/src/clientdlg.cpp +++ b/src/clientdlg.cpp @@ -375,6 +375,47 @@ CClientDlg::CClientDlg ( CClient* pNCliP, } + // Window positions -------------------------------------------------------- + // main window + if ( !pClient->vecWindowPosMain.isEmpty() && !pClient->vecWindowPosMain.isNull() ) + { + restoreGeometry ( pClient->vecWindowPosMain ); + } + + // settings window + if ( !pClient->vecWindowPosSettings.isEmpty() && !pClient->vecWindowPosSettings.isNull() ) + { + ClientSettingsDlg.restoreGeometry ( pClient->vecWindowPosSettings ); + } + + if ( pClient->bWindowWasShownSettings ) + { + ShowGeneralSettings(); + } + + // chat window + if ( !pClient->vecWindowPosChat.isEmpty() && !pClient->vecWindowPosChat.isNull() ) + { + ChatDlg.restoreGeometry ( pClient->vecWindowPosChat ); + } + + if ( pClient->bWindowWasShownChat ) + { + ShowChatWindow(); + } + + // connection setup window + if ( !pClient->vecWindowPosConnect.isEmpty() && !pClient->vecWindowPosConnect.isNull() ) + { + ConnectDlg.restoreGeometry ( pClient->vecWindowPosConnect ); + } + + if ( pClient->bWindowWasShownConnect ) + { + ShowConnectionSetupDialog(); + } + + // Connections ------------------------------------------------------------- // push buttons QObject::connect ( butConnect, SIGNAL ( clicked() ), @@ -489,10 +530,20 @@ CClientDlg::CClientDlg ( CClient* pNCliP, void CClientDlg::closeEvent ( QCloseEvent* Event ) { + // store window positions + pClient->vecWindowPosMain = saveGeometry(); + pClient->vecWindowPosSettings = ClientSettingsDlg.saveGeometry(); + pClient->vecWindowPosChat = ChatDlg.saveGeometry(); + pClient->vecWindowPosConnect = ConnectDlg.saveGeometry(); + + pClient->bWindowWasShownSettings = ClientSettingsDlg.isVisible(); + pClient->bWindowWasShownChat = ChatDlg.isVisible(); + pClient->bWindowWasShownConnect = ConnectDlg.isVisible(); + // if settings/connect dialog or chat dialog is open, close it ClientSettingsDlg.close(); - ConnectDlg.close(); ChatDlg.close(); + ConnectDlg.close(); AnalyzerConsole.close(); // if connected, terminate connection diff --git a/src/settings.cpp b/src/settings.cpp index ccfe2ef6..46cb94c5 100755 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -234,6 +234,40 @@ void CSettings::Load() { pClient->SetUseDefaultCentralServerAddress ( bValue ); } + + // window position of the main window + pClient->vecWindowPosMain = QByteArray().fromBase64 ( + GetIniSetting ( IniXMLDocument, "client", "winposmain" ).toLatin1() ); + + // window position of the settings window + pClient->vecWindowPosSettings = QByteArray().fromBase64 ( + GetIniSetting ( IniXMLDocument, "client", "winposset" ).toLatin1() ); + + // window position of the chat window + pClient->vecWindowPosChat = QByteArray().fromBase64 ( + GetIniSetting ( IniXMLDocument, "client", "winposchat" ).toLatin1() ); + + // window position of the connect window + pClient->vecWindowPosConnect = QByteArray().fromBase64 ( + GetIniSetting ( IniXMLDocument, "client", "winposcon" ).toLatin1() ); + + // visibility state of the settings window + if ( GetFlagIniSet ( IniXMLDocument, "client", "winvisset", bValue ) ) + { + pClient->bWindowWasShownSettings = bValue; + } + + // visibility state of the chat window + if ( GetFlagIniSet ( IniXMLDocument, "client", "winvischat", bValue ) ) + { + pClient->bWindowWasShownChat = bValue; + } + + // visibility state of the connect window + if ( GetFlagIniSet ( IniXMLDocument, "client", "winviscon", bValue ) ) + { + pClient->bWindowWasShownConnect = bValue; + } } else { @@ -392,6 +426,34 @@ void CSettings::Save() // use default central server address flag SetFlagIniSet ( IniXMLDocument, "client", "defcentservaddr", pClient->GetUseDefaultCentralServerAddress() ); + + // window position of the main window + PutIniSetting ( IniXMLDocument, "client", "winposmain", + QString().fromLatin1 ( pClient->vecWindowPosMain.toBase64() ) ); + + // window position of the settings window + PutIniSetting ( IniXMLDocument, "client", "winposset", + QString().fromLatin1 ( pClient->vecWindowPosSettings.toBase64() ) ); + + // window position of the chat window + PutIniSetting ( IniXMLDocument, "client", "winposchat", + QString().fromLatin1 ( pClient->vecWindowPosChat.toBase64() ) ); + + // window position of the connect window + PutIniSetting ( IniXMLDocument, "client", "winposcon", + QString().fromLatin1 ( pClient->vecWindowPosConnect.toBase64() ) ); + + // visibility state of the settings window + SetFlagIniSet ( IniXMLDocument, "client", "winvisset", + pClient->bWindowWasShownSettings ); + + // visibility state of the chat window + SetFlagIniSet ( IniXMLDocument, "client", "winvischat", + pClient->bWindowWasShownChat ); + + // visibility state of the connect window + SetFlagIniSet ( IniXMLDocument, "client", "winviscon", + pClient->bWindowWasShownConnect ); } else {