fixes for the server GUI, set help text for server GUI, support for default central server address check box in the server GUI

This commit is contained in:
Volker Fischer 2011-04-30 19:51:49 +00:00
parent a97901c816
commit 29a185da97
12 changed files with 207 additions and 51 deletions

View file

@ -31,7 +31,8 @@ CChatDlg::CChatDlg ( QWidget* parent, Qt::WindowFlags f ) :
{ {
setupUi ( this ); setupUi ( this );
// add help text to controls -----------------------------------------------
// Add help text to controls -----------------------------------------------
lineEditLocalInputText->setAccessibleName ( "New chat text edit box" ); lineEditLocalInputText->setAccessibleName ( "New chat text edit box" );
TextViewChatWindow->setAccessibleName ( "Chat history" ); TextViewChatWindow->setAccessibleName ( "Chat history" );

View file

@ -31,6 +31,7 @@ CClientSettingsDlg::CClientSettingsDlg ( CClient* pNCliP, QWidget* parent,
{ {
setupUi ( this ); setupUi ( this );
// Add help text to controls ----------------------------------------------- // Add help text to controls -----------------------------------------------
// jitter buffer // jitter buffer
QString strJitterBufferSize = tr ( "<b>Jitter Buffer Size:</b> The jitter " QString strJitterBufferSize = tr ( "<b>Jitter Buffer Size:</b> The jitter "

View file

@ -60,7 +60,7 @@
#define LLCON_DOWNLOAD_URL "http://sourceforge.net/projects/llcon/files" #define LLCON_DOWNLOAD_URL "http://sourceforge.net/projects/llcon/files"
// defined port number for client and server // defined port number for client and server
#define LLCON_DEFAULT_PORT_NUMBER 22124 #define LLCON_DEFAULT_PORT_NUMBER 22122
// system sample rate (the sound card and audio coder works on this sample rate) // system sample rate (the sound card and audio coder works on this sample rate)
#define SYSTEM_SAMPLE_RATE_HZ 48000 // Hz #define SYSTEM_SAMPLE_RATE_HZ 48000 // Hz

View file

@ -55,6 +55,7 @@ CLlconClientDlg::CLlconClientDlg ( CClient* pNCliP,
{ {
setupUi ( this ); setupUi ( this );
// Add help text to controls ----------------------------------------------- // Add help text to controls -----------------------------------------------
// input level meter // input level meter
QString strInpLevH = tr ( "<b>Input Level Meter:</b> The input level " QString strInpLevH = tr ( "<b>Input Level Meter:</b> The input level "

View file

@ -31,6 +31,75 @@ CLlconServerDlg::CLlconServerDlg ( CServer* pNServP, QWidget* parent )
{ {
setupUi ( this ); setupUi ( this );
// Add help text to controls -----------------------------------------------
// client list
ListViewClients->setWhatsThis ( tr ( "<b>Client List:</b> The client list "
"shows all clients which are currently connected to this server. Some "
"informations about the clients like the IP address, name, buffer "
"state are given for each connected client." ) );
ListViewClients->setAccessibleName ( tr ( "Connected clients list view" ) );
// register server flag
cbRegisterServer->setWhatsThis ( tr ( "<b>Register Server Status:</b> If "
"the register server check box is checked, this server registers "
"itself at the central server so that all " ) + APP_NAME +
tr ( " users can see the server in the connect dialog server list and "
"connect to it. The registering of the server is renewed periodically "
"to make sure that all servers in the connect dialog server list are "
"actually available." ) );
// central server address
QString strCentrServAddr = tr ( "<b>Central Server Address:</b> The "
"Central server address is the IP address or URL of the central server "
"at which this server is registered. If the Default check box is "
"checked, the default central server address is shown read-only." );
LabelCentralServerAddress->setWhatsThis ( strCentrServAddr );
cbDefaultCentralServer->setWhatsThis ( strCentrServAddr );
LineEditCentralServerAddress->setWhatsThis ( strCentrServAddr );
cbDefaultCentralServer->setAccessibleName (
tr ( "Default central server check box" ) );
LineEditCentralServerAddress->setAccessibleName (
tr ( "Central server address line edit" ) );
// server name
QString strServName = tr ( "<b>Server Name:</b> The server name identifies "
"your server in the connect dialog server list at the clients. If no "
"name is given, the IP address is shown instead." );
LabelServerName->setWhatsThis ( strServName );
LineEditServerName->setWhatsThis ( strServName );
LineEditServerName->setAccessibleName ( tr ( "Server name line edit" ) );
// location city
QString strLocCity = tr ( "<b>Location City:</b> The city in which this "
"server is located can be set here. If a city name is entered, it "
"will be shown in the connect dialog server list at the clients." );
LabelLocationCity->setWhatsThis ( strLocCity );
LineEditLocationCity->setWhatsThis ( strLocCity );
LineEditLocationCity->setAccessibleName ( tr (
"City where the server is located line edit" ) );
// location country
QString strLocCountry = tr ( "<b>Location country:</b> The country in "
"which this server is located can be set here. If a country is "
"entered, it will be shown in the connect dialog server list at the "
"clients." );
LabelLocationCountry->setWhatsThis ( strLocCountry );
ComboBoxLocationCountry->setWhatsThis ( strLocCountry );
ComboBoxLocationCountry->setAccessibleName ( tr (
"Country where the server is located combo box" ) );
// set text for version and application name // set text for version and application name
TextLabelNameVersion->setText ( QString ( APP_NAME ) + TextLabelNameVersion->setText ( QString ( APP_NAME ) +
tr ( " server " ) + QString ( VERSION ) ); tr ( " server " ) + QString ( VERSION ) );
@ -54,6 +123,16 @@ CLlconServerDlg::CLlconServerDlg ( CServer* pNServP, QWidget* parent )
LineEditCentralServerAddress->setText ( LineEditCentralServerAddress->setText (
pServer->GetServerListCentralServerAddress() ); pServer->GetServerListCentralServerAddress() );
// update default central server address check box
if ( pServer->GetUseDefaultCentralServerAddress() )
{
cbDefaultCentralServer->setCheckState ( Qt::Checked );
}
else
{
cbDefaultCentralServer->setCheckState ( Qt::Unchecked );
}
// update server name line edit // update server name line edit
LineEditServerName->setText ( pServer->GetServerName() ); LineEditServerName->setText ( pServer->GetServerName() );
@ -86,9 +165,7 @@ 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
const bool bCurSerListEnabled = pServer->GetServerListEnabled(); if ( pServer->GetServerListEnabled() )
if ( bCurSerListEnabled )
{ {
cbRegisterServer->setCheckState ( Qt::Checked ); cbRegisterServer->setCheckState ( Qt::Checked );
} }
@ -97,8 +174,8 @@ CLlconServerDlg::CLlconServerDlg ( CServer* pNServP, QWidget* parent )
cbRegisterServer->setCheckState ( Qt::Unchecked ); cbRegisterServer->setCheckState ( Qt::Unchecked );
} }
// update GUI dependency // update GUI dependencies
UpdateServerInfosDependency ( bCurSerListEnabled ); UpdateGUIDependencies();
// Main menu bar ----------------------------------------------------------- // Main menu bar -----------------------------------------------------------
@ -114,10 +191,13 @@ CLlconServerDlg::CLlconServerDlg ( CServer* pNServP, QWidget* parent )
QObject::connect ( cbRegisterServer, SIGNAL ( stateChanged ( int ) ), QObject::connect ( cbRegisterServer, SIGNAL ( stateChanged ( int ) ),
this, SLOT ( OnRegisterServerStateChanged ( int ) ) ); this, SLOT ( OnRegisterServerStateChanged ( int ) ) );
QObject::connect ( cbDefaultCentralServer, SIGNAL ( stateChanged ( int ) ),
this, SLOT ( OnDefaultCentralServerStateChanged ( int ) ) );
// line edits // line edits
QObject::connect ( LineEditCentralServerAddress, QObject::connect ( LineEditCentralServerAddress,
SIGNAL ( textChanged ( const QString& ) ), SIGNAL ( editingFinished() ),
this, SLOT ( OnLineEditCentralServerAddressTextChanged ( const QString& ) ) ); this, SLOT ( OnLineEditCentralServerAddressEditingFinished() ) );
QObject::connect ( LineEditServerName, SIGNAL ( textChanged ( const QString& ) ), QObject::connect ( LineEditServerName, SIGNAL ( textChanged ( const QString& ) ),
this, SLOT ( OnLineEditServerNameTextChanged ( const QString& ) ) ); this, SLOT ( OnLineEditServerNameTextChanged ( const QString& ) ) );
@ -138,58 +218,64 @@ CLlconServerDlg::CLlconServerDlg ( CServer* pNServP, QWidget* parent )
Timer.start ( GUI_CONTRL_UPDATE_TIME ); Timer.start ( GUI_CONTRL_UPDATE_TIME );
} }
void CLlconServerDlg::OnRegisterServerStateChanged ( int value ) void CLlconServerDlg::OnDefaultCentralServerStateChanged ( int value )
{ {
const bool bEnabled = ( value == Qt::Checked );
// update GUI dependency
UpdateServerInfosDependency ( bEnabled );
// apply new setting to the server and update it // apply new setting to the server and update it
pServer->SetServerListEnabled ( bEnabled ); pServer->SetUseDefaultCentralServerAddress ( value == Qt::Checked );
pServer->UpdateServerList(); pServer->UpdateServerList();
// update GUI dependencies
UpdateGUIDependencies();
} }
void CLlconServerDlg::OnLineEditCentralServerAddressTextChanged ( const QString& strNewAddr ) void CLlconServerDlg::OnRegisterServerStateChanged ( int value )
{ {
// apply new setting to the server and update it // apply new setting to the server and update it
pServer->SetServerListCentralServerAddress ( strNewAddr ); pServer->SetServerListEnabled ( value == Qt::Checked );
pServer->UpdateServerList();
// TODO // update GUI dependencies
// only apply this in case the focus is lost and the name has actually changed! UpdateGUIDependencies();
pServer->UpdateServerList(); }
void CLlconServerDlg::OnLineEditCentralServerAddressEditingFinished()
{
// apply new setting to the server and update it
pServer->SetServerListCentralServerAddress (
LineEditCentralServerAddress->text() );
pServer->UpdateServerList();
} }
void CLlconServerDlg::OnLineEditServerNameTextChanged ( const QString& strNewName ) void CLlconServerDlg::OnLineEditServerNameTextChanged ( const QString& strNewName )
{ {
// check length // check length
if ( strNewName.length() <= MAX_LEN_SERVER_NAME ) if ( strNewName.length() <= MAX_LEN_SERVER_NAME )
{ {
// apply new setting to the server and update it // apply new setting to the server and update it
pServer->SetServerName ( strNewName ); pServer->SetServerName ( strNewName );
pServer->UpdateServerList(); pServer->UpdateServerList();
} }
else else
{ {
// text is too long, update control with shortend text // text is too long, update control with shortend text
LineEditServerName->setText ( strNewName.left ( MAX_LEN_SERVER_NAME ) ); LineEditServerName->setText ( strNewName.left ( MAX_LEN_SERVER_NAME ) );
} }
} }
void CLlconServerDlg::OnLineEditLocationCityTextChanged ( const QString& strNewCity ) void CLlconServerDlg::OnLineEditLocationCityTextChanged ( const QString& strNewCity )
{ {
// check length // check length
if ( strNewCity.length() <= MAX_LEN_SERVER_CITY ) if ( strNewCity.length() <= MAX_LEN_SERVER_CITY )
{ {
// apply new setting to the server and update it // apply new setting to the server and update it
pServer->SetServerCity ( strNewCity ); pServer->SetServerCity ( strNewCity );
pServer->UpdateServerList(); pServer->UpdateServerList();
} }
else else
{ {
// text is too long, update control with shortend text // text is too long, update control with shortend text
LineEditLocationCity->setText ( strNewCity.left ( MAX_LEN_SERVER_CITY ) ); LineEditLocationCity->setText ( strNewCity.left ( MAX_LEN_SERVER_CITY ) );
} }
} }
@ -250,14 +336,41 @@ void CLlconServerDlg::OnTimer()
ListViewMutex.unlock(); ListViewMutex.unlock();
} }
void CLlconServerDlg::UpdateServerInfosDependency ( const bool bState ) void CLlconServerDlg::UpdateGUIDependencies()
{ {
// get the states which define the GUI dependencies from the server
const bool bCurSerListEnabled = pServer->GetServerListEnabled();
const bool bCurUseDefCentServAddr =
pServer->GetUseDefaultCentralServerAddress();
// if register server is not enabled, we disable all the configuration // if register server is not enabled, we disable all the configuration
// controls for the server list // controls for the server list
LabelCentralServerAddress->setEnabled ( bState ); cbDefaultCentralServer->setEnabled ( bCurSerListEnabled );
cbDefaultCentralServer->setEnabled ( bState ); LineEditCentralServerAddress->setEnabled ( bCurSerListEnabled );
LineEditCentralServerAddress->setEnabled ( bState ); GroupBoxServerInfo->setEnabled ( bCurSerListEnabled );
GroupBoxServerInfo->setEnabled ( bState );
// If the default central server address is enabled, the line edit shows
// the default server and is not editable. Make sure the line edit does not
// fire signals when we update the text.
LineEditCentralServerAddress->blockSignals ( true );
{
if ( bCurUseDefCentServAddr )
{
LineEditCentralServerAddress->setText ( DEFAULT_SERVER_ADDRESS );
}
else
{
LineEditCentralServerAddress->setText (
pServer->GetServerListCentralServerAddress() );
}
}
LineEditCentralServerAddress->blockSignals ( false );
// the line edit of the central server address is only enabled, if the
// server list is enabled and not the default address is used
LineEditCentralServerAddress->setEnabled (
!bCurUseDefCentServAddr && bCurSerListEnabled );
} }
void CLlconServerDlg::customEvent ( QEvent* Event ) void CLlconServerDlg::customEvent ( QEvent* Event )

View file

@ -67,12 +67,12 @@ protected:
QMenuBar* pMenu; QMenuBar* pMenu;
virtual void customEvent ( QEvent* Event ); virtual void customEvent ( QEvent* Event );
void UpdateServerInfosDependency ( const bool bState ); void UpdateGUIDependencies();
public slots: public slots:
void OnRegisterServerStateChanged ( int value ); void OnRegisterServerStateChanged ( int value );
void OnLineEditCentralServerAddressTextChanged ( const QString& strNewAddr ); void OnDefaultCentralServerStateChanged ( int value );
void OnLineEditCentralServerAddressEditingFinished();
void OnLineEditServerNameTextChanged ( const QString& strNewName ); void OnLineEditServerNameTextChanged ( const QString& strNewName );
void OnLineEditLocationCityTextChanged ( const QString& strNewCity ); void OnLineEditLocationCityTextChanged ( const QString& strNewCity );
void OnComboBoxLocationCountryActivated ( int iCntryListItem ); void OnComboBoxLocationCountryActivated ( int iCntryListItem );

View file

@ -6,7 +6,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>588</width> <width>588</width>
<height>438</height> <height>378</height>
</rect> </rect>
</property> </property>
<property name="windowTitle" > <property name="windowTitle" >
@ -67,6 +67,9 @@
</property> </property>
</widget> </widget>
</item> </item>
<item>
<widget class="QLineEdit" name="LineEditCentralServerAddress" />
</item>
<item> <item>
<widget class="QCheckBox" name="cbDefaultCentralServer" > <widget class="QCheckBox" name="cbDefaultCentralServer" >
<property name="text" > <property name="text" >
@ -74,9 +77,6 @@
</property> </property>
</widget> </widget>
</item> </item>
<item>
<widget class="QLineEdit" name="LineEditCentralServerAddress" />
</item>
</layout> </layout>
</item> </item>
<item> <item>

View file

@ -349,6 +349,11 @@ int main ( int argc, char** argv )
if ( bUseGUI ) if ( bUseGUI )
{ {
// special case for the GUI mode: as the default we want to use
// the default central server address (if not given in the
// settings file)
Server.SetUseDefaultCentralServerAddress ( true );
// load settings from init-file // load settings from init-file
CSettings Settings ( &Server ); CSettings Settings ( &Server );
Settings.Load ( strIniFileName ); Settings.Load ( strIniFileName );

View file

@ -141,6 +141,12 @@ public:
QString GetServerListCentralServerAddress() QString GetServerListCentralServerAddress()
{ return ServerListManager.GetCentralServerAddress(); } { return ServerListManager.GetCentralServerAddress(); }
void SetUseDefaultCentralServerAddress ( const bool bNUDCSeAddr )
{ ServerListManager.SetUseDefaultCentralServerAddress ( bNUDCSeAddr ); }
bool GetUseDefaultCentralServerAddress()
{ return ServerListManager.GetUseDefaultCentralServerAddress(); }
void SetServerName ( const QString& strNewName ) void SetServerName ( const QString& strNewName )
{ ServerListManager.SetServerName ( strNewName ); } { ServerListManager.SetServerName ( strNewName ); }

View file

@ -29,7 +29,8 @@
CServerListManager::CServerListManager ( const QString& sNCentServAddr, CServerListManager::CServerListManager ( const QString& sNCentServAddr,
const QString& strServerInfo, const QString& strServerInfo,
CProtocol* pNConLProt ) CProtocol* pNConLProt )
: pConnLessProtocol ( pNConLProt ) : bUseDefaultCentralServerAddress ( false ),
pConnLessProtocol ( pNConLProt )
{ {
// set the central server address // set the central server address
SetCentralServerAddress ( sNCentServAddr ); SetCentralServerAddress ( sNCentServAddr );
@ -294,6 +295,17 @@ void CServerListManager::OnTimerRegistering()
if ( !bIsCentralServer && bEnabled ) if ( !bIsCentralServer && bEnabled )
{ {
// get the correct central server address
QString strCurCentrServAddr;
if ( bUseDefaultCentralServerAddress )
{
strCurCentrServAddr = DEFAULT_SERVER_ADDRESS;
}
else
{
strCurCentrServAddr = strCentralServerAddress;
}
// For the slave server, the slave server properties are store in the // For the slave server, the slave server properties are store in the
// very first item in the server list (which is actually no server list // very first item in the server list (which is actually no server list
// but just one item long for the slave server). // but just one item long for the slave server).
@ -301,7 +313,7 @@ void CServerListManager::OnTimerRegistering()
// it is an URL of a dynamic IP address, the IP address might have // it is an URL of a dynamic IP address, the IP address might have
// changed in the meanwhile. // changed in the meanwhile.
CHostAddress HostAddress; CHostAddress HostAddress;
if ( LlconNetwUtil().ParseNetworkAddress ( strCentralServerAddress, if ( LlconNetwUtil().ParseNetworkAddress ( strCurCentrServAddr,
HostAddress ) ) HostAddress ) )
{ {
pConnLessProtocol->CreateCLRegisterServerMes ( HostAddress, pConnLessProtocol->CreateCLRegisterServerMes ( HostAddress,

View file

@ -135,6 +135,12 @@ public:
void SetCentralServerAddress ( const QString sNCentServAddr ); void SetCentralServerAddress ( const QString sNCentServAddr );
QString GetCentralServerAddress() { return strCentralServerAddress; } QString GetCentralServerAddress() { return strCentralServerAddress; }
void SetUseDefaultCentralServerAddress ( const bool bNUDCSeAddr )
{ bUseDefaultCentralServerAddress = bNUDCSeAddr; }
bool GetUseDefaultCentralServerAddress()
{ return bUseDefaultCentralServerAddress; }
bool GetIsCentralServer() const { return bIsCentralServer; } bool GetIsCentralServer() const { return bIsCentralServer; }
void RegisterServer ( const CHostAddress& InetAddr, void RegisterServer ( const CHostAddress& InetAddr,
@ -169,6 +175,7 @@ protected:
QString strCentralServerAddress; QString strCentralServerAddress;
bool bEnabled; bool bEnabled;
bool bIsCentralServer; bool bIsCentralServer;
bool bUseDefaultCentralServerAddress;
CProtocol* pConnLessProtocol; CProtocol* pConnLessProtocol;

View file

@ -197,6 +197,12 @@ void CSettings::ReadIniFile ( const QString& sFileName )
pServer->SetServerListCentralServerAddress ( pServer->SetServerListCentralServerAddress (
GetIniSetting ( IniXMLDocument, "server", "centralservaddr" ) ); GetIniSetting ( IniXMLDocument, "server", "centralservaddr" ) );
// use default central server address flag
if ( GetFlagIniSet ( IniXMLDocument, "server", "defcentservaddr", bValue ) )
{
pServer->SetUseDefaultCentralServerAddress ( bValue );
}
// server list enabled flag // server list enabled flag
if ( GetFlagIniSet ( IniXMLDocument, "server", "servlistenabled", bValue ) ) if ( GetFlagIniSet ( IniXMLDocument, "server", "servlistenabled", bValue ) )
{ {
@ -309,6 +315,10 @@ void CSettings::WriteIniFile ( const QString& sFileName )
PutIniSetting ( IniXMLDocument, "server", "centralservaddr", PutIniSetting ( IniXMLDocument, "server", "centralservaddr",
pServer->GetServerListCentralServerAddress() ); pServer->GetServerListCentralServerAddress() );
// use default central server address flag
SetFlagIniSet ( IniXMLDocument, "server", "defcentservaddr",
pServer->GetUseDefaultCentralServerAddress() );
// server list enabled flag // server list enabled flag
SetFlagIniSet ( IniXMLDocument, "server", "servlistenabled", SetFlagIniSet ( IniXMLDocument, "server", "servlistenabled",
pServer->GetServerListEnabled() ); pServer->GetServerListEnabled() );