implemented combo box for server address for storing the last 6 items

This commit is contained in:
Volker Fischer 2009-05-04 11:27:05 +00:00
parent 09c073e014
commit 3bc7d3cc32
7 changed files with 82 additions and 20 deletions

View file

@ -33,7 +33,7 @@ CClient::CClient ( const quint16 iPortNumber ) :
iAudioInFader ( AUD_FADER_IN_MIDDLE ), iAudioInFader ( AUD_FADER_IN_MIDDLE ),
iReverbLevel ( 0 ), iReverbLevel ( 0 ),
bReverbOnLeftChan ( false ), bReverbOnLeftChan ( false ),
strIPAddress ( "" ), strName ( "" ), vstrIPAddress ( MAX_NUM_SERVER_ADDR_ITEMS, "" ), strName ( "" ),
bOpenChatOnNewMessage ( true ), bOpenChatOnNewMessage ( true ),
bDoAutoSockBufSize ( true ), bDoAutoSockBufSize ( true ),
iSndCrdPreferredMonoBlSizeIndex ( CSndCrdBufferSizes::GetDefaultIndex() ), iSndCrdPreferredMonoBlSizeIndex ( CSndCrdBufferSizes::GetDefaultIndex() ),

View file

@ -155,7 +155,7 @@ public:
// settings // settings
QString strIPAddress; CVector<QString> vstrIPAddress;
QString strName; QString strName;
protected: protected:

View file

@ -96,6 +96,9 @@
#define MAX_NUMBER_SOUND_CARDS 10 #define MAX_NUMBER_SOUND_CARDS 10
#define INVALID_SNC_CARD_DEVICE -1 #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 // defines for LED input level meter
#define NUM_STEPS_INP_LEV_METER 10 #define NUM_STEPS_INP_LEV_METER 10
#define YELLOW_BOUND_INP_LEV_METER 7 #define YELLOW_BOUND_INP_LEV_METER 7

View file

