diff --git a/src/client.cpp b/src/client.cpp index 4d4cf157..33092b23 100755 --- a/src/client.cpp +++ b/src/client.cpp @@ -33,7 +33,7 @@ CClient::CClient ( const quint16 iPortNumber ) : iAudioInFader ( AUD_FADER_IN_MIDDLE ), iReverbLevel ( 0 ), bReverbOnLeftChan ( false ), - strIPAddress ( "" ), strName ( "" ), + vstrIPAddress ( MAX_NUM_SERVER_ADDR_ITEMS, "" ), strName ( "" ), bOpenChatOnNewMessage ( true ), bDoAutoSockBufSize ( true ), iSndCrdPreferredMonoBlSizeIndex ( CSndCrdBufferSizes::GetDefaultIndex() ), diff --git a/src/client.h b/src/client.h index 51ab535a..a63eba0a 100755 --- a/src/client.h +++ b/src/client.h @@ -155,7 +155,7 @@ public: // settings - QString strIPAddress; + CVector vstrIPAddress; QString strName; protected: diff --git a/src/global.h b/src/global.h index 1c2a66aa..31bc55ae 100755 --- a/src/global.h +++ b/src/global.h @@ -96,6 +96,9 @@ #define MAX_NUMBER_SOUND_CARDS 10 #define INVALID_SNC_CARD_DEVICE -1 +// maximum number of elemts in the server address combo box +#define MAX_NUM_SERVER_ADDR_ITEMS 6 + // defines for LED input level meter #define NUM_STEPS_INP_LEV_METER 10 #define YELLOW_BOUND_INP_LEV_METER 7 diff --git a/src/llconclientdlg.cpp b/src/llconclientdlg.cpp index 60fb69af..5e72a608 100755 --- a/src/llconclientdlg.cpp +++ b/src/llconclientdlg.cpp @@ -60,7 +60,7 @@ CLlconClientDlg::CLlconClientDlg ( CClient* pNCliP, QWidget* parent, "the tag string of your fader can be set. This tag will appear " "at your fader on the mixer board when connected to the server."); TextLabelServerTag->setWhatsThis ( strFaderTag ); - LineEditFaderTag->setWhatsThis ( strFaderTag ); + LineEditFaderTag->setWhatsThis ( strFaderTag ); QString strAudFader = tr ( "Audio Fader: With the audio fader " "control the level of left and right audio input channels can " @@ -91,8 +91,18 @@ CLlconClientDlg::CLlconClientDlg ( CClient* pNCliP, QWidget* parent, // init fader tag line edit LineEditFaderTag->setText ( pClient->strName ); - // init server address line edit - LineEditServerAddr->setText ( pClient->strIPAddress ); + // init server address combo box (max MAX_NUM_SERVER_ADDR_ITEMS entries) + LineEditServerAddr->setMaxCount ( MAX_NUM_SERVER_ADDR_ITEMS ); + LineEditServerAddr->setInsertPolicy ( QComboBox::InsertAtTop ); + + // load data from ini file + for ( int iLEIdx = 0; iLEIdx < MAX_NUM_SERVER_ADDR_ITEMS; iLEIdx++ ) + { + if ( !pClient->vstrIPAddress[iLEIdx].isEmpty() ) + { + LineEditServerAddr->addItem ( pClient->vstrIPAddress[iLEIdx] ); + } + } // we want the cursor to be at IP address line edit at startup LineEditServerAddr->setFocus(); @@ -180,6 +190,10 @@ CLlconClientDlg::CLlconClientDlg ( CClient* pNCliP, QWidget* parent, // line edits QObject::connect ( LineEditFaderTag, SIGNAL ( textChanged ( const QString& ) ), this, SLOT ( OnFaderTagTextChanged ( const QString& ) ) ); + QObject::connect ( LineEditServerAddr, SIGNAL ( editTextChanged ( const QString ) ), + this, SLOT ( OnLineEditServerAddrTextChanged ( const QString ) ) ); + QObject::connect ( LineEditServerAddr, SIGNAL ( activated ( int ) ), + this, SLOT ( OnLineEditServerAddrActivated ( int ) ) ); // other QObject::connect ( pClient, @@ -214,8 +228,12 @@ void CLlconClientDlg::closeEvent ( QCloseEvent * Event ) ClientSettingsDlg.close(); ChatDlg.close(); - // store IP address - pClient->strIPAddress = LineEditServerAddr->text(); + // store IP addresses + for ( int iLEIdx = 0; iLEIdx < LineEditServerAddr->count(); iLEIdx++ ) + { + pClient->vstrIPAddress[iLEIdx] = + LineEditServerAddr->itemText ( iLEIdx ); + } // store fader tag pClient->strName = LineEditFaderTag->text(); @@ -259,13 +277,33 @@ void CLlconClientDlg::OnSliderAudInFader ( int value ) UpdateAudioFaderSlider(); } +void CLlconClientDlg::OnLineEditServerAddrTextChanged ( const QString sNewText ) +{ + // if the maximum number of items in the combo box is reached, + // delete the last item so that the new item can be added (first + // in - first out) + if ( LineEditServerAddr->count() == MAX_NUM_SERVER_ADDR_ITEMS ) + { + LineEditServerAddr->removeItem ( MAX_NUM_SERVER_ADDR_ITEMS - 1 ); + } +} + +void CLlconClientDlg::OnLineEditServerAddrActivated ( int index ) +{ + // move activated list item to the top + const QString strCurIPAddress = LineEditServerAddr->itemText ( index ); + LineEditServerAddr->removeItem ( index ); + LineEditServerAddr->insertItem ( 0, strCurIPAddress ); + LineEditServerAddr->setCurrentIndex ( 0 ); +} + void CLlconClientDlg::OnConnectDisconBut() { // start/stop client, set button text if ( !pClient->IsRunning() ) { // set address and check if address is valid - if ( pClient->SetServerAddr ( LineEditServerAddr->text() ) ) + if ( pClient->SetServerAddr ( LineEditServerAddr->currentText() ) ) { pClient->Start(); diff --git a/src/llconclientdlg.h b/src/llconclientdlg.h index 904d5738..9eefddab 100755 --- a/src/llconclientdlg.h +++ b/src/llconclientdlg.h @@ -107,4 +107,6 @@ public slots: void OnChatTextReceived ( QString strChatText ); void OnNewLocalInputText ( QString strChatText ) { pClient->SendTextMess ( strChatText ); } + void OnLineEditServerAddrTextChanged ( const QString sNewText ); + void OnLineEditServerAddrActivated ( int index ); }; diff --git a/src/llconclientdlgbase.ui b/src/llconclientdlgbase.ui index 610f6280..02692349 100755 --- a/src/llconclientdlgbase.ui +++ b/src/llconclientdlgbase.ui @@ -57,8 +57,8 @@ - 20 - 0 + 249 + 16 @@ -170,8 +170,8 @@ - 20 - 0 + 249 + 16 @@ -205,7 +205,11 @@ - + + + true + + @@ -628,7 +632,6 @@ Fader - LineEditServerAddr LineEditFaderTag PushButtonConnect SliderAudReverb diff --git a/src/settings.cpp b/src/settings.cpp index 33f11a33..0039d67a 100755 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -53,9 +53,21 @@ void CSettings::ReadIniFile ( const QString& sFileName ) // actual settings data --------------------------------------------------- - // IP address - pClient->strIPAddress = GetIniSetting ( IniXMLDocument, "client", - "ipaddress", DEFAULT_SERVER_ADDRESS ); + // IP addresses + for ( int iIPAddrIdx = 0; iIPAddrIdx < MAX_NUM_SERVER_ADDR_ITEMS; iIPAddrIdx++ ) + { + QString sDefaultIP = ""; + + // use default only for first entry + if ( iIPAddrIdx == 0 ) + { + sDefaultIP = DEFAULT_SERVER_ADDRESS; + } + + pClient->vstrIPAddress[iIPAddrIdx] = + GetIniSetting ( IniXMLDocument, "client", + QString ( "ipaddress%1" ).arg ( iIPAddrIdx ), sDefaultIP ); + } // name pClient->strName = GetIniSetting ( IniXMLDocument, "client", "name" ); @@ -150,9 +162,13 @@ void CSettings::WriteIniFile ( const QString& sFileName ) // actual settings data --------------------------------------------------- - // IP address - PutIniSetting ( IniXMLDocument, "client", "ipaddress", - pClient->strIPAddress ); + // IP addresses + for ( int iIPAddrIdx = 0; iIPAddrIdx < MAX_NUM_SERVER_ADDR_ITEMS; iIPAddrIdx++ ) + { + PutIniSetting ( IniXMLDocument, "client", + QString ( "ipaddress%1" ).arg ( iIPAddrIdx ), + pClient->vstrIPAddress[iIPAddrIdx] ); + } // name PutIniSetting ( IniXMLDocument, "client", "name",