the connection setup dialog can now be opened during a connection

This commit is contained in:
Volker Fischer 2013-05-03 19:11:01 +00:00
parent 8320b93a9a
commit dc22883150
5 changed files with 181 additions and 172 deletions

View file

@ -1,5 +1,7 @@
3.3.2 3.3.2
- the connection setup dialog can now be opened during a connection
3.3.1 3.3.1
@ -10,8 +12,7 @@
- improved server performance under Linux - improved server performance under Linux
- changed the network buffer for improved OPUS PLC - changed the network buffer for improved OPUS PLC performance
performance
- added protocol overhead for DSL line for upload rate calculation - added protocol overhead for DSL line for upload rate calculation

View file

@ -279,16 +279,24 @@ CClientDlg::CClientDlg ( CClient* pNCliP,
SetMyWindowTitle ( 0 ); SetMyWindowTitle ( 0 );
// connect on startup --- // Connect on startup ------------------------------------------------------
if ( bNewConnectOnStartup ) if ( bNewConnectOnStartup )
{ {
// since the software starts up right now, the previous state was // per definition use the last connection (first entry in the
// "not connected" so we start the connection // stored address list)
ConnectDisconnect ( true, true ); const QString strSelectedAddress = pClient->vstrIPAddress[0];
// only if address is not empty, start the client
if ( !strSelectedAddress.isEmpty() )
{
// initiate connection (always show the address in the mixer board
// (no alias))
Connect ( strSelectedAddress, strSelectedAddress );
}
} }
// disable controls on request --- // Disable controls on request ---------------------------------------------
// disable LEDs in main window if requested // disable LEDs in main window if requested
if ( bNewDisalbeLEDs ) if ( bNewDisalbeLEDs )
{ {
@ -316,7 +324,10 @@ CClientDlg::CClientDlg ( CClient* pNCliP,
// View menu -------------------------------------------------------------- // View menu --------------------------------------------------------------
pViewMenu = new QMenu ( "&View", this ); pViewMenu = new QMenu ( "&View", this );
pViewMenu->addAction ( tr ( "&Chat..." ), this, pViewMenu->addAction ( tr ( "&Connection Setup..." ), this,
SLOT ( OnOpenConnectionSetupDialog() ) );
pViewMenu->addAction ( tr ( "C&hat..." ), this,
SLOT ( OnOpenChatDialog() ) ); SLOT ( OnOpenChatDialog() ) );
pViewMenu->addAction ( tr ( "&General Settings..." ), this, pViewMenu->addAction ( tr ( "&General Settings..." ), this,
@ -467,6 +478,9 @@ CClientDlg::CClientDlg ( CClient* pNCliP,
QObject::connect ( &ConnectDlg, SIGNAL ( CreateCLServerListPingMes ( CHostAddress ) ), QObject::connect ( &ConnectDlg, SIGNAL ( CreateCLServerListPingMes ( CHostAddress ) ),
this, SLOT ( OnCreateCLServerListPingMes ( CHostAddress ) ) ); this, SLOT ( OnCreateCLServerListPingMes ( CHostAddress ) ) );
QObject::connect ( &ConnectDlg, SIGNAL ( accepted() ),
this, SLOT ( OnConnectDlgAccepted() ) );
// Timers ------------------------------------------------------------------ // Timers ------------------------------------------------------------------
// start timer for status bar // start timer for status bar
@ -563,11 +577,69 @@ void CClientDlg::OnAudioPanValueChanged ( int value )
UpdateAudioFaderSlider(); UpdateAudioFaderSlider();
} }
void CClientDlg::OnConnectDlgAccepted()
{
// get the address from the connect dialog
const QString strSelectedAddress = ConnectDlg.GetSelectedAddress();
// only store new host address in our data base if the address is
// not empty and it was not a server list item (only the addresses
// typed in manually are stored by definition)
if ( !strSelectedAddress.isEmpty() &&
!ConnectDlg.GetServerListItemWasChosen() )
{
// store new address at the top of the list, if the list was already
// full, the last element is thrown out
pClient->vstrIPAddress.StringFiFoWithCompare ( strSelectedAddress );
}
// get name to be set in audio mixer group box title
QString strMixerBoardLabel;
if ( ConnectDlg.GetServerListItemWasChosen() )
{
// in case a server in the server list was chosen,
// display the server name of the server list
strMixerBoardLabel = ConnectDlg.GetSelectedServerName();
}
else
{
// an item of the server address combo box was chosen,
// just show the address string as it was entered by the
// user
strMixerBoardLabel = strSelectedAddress;
}
// first check if we are already connected, if this is the case we have to
// disconnect the old server first
if ( pClient->IsRunning() )
{
Disconnect();
}
// initiate connection
Connect ( strSelectedAddress, strMixerBoardLabel );
}
void CClientDlg::OnConnectDisconBut() void CClientDlg::OnConnectDisconBut()
{ {
// the connect/disconnect button implements a toggle functionality // the connect/disconnect button implements a toggle functionality
// -> apply inverted running state if ( pClient->IsRunning() )
ConnectDisconnect ( !pClient->IsRunning() ); {
Disconnect();
}
else
{
ShowConnectionSetupDialog();
}
}
void CClientDlg::OnDisconnected()
{
// channel is now disconnected, clear mixer board (remove all faders)
MainMixerBoard->HideAll();
UpdateDisplay();
} }
void CClientDlg::OnInstPictureBut() void CClientDlg::OnInstPictureBut()
@ -617,14 +689,6 @@ void CClientDlg::OnChatTextReceived ( QString strChatText )
UpdateDisplay(); UpdateDisplay();
} }
void CClientDlg::OnDisconnected()
{
// channel is now disconnected, clear mixer board (remove all faders)
MainMixerBoard->HideAll();
UpdateDisplay();
}
void CClientDlg::OnConClientListMesReceived ( CVector<CChannelInfo> vecChanInfo ) void CClientDlg::OnConClientListMesReceived ( CVector<CChannelInfo> vecChanInfo )
{ {
// update mixer board with the additional client infos // update mixer board with the additional client infos
@ -660,6 +724,24 @@ void CClientDlg::SetMyWindowTitle ( const int iNumClients )
} }
} }
void CClientDlg::ShowConnectionSetupDialog()
{
// get the central server address string
const QString strCurCentServAddr =
SELECT_SERVER_ADDRESS ( pClient->GetUseDefaultCentralServerAddress(),
pClient->GetServerListCentralServerAddress() );
// init the connect dialog
ConnectDlg.Init ( strCurCentServAddr, pClient->vstrIPAddress );
// show connect dialog
ConnectDlg.show();
// make sure dialog is upfront and has focus
ConnectDlg.raise();
ConnectDlg.activateWindow();
}
void CClientDlg::ShowGeneralSettings() void CClientDlg::ShowGeneralSettings()
{ {
// open general settings dialog // open general settings dialog
@ -842,140 +924,69 @@ void CClientDlg::OnCLPingTimeWithNumClientsReceived ( CHostAddress InetAddr,
iNumClients ); iNumClients );
} }
void CClientDlg::ConnectDisconnect ( const bool bDoStart, void CClientDlg::Connect ( const QString& strSelectedAddress,
const bool bConnectOnStartup ) const QString& strMixerBoardLabel )
{ {
// start/stop client, set button text // set address and check if address is valid
if ( bDoStart ) if ( pClient->SetServerAddr ( strSelectedAddress ) )
{ {
QString strSelectedAddress; // try to start client, if error occurred, do not go in
bool bConnectStateOK = false; // init flag // running state but show error message
try
// only show connection dialog if this is not a connection on startup
if ( bConnectOnStartup )
{ {
// per definition use the last connection (first entry in the pClient->Start();
// stored address list)
strSelectedAddress = pClient->vstrIPAddress[0];
// only if address is not empty, start the client
if ( !strSelectedAddress.isEmpty() )
{
bConnectStateOK = true;
}
}
else
{
// get the central server address string
const QString strCurCentServAddr =
SELECT_SERVER_ADDRESS ( pClient->GetUseDefaultCentralServerAddress(),
pClient->GetServerListCentralServerAddress() );
// init the connect dialog and execute it (modal dialog)
ConnectDlg.Init ( strCurCentServAddr, pClient->vstrIPAddress );
ConnectDlg.exec();
// check if state is OK (e.g., no Cancel was pressed)
if ( ConnectDlg.GetStateOK() )
{
strSelectedAddress = ConnectDlg.GetSelectedAddress();
// only store new host address in our data base if the address is
// not empty and it was not a server list item (only the addresses
// typed in manually are stored by definition)
if ( !strSelectedAddress.isEmpty() &&
!ConnectDlg.GetServerListItemWasChosen() )
{
// store new address at the top of the list, if the list was already
// full, the last element is thrown out
pClient->vstrIPAddress.StringFiFoWithCompare ( strSelectedAddress );
}
// everything was ok with the connection dialog, set flag
bConnectStateOK = true;
}
} }
// only start connection action if the connection state is ok catch ( CGenErr generr )
if ( bConnectStateOK )
{ {
// set address and check if address is valid // show error message and return the function
if ( pClient->SetServerAddr ( strSelectedAddress ) ) QMessageBox::critical (
{ this, APP_NAME, generr.GetErrorText(), "Close", 0 );
bool bStartOk = true;
// try to start client, if error occurred, do not go in return;
// running state but show error message
try
{
pClient->Start();
}
catch ( CGenErr generr )
{
QMessageBox::critical (
this, APP_NAME, generr.GetErrorText(), "Close", 0 );
bStartOk = false;
}
if ( bStartOk )
{
// change connect button text to "disconnect"
butConnect->setText ( CON_BUT_DISCONNECTTEXT );
// set server name in audio mixer group box title
if ( ConnectDlg.GetServerListItemWasChosen() )
{
// in case a server in the server list was chosen,
// display the server name of the server list
MainMixerBoard->SetServerName (
ConnectDlg.GetSelectedServerName() );
}
else
{
// an item of the server address combo box was chosen,
// just show the address string as it was entered by the
// user
MainMixerBoard->SetServerName ( strSelectedAddress );
}
// start timer for level meter bar and ping time measurement
TimerSigMet.start ( LEVELMETER_UPDATE_TIME_MS );
TimerPing.start ( PING_UPDATE_TIME_MS );
}
}
else
{
// show the error as red light
ledConnection->SetLight ( MUL_COL_LED_RED );
}
} }
// change connect button text to "disconnect"
butConnect->setText ( CON_BUT_DISCONNECTTEXT );
// set server name in audio mixer group box title
MainMixerBoard->SetServerName ( strMixerBoardLabel );
// start timer for level meter bar and ping time measurement
TimerSigMet.start ( LEVELMETER_UPDATE_TIME_MS );
TimerPing.start ( PING_UPDATE_TIME_MS );
} }
else else
{ {
// only stop client if currently running, in case we received // show the error as red light
// the stopped message, the client is already stopped but the ledConnection->SetLight ( MUL_COL_LED_RED );
// connect/disconnect button and other GUI controls must be }
// updated }
if ( pClient->IsRunning() )
{
pClient->Stop();
}
// change connect button text to "connect" void CClientDlg::Disconnect()
butConnect->setText ( CON_BUT_CONNECTTEXT ); {
// only stop client if currently running, in case we received
// the stopped message, the client is already stopped but the
// connect/disconnect button and other GUI controls must be
// updated
if ( pClient->IsRunning() )
{
pClient->Stop();
}
// reset server name in audio mixer group box title // change connect button text to "connect"
MainMixerBoard->SetServerName ( "" ); butConnect->setText ( CON_BUT_CONNECTTEXT );
// stop timer for level meter bars and reset them // reset server name in audio mixer group box title
TimerSigMet.stop(); MainMixerBoard->SetServerName ( "" );
lbrInputLevelL->setValue ( 0 );
lbrInputLevelR->setValue ( 0 );
// stop ping time measurement timer // stop timer for level meter bars and reset them
TimerPing.stop(); TimerSigMet.stop();
lbrInputLevelL->setValue ( 0 );
lbrInputLevelR->setValue ( 0 );
// stop ping time measurement timer
TimerPing.stop();
// TODO is this still required??? // TODO is this still required???
@ -990,9 +1001,8 @@ ledDelay->Reset();
ledChat->Reset(); ledChat->Reset();
// clear mixer board (remove all faders) // clear mixer board (remove all faders)
MainMixerBoard->HideAll(); MainMixerBoard->HideAll();
}
} }
void CClientDlg::UpdateDisplay() void CClientDlg::UpdateDisplay()

View file

@ -80,13 +80,15 @@ public:
protected: protected:
void SetGUIDesign ( const EGUIDesign eNewDesign ); void SetGUIDesign ( const EGUIDesign eNewDesign );
void SetMyWindowTitle ( const int iNumClients ); void SetMyWindowTitle ( const int iNumClients );
void ShowConnectionSetupDialog();
void ShowGeneralSettings(); void ShowGeneralSettings();
void ShowChatWindow(); void ShowChatWindow();
void ShowAnalyzerConsole(); void ShowAnalyzerConsole();
void UpdateAudioFaderSlider(); void UpdateAudioFaderSlider();
void UpdateRevSelection(); void UpdateRevSelection();
void ConnectDisconnect ( const bool bDoStart, void Connect ( const QString& strSelectedAddress,
const bool bConnectOnStartup = false ); const QString& strMixerBoardLabel );
void Disconnect();
CClient* pClient; CClient* pClient;
CSettings* pSettings; CSettings* pSettings;
@ -125,6 +127,7 @@ public slots:
int iPingTime, int iPingTime,
int iNumClients ); int iNumClients );
void OnOpenConnectionSetupDialog() { ShowConnectionSetupDialog(); }
void OnOpenGeneralSettings() { ShowGeneralSettings(); } void OnOpenGeneralSettings() { ShowGeneralSettings(); }
void OnOpenChatDialog() { ShowChatWindow(); } void OnOpenChatDialog() { ShowChatWindow(); }
void OnOpenAnalyzerConsole() { ShowAnalyzerConsole(); } void OnOpenAnalyzerConsole() { ShowAnalyzerConsole(); }
@ -165,6 +168,7 @@ public slots:
CVector<CServerInfo> vecServerInfo ) CVector<CServerInfo> vecServerInfo )
{ ConnectDlg.SetServerList ( InetAddr, vecServerInfo ); } { ConnectDlg.SetServerList ( InetAddr, vecServerInfo ); }
void OnConnectDlgAccepted();
void OnDisconnected(); void OnDisconnected();
void OnUpstreamRateChanged() void OnUpstreamRateChanged()

