2727/* Implementation *************************************************************/
2828CClientDlg::CClientDlg ( CClient* pNCliP,
2929 CClientSettings* pNSetP,
30- const QString& strConnOnStartupAddress,
3130 const QString& strMIDISetup,
3231 const bool bNewShowComplRegConnList,
3332 const bool bShowAnalyzerConsole,
@@ -272,14 +271,6 @@ CClientDlg::CClientDlg ( CClient* pNCliP,
272271 TimerCheckAudioDeviceOk.setSingleShot ( true ); // only check once after connection
273272 TimerDetectFeedback.setSingleShot ( true );
274273
275- // Connect on startup ------------------------------------------------------
276- if ( !strConnOnStartupAddress.isEmpty () )
277- {
278- // initiate connection (always show the address in the mixer board
279- // (no alias))
280- Connect ( strConnOnStartupAddress, strConnOnStartupAddress );
281- }
282-
283274 // File menu --------------------------------------------------------------
284275 QMenu* pFileMenu = new QMenu ( tr ( " &File" ), this );
285276
@@ -483,7 +474,11 @@ CClientDlg::CClientDlg ( CClient* pNCliP,
483474 // other
484475 QObject::connect ( pClient, &CClient::ConClientListMesReceived, this , &CClientDlg::OnConClientListMesReceived );
485476
486- QObject::connect ( pClient, &CClient::Disconnected, this , &CClientDlg::OnDisconnected );
477+ QObject::connect ( pClient, &CClient::Connected, this , &CClientDlg::OnConnect );
478+
479+ QObject::connect ( pClient, &CClient::ConnectingFailed, this , &CClientDlg::OnConnectingFailed );
480+
481+ QObject::connect ( pClient, &CClient::Disconnected, this , &CClientDlg::OnDisconnect );
487482
488483 QObject::connect ( pClient, &CClient::ChatTextReceived, this , &CClientDlg::OnChatTextReceived );
489484
@@ -618,11 +613,8 @@ void CClientDlg::closeEvent ( QCloseEvent* Event )
618613 ConnectDlg.close ();
619614 AnalyzerConsole.close ();
620615
621- // if connected, terminate connection
622- if ( pClient->IsRunning () )
623- {
624- pClient->Stop ();
625- }
616+ // Disconnect if needed
617+ pClient->Stop ();
626618
627619 // make sure all current fader settings are applied to the settings struct
628620 MainMixerBoard->StoreAllFaderSettings ();
@@ -740,15 +732,12 @@ void CClientDlg::OnConnectDlgAccepted()
740732 }
741733 }
742734
743- // first check if we are already connected, if this is the case we have to
744- // disconnect the old server first
745- if ( pClient->IsRunning () )
746- {
747- Disconnect ();
748- }
735+ // Disconnect the client. We could be currently connected.
736+ pClient->Stop ();
749737
750738 // initiate connection
751- Connect ( strSelectedAddress, strMixerBoardLabel );
739+
740+ pClient->Connect ( strSelectedAddress, strMixerBoardLabel );
752741
753742 // reset flag
754743 bConnectDlgWasShown = false ;
@@ -760,11 +749,12 @@ void CClientDlg::OnConnectDisconBut()
760749 // the connect/disconnect button implements a toggle functionality
761750 if ( pClient->IsRunning () )
762751 {
763- Disconnect ();
764- SetMixerBoardDeco ( RS_UNDEFINED, pClient->GetGUIDesign () );
752+ pClient->Stop ();
765753 }
766754 else
767755 {
756+ // If the client isn't running, we assume that we weren't connected. Thus show the connect dialog
757+ // TODO: Refactor to have robust error handling
768758 ShowConnectionSetupDialog ();
769759 }
770760}
@@ -869,7 +859,7 @@ void CClientDlg::OnLicenceRequired ( ELicenceType eLicenceType )
869859 // disconnect from that server.
870860 if ( !LicenceDlg.exec () )
871861 {
872- Disconnect ();
862+ pClient-> Stop ();
873863 }
874864
875865 // unmute the client output stream if local mute button is not pressed
@@ -1174,7 +1164,7 @@ void CClientDlg::OnSoundDeviceChanged ( QString strError )
11741164 // the sound device setup has a problem, disconnect any active connection
11751165 if ( pClient->IsRunning () )
11761166 {
1177- Disconnect ();
1167+ pClient-> Stop ();
11781168 }
11791169
11801170 // show the error message of the device setup
@@ -1203,65 +1193,38 @@ void CClientDlg::OnCLPingTimeWithNumClientsReceived ( CHostAddress InetAddr, int
12031193 ConnectDlg.SetPingTimeAndNumClientsResult ( InetAddr, iPingTime, iNumClients );
12041194}
12051195
1206- void CClientDlg::Connect ( const QString& strSelectedAddress, const QString& strMixerBoardLabel )
1196+ void CClientDlg::OnConnect ( const QString& strMixerBoardLabel )
12071197{
1208- // set address and check if address is valid
1209- if ( pClient->SetServerAddr ( strSelectedAddress ) )
1210- {
1211- // try to start client, if error occurred, do not go in
1212- // running state but show error message
1213- try
1214- {
1215- if ( !pClient->IsRunning () )
1216- {
1217- pClient->Start ();
1218- }
1219- }
12201198
1221- catch ( const CGenErr& generr )
1222- {
1223- // show error message and return the function
1224- QMessageBox::critical ( this , APP_NAME, generr.GetErrorText (), " Close" , nullptr );
1225- return ;
1226- }
1199+ // hide label connect to server
1200+ lblConnectToServer->hide ();
1201+ lbrInputLevelL->setEnabled ( true );
1202+ lbrInputLevelR->setEnabled ( true );
12271203
1228- // hide label connect to server
1229- lblConnectToServer->hide ();
1230- lbrInputLevelL->setEnabled ( true );
1231- lbrInputLevelR->setEnabled ( true );
1204+ // change connect button text to "disconnect"
1205+ butConnect->setText ( tr ( " &Disconnect" ) );
12321206
1233- // change connect button text to "disconnect"
1234- butConnect-> setText ( tr ( " &Disconnect " ) );
1207+ // set server name in audio mixer group box title
1208+ MainMixerBoard-> SetServerName ( strMixerBoardLabel );
12351209
1236- // set server name in audio mixer group box title
1237- MainMixerBoard->SetServerName ( strMixerBoardLabel );
1210+ // start timer for level meter bar and ping time measurement
1211+ TimerSigMet.start ( LEVELMETER_UPDATE_TIME_MS );
1212+ TimerBuffersLED.start ( BUFFER_LED_UPDATE_TIME_MS );
1213+ TimerPing.start ( PING_UPDATE_TIME_MS );
1214+ TimerCheckAudioDeviceOk.start ( CHECK_AUDIO_DEV_OK_TIME_MS ); // is single shot timer
12381215
1239- // start timer for level meter bar and ping time measurement
1240- TimerSigMet.start ( LEVELMETER_UPDATE_TIME_MS );
1241- TimerBuffersLED.start ( BUFFER_LED_UPDATE_TIME_MS );
1242- TimerPing.start ( PING_UPDATE_TIME_MS );
1243- TimerCheckAudioDeviceOk.start ( CHECK_AUDIO_DEV_OK_TIME_MS ); // is single shot timer
1244-
1245- // audio feedback detection
1246- if ( pSettings->bEnableFeedbackDetection )
1247- {
1248- TimerDetectFeedback.start ( DETECT_FEEDBACK_TIME_MS ); // single shot timer
1249- bDetectFeedback = true ;
1250- }
1216+ // audio feedback detection
1217+ if ( pSettings->bEnableFeedbackDetection )
1218+ {
1219+ TimerDetectFeedback.start ( DETECT_FEEDBACK_TIME_MS ); // single shot timer
1220+ bDetectFeedback = true ;
12511221 }
12521222}
12531223
1254- void CClientDlg::Disconnect ()
1255- {
1256- // only stop client if currently running, in case we received
1257- // the stopped message, the client is already stopped but the
1258- // connect/disconnect button and other GUI controls must be
1259- // updated
1260- if ( pClient->IsRunning () )
1261- {
1262- pClient->Stop ();
1263- }
1224+ void CClientDlg::OnConnectingFailed ( const QString& strError ) { QMessageBox::critical ( this , APP_NAME, strError, " Close" , nullptr ); }
12641225
1226+ void CClientDlg::OnDisconnect ()
1227+ {
12651228 // change connect button text to "connect"
12661229 butConnect->setText ( tr ( " C&onnect" ) );
12671230
@@ -1303,6 +1266,9 @@ void CClientDlg::Disconnect()
13031266
13041267 // clear mixer board (remove all faders)
13051268 MainMixerBoard->HideAll ();
1269+
1270+ // Reset the deco
1271+ SetMixerBoardDeco ( RS_UNDEFINED, pClient->GetGUIDesign () );
13061272}
13071273
13081274void CClientDlg::UpdateDisplay ()
0 commit comments