@ -91,8 +91,18 @@ CLlconClientDlg::CLlconClientDlg ( CClient* pNCliP, QWidget* parent,
// init fader tag line edit // init fader tag line edit
LineEditFaderTag->setText ( pClient->strName ); LineEditFaderTag->setText ( pClient->strName );
// init server address line edit // init server address combo box (max MAX_NUM_SERVER_ADDR_ITEMS entries)
LineEditServerAddr->setText ( pClient->strIPAddress ); 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 // we want the cursor to be at IP address line edit at startup
LineEditServerAddr->setFocus(); LineEditServerAddr->setFocus();
@ -180,6 +190,10 @@ CLlconClientDlg::CLlconClientDlg ( CClient* pNCliP, QWidget* parent,
// line edits // line edits
QObject::connect ( LineEditFaderTag, SIGNAL ( textChanged ( const QString& ) ), QObject::connect ( LineEditFaderTag, SIGNAL ( textChanged ( const QString& ) ),
this, SLOT ( OnFaderTagTextChanged ( 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 // other
QObject::connect ( pClient, QObject::connect ( pClient,
@ -214,8 +228,12 @@ void CLlconClientDlg::closeEvent ( QCloseEvent * Event )
ClientSettingsDlg.close(); ClientSettingsDlg.close();
ChatDlg.close(); ChatDlg.close();
// store IP address // store IP addresses
pClient->strIPAddress = LineEditServerAddr->text(); for ( int iLEIdx = 0; iLEIdx < LineEditServerAddr->count(); iLEIdx++ )
{
pClient->vstrIPAddress[iLEIdx] =
LineEditServerAddr->itemText ( iLEIdx );
}
// store fader tag // store fader tag
pClient->strName = LineEditFaderTag->text(); pClient->strName = LineEditFaderTag->text();
@ -259,13 +277,33 @@ void CLlconClientDlg::OnSliderAudInFader ( int value )
UpdateAudioFaderSlider(); 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() void CLlconClientDlg::OnConnectDisconBut()
{ {
// start/stop client, set button text // start/stop client, set button text
if ( !pClient->IsRunning() ) if ( !pClient->IsRunning() )
{ {
// set address and check if address is valid // set address and check if address is valid
if ( pClient->SetServerAddr ( LineEditServerAddr->text() ) ) if ( pClient->SetServerAddr ( LineEditServerAddr->currentText() ) )
{ {
pClient->Start(); pClient->Start();

View file

@ -107,4 +107,6 @@ public slots:
void OnChatTextReceived ( QString strChatText ); void OnChatTextReceived ( QString strChatText );
void OnNewLocalInputText ( QString strChatText ) void OnNewLocalInputText ( QString strChatText )
{ pClient->SendTextMess ( strChatText ); } { pClient->SendTextMess ( strChatText ); }
void OnLineEditServerAddrTextChanged ( const QString sNewText );
void OnLineEditServerAddrActivated ( int index );
}; };

View file

@ -57,8 +57,8 @@
</property> </property>
<property name="sizeHint" > <property name="sizeHint" >
<size> <size>
<width>20</width> <width>249</width>
<height>0</height> <height>16</height>
</size> </size>
</property> </property>
</spacer> </spacer>
@ -170,8 +170,8 @@
</property> </property>
<property name="sizeHint" > <property name="sizeHint" >
<size> <size>
<width>20</width> <width>249</width>
<height>0</height> <height>16</height>
</size> </size>
</property> </property>
</spacer> </spacer>
@ -205,7 +205,11 @@
<item> <item>
<layout class="QVBoxLayout" > <layout class="QVBoxLayout" >
<item> <item>
<widget class="QLineEdit" name="LineEditServerAddr" /> <widget class="QComboBox" name="LineEditServerAddr" >
<property name="editable" >
<bool>true</bool>
</property>
</widget>
</item> </item>
<item> <item>
<widget class="QLineEdit" name="LineEditFaderTag" > <widget class="QLineEdit" name="LineEditFaderTag" >
@ -628,7 +632,6 @@ Fader</string>
</customwidget> </customwidget>
</customwidgets> </customwidgets>
<tabstops> <tabstops>
<tabstop>LineEditServerAddr</tabstop>
<tabstop>LineEditFaderTag</tabstop> <tabstop>LineEditFaderTag</tabstop>
<tabstop>PushButtonConnect</tabstop> <tabstop>PushButtonConnect</tabstop>
<tabstop>SliderAudReverb</tabstop> <tabstop>SliderAudReverb</tabstop>

View file

@ -53,9 +53,21 @@ void CSettings::ReadIniFile ( const QString& sFileName )
// actual settings data --------------------------------------------------- // actual settings data ---------------------------------------------------
// IP address // IP addresses
pClient->strIPAddress = GetIniSetting ( IniXMLDocument, "client", for ( int iIPAddrIdx = 0; iIPAddrIdx < MAX_NUM_SERVER_ADDR_ITEMS; iIPAddrIdx++ )
"ipaddress", DEFAULT_SERVER_ADDRESS ); {
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 // name
pClient->strName = GetIniSetting ( IniXMLDocument, "client", "name" ); pClient->strName = GetIniSetting ( IniXMLDocument, "client", "name" );
@ -150,9 +162,13 @@ void CSettings::WriteIniFile ( const QString& sFileName )
// actual settings data --------------------------------------------------- // actual settings data ---------------------------------------------------
// IP address // IP addresses
PutIniSetting ( IniXMLDocument, "client", "ipaddress", for ( int iIPAddrIdx = 0; iIPAddrIdx < MAX_NUM_SERVER_ADDR_ITEMS; iIPAddrIdx++ )
pClient->strIPAddress ); {
PutIniSetting ( IniXMLDocument, "client",
QString ( "ipaddress%1" ).arg ( iIPAddrIdx ),
pClient->vstrIPAddress[iIPAddrIdx] );
}
// name // name
PutIniSetting ( IniXMLDocument, "client", "name", PutIniSetting ( IniXMLDocument, "client", "name",