View file

@ -35,7 +35,6 @@ CConnectDlg::CConnectDlg ( const bool bNewShowCompleteRegList,
strSelectedServerName ( "" ), strSelectedServerName ( "" ),
bShowCompleteRegList ( bNewShowCompleteRegList ), bShowCompleteRegList ( bNewShowCompleteRegList ),
bServerListReceived ( false ), bServerListReceived ( false ),
bStateOK ( false ),
bServerListItemWasChosen ( false ) bServerListItemWasChosen ( false )
{ {
setupUi ( this ); setupUi ( this );
@ -132,6 +131,7 @@ void CConnectDlg::Init ( const QString strNewCentralServerAddr,
// load stored IP addresses in combo box // load stored IP addresses in combo box
cbxServerAddr->clear(); cbxServerAddr->clear();
for ( int iLEIdx = 0; iLEIdx < MAX_NUM_SERVER_ADDR_ITEMS; iLEIdx++ ) for ( int iLEIdx = 0; iLEIdx < MAX_NUM_SERVER_ADDR_ITEMS; iLEIdx++ )
{ {
if ( !vstrIPAddresses[iLEIdx].isEmpty() ) if ( !vstrIPAddresses[iLEIdx].isEmpty() )
@ -146,7 +146,6 @@ void CConnectDlg::showEvent ( QShowEvent* )
// reset flags (on opening the connect dialg, we always want to request a // reset flags (on opening the connect dialg, we always want to request a
// new updated server list per definition) // new updated server list per definition)
bServerListReceived = false; bServerListReceived = false;
bStateOK = false;
bServerListItemWasChosen = false; bServerListItemWasChosen = false;
// clear current address and name // clear current address and name
@ -173,28 +172,6 @@ void CConnectDlg::showEvent ( QShowEvent* )
void CConnectDlg::hideEvent ( QHideEvent* ) void CConnectDlg::hideEvent ( QHideEvent* )
{ {
// get the IP address to be used according to the following definitions:
// - if the list has focus and a line is selected, use this line
// - if the list has no focus, use the current combo box text
QList<QTreeWidgetItem*> CurSelListItemList = lvwServers->selectedItems();
if ( CurSelListItemList.count() > 0 )
{
// get host address from selected list view item as a string
strSelectedAddress =
CurSelListItemList[0]->data ( 0, Qt::UserRole ).toString();
// store selected server name
strSelectedServerName = CurSelListItemList[0]->text ( 0 );
// set flag that a server list item was chosen to connect
bServerListItemWasChosen = true;
}
else
{
strSelectedAddress = cbxServerAddr->currentText();
}
// if window is closed, stop timers // if window is closed, stop timers
TimerPing.stop(); TimerPing.stop();
TimerReRequestServList.stop(); TimerReRequestServList.stop();
@ -353,11 +330,30 @@ void CConnectDlg::OnServerAddrEditTextChanged ( const QString& )
void CConnectDlg::OnConnectClicked() void CConnectDlg::OnConnectClicked()
{ {
// set state OK flag // get the IP address to be used according to the following definitions:
bStateOK = true; // - if the list has focus and a line is selected, use this line
// - if the list has no focus, use the current combo box text
QList<QTreeWidgetItem*> CurSelListItemList = lvwServers->selectedItems();
// close dialog if ( CurSelListItemList.count() > 0 )
close(); {
// get host address from selected list view item as a string
strSelectedAddress =
CurSelListItemList[0]->data ( 0, Qt::UserRole ).toString();
// store selected server name
strSelectedServerName = CurSelListItemList[0]->text ( 0 );
// set flag that a server list item was chosen to connect
bServerListItemWasChosen = true;
}
else
{
strSelectedAddress = cbxServerAddr->currentText();
}
// tell the parent window that the connection shall be initiated
done ( QDialog::Accepted );
} }
void CConnectDlg::OnTimerPing() void CConnectDlg::OnTimerPing()

View file

@ -61,7 +61,6 @@ public:
const int iPingTimeLEDColor, const int iPingTimeLEDColor,
const int iNumClients ); const int iNumClients );
bool GetStateOK() const { return bStateOK; }
bool GetServerListItemWasChosen() const { return bServerListItemWasChosen; } bool GetServerListItemWasChosen() const { return bServerListItemWasChosen; }
QString GetSelectedAddress() const { return strSelectedAddress; } QString GetSelectedAddress() const { return strSelectedAddress; }
QString GetSelectedServerName() const { return strSelectedServerName; } QString GetSelectedServerName() const { return strSelectedServerName; }
@ -79,7 +78,6 @@ protected:
QString strSelectedServerName; QString strSelectedServerName;
bool bShowCompleteRegList; bool bShowCompleteRegList;
bool bServerListReceived; bool bServerListReceived;
bool bStateOK;
bool bServerListItemWasChosen; bool bServerListItemWasChosen;
public slots: public slots: