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 );
// add help text to controls -----------------------------------------------
// Add help text to controls -----------------------------------------------
lineEditLocalInputText->setAccessibleName ( "New chat text edit box" );
TextViewChatWindow->setAccessibleName ( "Chat history" );

View File

@ -31,6 +31,7 @@ CClientSettingsDlg::CClientSettingsDlg ( CClient* pNCliP, QWidget* parent,
{
setupUi ( this );
// Add help text to controls -----------------------------------------------
// jitter buffer
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"
// 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)
#define SYSTEM_SAMPLE_RATE_HZ 48000 // Hz

View File

@ -55,6 +55,7 @@ CLlconClientDlg::CLlconClientDlg ( CClient* pNCliP,
{
setupUi ( this );
// Add help text to controls -----------------------------------------------
// input level meter
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 );
// 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
TextLabelNameVersion->setText ( QString ( APP_NAME ) +
tr ( " server " ) + QString ( VERSION ) );
@ -54,6 +123,16 @@ CLlconServerDlg::CLlconServerDlg ( CServer* pNServP, QWidget* parent )
LineEditCentralServerAddress->setText (
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
LineEditServerName->setText ( pServer->GetServerName() );
@ -86,9 +165,7 @@ CLlconServerDlg::CLlconServerDlg ( CServer* pNServP, QWidget* parent )
static_cast<int> ( pServer->GetServerCountry() ) ) );
// update register server check box
const bool bCurSerListEnabled = pServer->GetServerListEnabled();
if ( bCurSerListEnabled )
if ( pServer->GetServerListEnabled() )
{
cbRegisterServer->setCheckState ( Qt::Checked );
}
@ -97,8 +174,8 @@ CLlconServerDlg::CLlconServerDlg ( CServer* pNServP, QWidget* parent )
cbRegisterServer->setCheckState ( Qt::Unchecked );
}
// update GUI dependency
UpdateServerInfosDependency ( bCurSerListEnabled );
// update GUI dependencies
UpdateGUIDependencies();
// Main menu bar -----------------------------------------------------------
@ -114,10 +191,13 @@ CLlconServerDlg::CLlconServerDlg ( CServer* pNServP, QWidget* parent )
QObject::connect ( cbRegisterServer, SIGNAL ( stateChanged ( int ) ),
this, SLOT ( OnRegisterServerStateChanged ( int ) ) );
QObject::connect ( cbDefaultCentralServer, SIGNAL ( stateChanged ( int ) ),
this, SLOT ( OnDefaultCentralServerStateChanged ( int ) ) );
// line edits
QObject::connect ( LineEditCentralServerAddress,
SIGNAL ( textChanged ( const QString& ) ),
this, SLOT ( OnLineEditCentralServerAddressTextChanged ( const QString& ) ) );
SIGNAL ( editingFinished() ),
this, SLOT ( OnLineEditCentralServerAddressEditingFinished() ) );
QObject::connect ( LineEditServerName, SIGNAL ( textChanged ( const QString& ) ),
this, SLOT ( OnLineEditServerNameTextChanged ( const QString& ) ) );
@ -138,58 +218,64 @@ CLlconServerDlg::CLlconServerDlg ( CServer* pNServP, QWidget* parent )
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
pServer->SetServerListEnabled ( bEnabled );
pServer->SetUseDefaultCentralServerAddress ( value == Qt::Checked );
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
pServer->SetServerListCentralServerAddress ( strNewAddr );
pServer->SetServerListEnabled ( value == Qt::Checked );
pServer->UpdateServerList();
// TODO
// only apply this in case the focus is lost and the name has actually changed!
pServer->UpdateServerList();
// update GUI dependencies
UpdateGUIDependencies();
}
void CLlconServerDlg::OnLineEditCentralServerAddressEditingFinished()
{
// apply new setting to the server and update it
pServer->SetServerListCentralServerAddress (
LineEditCentralServerAddress->text() );
pServer->UpdateServerList();
}
void CLlconServerDlg::OnLineEditServerNameTextChanged ( const QString& strNewName )
{
// check length
if ( strNewName.length() <= MAX_LEN_SERVER_NAME )
{
// 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 ) );
}
else
{
// text is too long, update control with shortend text
LineEditServerName->setText ( strNewName.left ( MAX_LEN_SERVER_NAME ) );
}
}
void CLlconServerDlg::OnLineEditLocationCityTextChanged ( const QString& strNewCity )
{
// check length
if ( strNewCity.length() <= MAX_LEN_SERVER_CITY )
{
// 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 ) );
}
else
{
// text is too long, update control with shortend text
LineEditLocationCity->setText ( strNewCity.left ( MAX_LEN_SERVER_CITY ) );
}
}
@ -250,14 +336,41 @@ void CLlconServerDlg::OnTimer()
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
// controls for the server list
LabelCentralServerAddress->setEnabled ( bState );
cbDefaultCentralServer->setEnabled ( bState );
LineEditCentralServerAddress->setEnabled ( bState );
GroupBoxServerInfo->setEnabled ( bState );
cbDefaultCentralServer->setEnabled ( bCurSerListEnabled );
LineEditCentralServerAddress->setEnabled ( bCurSerListEnabled );
GroupBoxServerInfo->setEnabled ( bCurSerListEnabled );
// 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 )

View File

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

View File

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

View File

@ -349,6 +349,11 @@ int main ( int argc, char** argv )
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
CSettings Settings ( &Server );
Settings.Load ( strIniFileName );

View File

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

View File

@ -29,7 +29,8 @@
CServerListManager::CServerListManager ( const QString& sNCentServAddr,
const QString& strServerInfo,
CProtocol* pNConLProt )
: pConnLessProtocol ( pNConLProt )
: bUseDefaultCentralServerAddress ( false ),
pConnLessProtocol ( pNConLProt )
{
// set the central server address
SetCentralServerAddress ( sNCentServAddr );
@ -294,6 +295,17 @@ void CServerListManager::OnTimerRegistering()
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
// very first item in the server list (which is actually no server list
// 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
// changed in the meanwhile.
CHostAddress HostAddress;
if ( LlconNetwUtil().ParseNetworkAddress ( strCentralServerAddress,
if ( LlconNetwUtil().ParseNetworkAddress ( strCurCentrServAddr,
HostAddress ) )
{
pConnLessProtocol->CreateCLRegisterServerMes ( HostAddress,

View File

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

View File

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