some fixes for server GUI
This commit is contained in:
parent
c08fe59a68
commit
a97901c816
4 changed files with 90 additions and 46 deletions
|
@ -86,14 +86,19 @@ CLlconServerDlg::CLlconServerDlg ( CServer* pNServP, QWidget* parent )
|
||||||
static_cast<int> ( pServer->GetServerCountry() ) ) );
|
static_cast<int> ( pServer->GetServerCountry() ) ) );
|
||||||
|
|
||||||
// update register server check box
|
// update register server check box
|
||||||
if ( pServer->GetServerListEnabled() )
|
const bool bCurSerListEnabled = pServer->GetServerListEnabled();
|
||||||
{
|
|
||||||
cbRegisterServer->setCheckState ( Qt::Checked );
|
if ( bCurSerListEnabled )
|
||||||
}
|
{
|
||||||
else
|
cbRegisterServer->setCheckState ( Qt::Checked );
|
||||||
{
|
|
||||||
cbRegisterServer->setCheckState ( Qt::Unchecked );
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
cbRegisterServer->setCheckState ( Qt::Unchecked );
|
||||||
|
}
|
||||||
|
|
||||||
|
// update GUI dependency
|
||||||
|
UpdateServerInfosDependency ( bCurSerListEnabled );
|
||||||
|
|
||||||
|
|
||||||
// Main menu bar -----------------------------------------------------------
|
// Main menu bar -----------------------------------------------------------
|
||||||
|
@ -106,22 +111,22 @@ CLlconServerDlg::CLlconServerDlg ( CServer* pNServP, QWidget* parent )
|
||||||
|
|
||||||
// Connections -------------------------------------------------------------
|
// Connections -------------------------------------------------------------
|
||||||
// check boxes
|
// check boxes
|
||||||
QObject::connect ( cbRegisterServer, SIGNAL ( stateChanged ( int ) ),
|
QObject::connect ( cbRegisterServer, SIGNAL ( stateChanged ( int ) ),
|
||||||
this, SLOT ( OnRegisterServerStateChanged ( int ) ) );
|
this, SLOT ( OnRegisterServerStateChanged ( int ) ) );
|
||||||
|
|
||||||
// line edits
|
// line edits
|
||||||
QObject::connect ( LineEditCentralServerAddress,
|
QObject::connect ( LineEditCentralServerAddress,
|
||||||
SIGNAL ( textChanged ( const QString& ) ),
|
SIGNAL ( textChanged ( const QString& ) ),
|
||||||
this, SLOT ( OnLineEditCentralServerAddressTextChanged ( 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& ) ) );
|
this, SLOT ( OnLineEditServerNameTextChanged ( const QString& ) ) );
|
||||||
|
|
||||||
QObject::connect ( LineEditLocationCity, SIGNAL ( textChanged ( const QString& ) ),
|
QObject::connect ( LineEditLocationCity, SIGNAL ( textChanged ( const QString& ) ),
|
||||||
this, SLOT ( OnLineEditLocationCityTextChanged ( const QString& ) ) );
|
this, SLOT ( OnLineEditLocationCityTextChanged ( const QString& ) ) );
|
||||||
|
|
||||||
// combo boxes
|
// combo boxes
|
||||||
QObject::connect ( ComboBoxLocationCountry, SIGNAL ( activated ( int ) ),
|
QObject::connect ( ComboBoxLocationCountry, SIGNAL ( activated ( int ) ),
|
||||||
this, SLOT ( OnComboBoxLocationCountryActivated ( int ) ) );
|
this, SLOT ( OnComboBoxLocationCountryActivated ( int ) ) );
|
||||||
|
|
||||||
// timers
|
// timers
|
||||||
|
@ -137,12 +142,8 @@ void CLlconServerDlg::OnRegisterServerStateChanged ( int value )
|
||||||
{
|
{
|
||||||
const bool bEnabled = ( value == Qt::Checked );
|
const bool bEnabled = ( value == Qt::Checked );
|
||||||
|
|
||||||
// if register server is not enabled, we disable all the configuration
|
// update GUI dependency
|
||||||
// controls for the server list
|
UpdateServerInfosDependency ( bEnabled );
|
||||||
LabelCentralServerAddress->setEnabled ( bEnabled );
|
|
||||||
cbDefaultCentralServer->setEnabled ( bEnabled );
|
|
||||||
LineEditCentralServerAddress->setEnabled ( bEnabled );
|
|
||||||
GroupBoxServerInfo->setEnabled ( bEnabled );
|
|
||||||
|
|
||||||
// apply new setting to the server and update it
|
// apply new setting to the server and update it
|
||||||
pServer->SetServerListEnabled ( bEnabled );
|
pServer->SetServerListEnabled ( bEnabled );
|
||||||
|
@ -153,21 +154,43 @@ void CLlconServerDlg::OnLineEditCentralServerAddressTextChanged ( const QString&
|
||||||
{
|
{
|
||||||
// apply new setting to the server and update it
|
// apply new setting to the server and update it
|
||||||
pServer->SetServerListCentralServerAddress ( strNewAddr );
|
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 )
|
void CLlconServerDlg::OnLineEditServerNameTextChanged ( const QString& strNewName )
|
||||||
{
|
{
|
||||||
// apply new setting to the server and update it
|
// check length
|
||||||
pServer->SetServerName ( strNewName );
|
if ( strNewName.length() <= MAX_LEN_SERVER_NAME )
|
||||||
pServer->UpdateServerList();
|
{
|
||||||
|
// 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 )
|
void CLlconServerDlg::OnLineEditLocationCityTextChanged ( const QString& strNewCity )
|
||||||
{
|
{
|
||||||
// apply new setting to the server and update it
|
// check length
|
||||||
pServer->SetServerCity ( strNewCity );
|
if ( strNewCity.length() <= MAX_LEN_SERVER_CITY )
|
||||||
pServer->UpdateServerList();
|
{
|
||||||
|
// 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 )
|
void CLlconServerDlg::OnComboBoxLocationCountryActivated ( int iCntryListItem )
|
||||||
|
@ -227,6 +250,16 @@ void CLlconServerDlg::OnTimer()
|
||||||
ListViewMutex.unlock();
|
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 )
|
void CLlconServerDlg::customEvent ( QEvent* Event )
|
||||||
{
|
{
|
||||||
if ( Event->type() == QEvent::User + 11 )
|
if ( Event->type() == QEvent::User + 11 )
|
||||||
|
|
|
@ -67,7 +67,8 @@ protected:
|
||||||
QMenuBar* pMenu;
|
QMenuBar* pMenu;
|
||||||
|
|
||||||
virtual void customEvent ( QEvent* Event );
|
virtual void customEvent ( QEvent* Event );
|
||||||
void UpdateSliderNetBuf();
|
void UpdateServerInfosDependency ( const bool bState );
|
||||||
|
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void OnRegisterServerStateChanged ( int value );
|
void OnRegisterServerStateChanged ( int value );
|
||||||
|
|
|
@ -172,14 +172,11 @@
|
||||||
<item>
|
<item>
|
||||||
<widget class="QPushButton" name="buttonOk" >
|
<widget class="QPushButton" name="buttonOk" >
|
||||||
<property name="text" >
|
<property name="text" >
|
||||||
<string>&Close</string>
|
<string>E&xit</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="autoDefault" >
|
<property name="autoDefault" >
|
||||||
<bool>true</bool>
|
<bool>true</bool>
|
||||||
</property>
|
</property>
|
||||||
<property name="default" >
|
|
||||||
<bool>true</bool>
|
|
||||||
</property>
|
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
|
|
|
@ -374,16 +374,21 @@ QString CSettings::GetIniFileNameWithPath ( const QString& sFileName )
|
||||||
return sCurFileName;
|
return sCurFileName;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSettings::SetNumericIniSet ( QDomDocument& xmlFile, const QString& strSection,
|
void CSettings::SetNumericIniSet ( QDomDocument& xmlFile,
|
||||||
const QString& strKey, const int iValue )
|
const QString& strSection,
|
||||||
|
const QString& strKey,
|
||||||
|
const int iValue )
|
||||||
{
|
{
|
||||||
// convert input parameter which is an integer to string and store
|
// convert input parameter which is an integer to string and store
|
||||||
PutIniSetting ( xmlFile, strSection, strKey, QString("%1").arg(iValue) );
|
PutIniSetting ( xmlFile, strSection, strKey, QString("%1").arg(iValue) );
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CSettings::GetNumericIniSet ( const QDomDocument& xmlFile, const QString& strSection,
|
bool CSettings::GetNumericIniSet ( const QDomDocument& xmlFile,
|
||||||
const QString& strKey, const int iRangeStart,
|
const QString& strSection,
|
||||||
const int iRangeStop, int& iValue )
|
const QString& strKey,
|
||||||
|
const int iRangeStart,
|
||||||
|
const int iRangeStop,
|
||||||
|
int& iValue )
|
||||||
{
|
{
|
||||||
// init return value
|
// init return value
|
||||||
bool bReturn = false;
|
bool bReturn = false;
|
||||||
|
@ -406,8 +411,10 @@ bool CSettings::GetNumericIniSet ( const QDomDocument& xmlFile, const QString& s
|
||||||
return bReturn;
|
return bReturn;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSettings::SetFlagIniSet ( QDomDocument& xmlFile, const QString& strSection,
|
void CSettings::SetFlagIniSet ( QDomDocument& xmlFile,
|
||||||
const QString& strKey, const bool bValue )
|
const QString& strSection,
|
||||||
|
const QString& strKey,
|
||||||
|
const bool bValue )
|
||||||
{
|
{
|
||||||
// we encode true -> "1" and false -> "0"
|
// we encode true -> "1" and false -> "0"
|
||||||
if ( bValue == true )
|
if ( bValue == true )
|
||||||
|
@ -420,8 +427,10 @@ void CSettings::SetFlagIniSet ( QDomDocument& xmlFile, const QString& strSection
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CSettings::GetFlagIniSet ( const QDomDocument& xmlFile, const QString& strSection,
|
bool CSettings::GetFlagIniSet ( const QDomDocument& xmlFile,
|
||||||
const QString& strKey, bool& bValue )
|
const QString& strSection,
|
||||||
|
const QString& strKey,
|
||||||
|
bool& bValue )
|
||||||
{
|
{
|
||||||
// init return value
|
// init return value
|
||||||
bool bReturn = false;
|
bool bReturn = false;
|
||||||
|
@ -447,8 +456,10 @@ bool CSettings::GetFlagIniSet ( const QDomDocument& xmlFile, const QString& strS
|
||||||
|
|
||||||
|
|
||||||
// Init-file routines using XML ***********************************************
|
// Init-file routines using XML ***********************************************
|
||||||
QString CSettings::GetIniSetting ( const QDomDocument& xmlFile, const QString& sSection,
|
QString CSettings::GetIniSetting ( const QDomDocument& xmlFile,
|
||||||
const QString& sKey, const QString& sDefaultVal )
|
const QString& sSection,
|
||||||
|
const QString& sKey,
|
||||||
|
const QString& sDefaultVal )
|
||||||
{
|
{
|
||||||
// init return parameter with default value
|
// init return parameter with default value
|
||||||
QString sResult ( sDefaultVal );
|
QString sResult ( sDefaultVal );
|
||||||
|
@ -469,8 +480,10 @@ QString CSettings::GetIniSetting ( const QDomDocument& xmlFile, const QString& s
|
||||||
return sResult;
|
return sResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSettings::PutIniSetting ( QDomDocument& xmlFile, const QString& sSection,
|
void CSettings::PutIniSetting ( QDomDocument& xmlFile,
|
||||||
const QString& sKey, const QString& sValue )
|
const QString& sSection,
|
||||||
|
const QString& sKey,
|
||||||
|
const QString& sValue )
|
||||||
{
|
{
|
||||||
// check if section is already there, if not then create it
|
// check if section is already there, if not then create it
|
||||||
QDomElement xmlSection = xmlFile.firstChildElement ( sSection );
|
QDomElement xmlSection = xmlFile.firstChildElement ( sSection );
|
||||||
|
|
Loading…
Add table
Reference in a new issue