some fixes for server GUI

This commit is contained in:
Volker Fischer 2011-04-30 16:04:22 +00:00
parent c08fe59a68
commit a97901c816
4 changed files with 90 additions and 46 deletions

View file

@ -86,14 +86,19 @@ CLlconServerDlg::CLlconServerDlg ( CServer* pNServP, QWidget* parent )
static_cast<int> ( pServer->GetServerCountry() ) ) );
// update register server check box
if ( pServer->GetServerListEnabled() )
{
cbRegisterServer->setCheckState ( Qt::Checked );
}
else
{
cbRegisterServer->setCheckState ( Qt::Unchecked );
const bool bCurSerListEnabled = pServer->GetServerListEnabled();
if ( bCurSerListEnabled )
{
cbRegisterServer->setCheckState ( Qt::Checked );
}
else
{
cbRegisterServer->setCheckState ( Qt::Unchecked );
}
// update GUI dependency
UpdateServerInfosDependency ( bCurSerListEnabled );
// Main menu bar -----------------------------------------------------------
@ -106,22 +111,22 @@ CLlconServerDlg::CLlconServerDlg ( CServer* pNServP, QWidget* parent )
// Connections -------------------------------------------------------------
// check boxes
QObject::connect ( cbRegisterServer, SIGNAL ( stateChanged ( int ) ),
QObject::connect ( cbRegisterServer, SIGNAL ( stateChanged ( int ) ),
this, SLOT ( OnRegisterServerStateChanged ( int ) ) );
// line edits
QObject::connect ( LineEditCentralServerAddress,
SIGNAL ( textChanged ( const QString& ) ),
// line edits
QObject::connect ( LineEditCentralServerAddress,
SIGNAL ( textChanged ( const QString& ) ),
this, SLOT ( OnLineEditCentralServerAddressTextChanged ( const QString& ) ) );
QObject::connect ( LineEditServerName, SIGNAL ( textChanged ( const QString& ) ),
QObject::connect ( LineEditServerName, SIGNAL ( textChanged ( const QString& ) ),
this, SLOT ( OnLineEditServerNameTextChanged ( const QString& ) ) );
QObject::connect ( LineEditLocationCity, SIGNAL ( textChanged ( const QString& ) ),
QObject::connect ( LineEditLocationCity, SIGNAL ( textChanged ( const QString& ) ),
this, SLOT ( OnLineEditLocationCityTextChanged ( const QString& ) ) );
// combo boxes
QObject::connect ( ComboBoxLocationCountry, SIGNAL ( activated ( int ) ),
// combo boxes
QObject::connect ( ComboBoxLocationCountry, SIGNAL ( activated ( int ) ),
this, SLOT ( OnComboBoxLocationCountryActivated ( int ) ) );
// timers
@ -137,12 +142,8 @@ void CLlconServerDlg::OnRegisterServerStateChanged ( int value )
{
const bool bEnabled = ( value == Qt::Checked );
// if register server is not enabled, we disable all the configuration
// controls for the server list
LabelCentralServerAddress->setEnabled ( bEnabled );
cbDefaultCentralServer->setEnabled ( bEnabled );
LineEditCentralServerAddress->setEnabled ( bEnabled );
GroupBoxServerInfo->setEnabled ( bEnabled );
// update GUI dependency
UpdateServerInfosDependency ( bEnabled );
// apply new setting to the server and update it
pServer->SetServerListEnabled ( bEnabled );
@ -153,21 +154,43 @@ void CLlconServerDlg::OnLineEditCentralServerAddressTextChanged ( const QString&
{
// apply new setting to the server and update it
pServer->SetServerListCentralServerAddress ( strNewAddr );
pServer->UpdateServerList();
// TODO
// only apply this in case the focus is lost and the name has actually changed!
pServer->UpdateServerList();
}
void CLlconServerDlg::OnLineEditServerNameTextChanged ( const QString& strNewName )
{
// apply new setting to the server and update it
pServer->SetServerName ( strNewName );
pServer->UpdateServerList();
// check length
if ( strNewName.length() <= MAX_LEN_SERVER_NAME )
{
// apply new setting to the server and update it
pServer->SetServerName ( strNewName );
pServer->UpdateServerList();
}
else
{
// text is too long, update control with shortend text
LineEditServerName->setText ( strNewName.left ( MAX_LEN_SERVER_NAME ) );
}
}
void CLlconServerDlg::OnLineEditLocationCityTextChanged ( const QString& strNewCity )
{
// apply new setting to the server and update it
pServer->SetServerCity ( strNewCity );
pServer->UpdateServerList();
// check length
if ( strNewCity.length() <= MAX_LEN_SERVER_CITY )
{
// apply new setting to the server and update it
pServer->SetServerCity ( strNewCity );
pServer->UpdateServerList();
}
else
{
// text is too long, update control with shortend text
LineEditLocationCity->setText ( strNewCity.left ( MAX_LEN_SERVER_CITY ) );
}
}
void CLlconServerDlg::OnComboBoxLocationCountryActivated ( int iCntryListItem )
@ -227,6 +250,16 @@ void CLlconServerDlg::OnTimer()
ListViewMutex.unlock();
}
void CLlconServerDlg::UpdateServerInfosDependency ( const bool bState )
{
// if register server is not enabled, we disable all the configuration
// controls for the server list
LabelCentralServerAddress->setEnabled ( bState );
cbDefaultCentralServer->setEnabled ( bState );
LineEditCentralServerAddress->setEnabled ( bState );
GroupBoxServerInfo->setEnabled ( bState );
}
void CLlconServerDlg::customEvent ( QEvent* Event )
{
if ( Event->type() == QEvent::User + 11 )

View file

@ -67,7 +67,8 @@ protected:
QMenuBar* pMenu;
virtual void customEvent ( QEvent* Event );
void UpdateSliderNetBuf();
void UpdateServerInfosDependency ( const bool bState );
public slots:
void OnRegisterServerStateChanged ( int value );

View file

@ -172,14 +172,11 @@
<item>
<widget class="QPushButton" name="buttonOk" >
<property name="text" >
<string>&amp;Close</string>
<string>E&amp;xit</string>
</property>
<property name="autoDefault" >
<bool>true</bool>
</property>
<property name="default" >
<bool>true</bool>
</property>
</widget>
</item>
</layout>

View file

@ -374,16 +374,21 @@ QString CSettings::GetIniFileNameWithPath ( const QString& sFileName )
return sCurFileName;
}
void CSettings::SetNumericIniSet ( QDomDocument& xmlFile, const QString& strSection,
const QString& strKey, const int iValue )
void CSettings::SetNumericIniSet ( QDomDocument& xmlFile,
const QString& strSection,
const QString& strKey,
const int iValue )
{
// convert input parameter which is an integer to string and store
PutIniSetting ( xmlFile, strSection, strKey, QString("%1").arg(iValue) );
}
bool CSettings::GetNumericIniSet ( const QDomDocument& xmlFile, const QString& strSection,
const QString& strKey, const int iRangeStart,
const int iRangeStop, int& iValue )
bool CSettings::GetNumericIniSet ( const QDomDocument& xmlFile,
const QString& strSection,
const QString& strKey,
const int iRangeStart,
const int iRangeStop,
int& iValue )
{
// init return value
bool bReturn = false;
@ -406,8 +411,10 @@ bool CSettings::GetNumericIniSet ( const QDomDocument& xmlFile, const QString& s
return bReturn;
}
void CSettings::SetFlagIniSet ( QDomDocument& xmlFile, const QString& strSection,
const QString& strKey, const bool bValue )
void CSettings::SetFlagIniSet ( QDomDocument& xmlFile,
const QString& strSection,
const QString& strKey,
const bool bValue )
{
// we encode true -> "1" and false -> "0"
if ( bValue == true )
@ -420,8 +427,10 @@ void CSettings::SetFlagIniSet ( QDomDocument& xmlFile, const QString& strSection
}
}
bool CSettings::GetFlagIniSet ( const QDomDocument& xmlFile, const QString& strSection,
const QString& strKey, bool& bValue )
bool CSettings::GetFlagIniSet ( const QDomDocument& xmlFile,
const QString& strSection,
const QString& strKey,
bool& bValue )
{
// init return value
bool bReturn = false;
@ -447,8 +456,10 @@ bool CSettings::GetFlagIniSet ( const QDomDocument& xmlFile, const QString& strS
// Init-file routines using XML ***********************************************
QString CSettings::GetIniSetting ( const QDomDocument& xmlFile, const QString& sSection,
const QString& sKey, const QString& sDefaultVal )
QString CSettings::GetIniSetting ( const QDomDocument& xmlFile,
const QString& sSection,
const QString& sKey,
const QString& sDefaultVal )
{
// init return parameter with default value
QString sResult ( sDefaultVal );
@ -469,8 +480,10 @@ QString CSettings::GetIniSetting ( const QDomDocument& xmlFile, const QString& s
return sResult;
}
void CSettings::PutIniSetting ( QDomDocument& xmlFile, const QString& sSection,
const QString& sKey, const QString& sValue )
void CSettings::PutIniSetting ( QDomDocument& xmlFile,
const QString& sSection,
const QString& sKey,
const QString& sValue )
{
// check if section is already there, if not then create it
QDomElement xmlSection = xmlFile.firstChildElement ( sSection );