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 ),
iReverbLevel ( 0 ),
bReverbOnLeftChan ( false ),
strIPAddress ( "" ), strName ( "" ),
vstrIPAddress ( MAX_NUM_SERVER_ADDR_ITEMS, "" ), strName ( "" ),
bOpenChatOnNewMessage ( true ),
bDoAutoSockBufSize ( true ),
iSndCrdPreferredMonoBlSizeIndex ( CSndCrdBufferSizes::GetDefaultIndex() ),

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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