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,9 @@ 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- }
749-
750735 // initiate connection
751- Connect ( strSelectedAddress, strMixerBoardLabel );
736+
737+ pClient->Connect ( strSelectedAddress, strMixerBoardLabel );
752738
753739 // reset flag
754740 bConnectDlgWasShown = false ;
@@ -760,11 +746,12 @@ void CClientDlg::OnConnectDisconBut()
760746 // the connect/disconnect button implements a toggle functionality
761747 if ( pClient->IsRunning () )
762748 {
763- Disconnect ();
764- SetMixerBoardDeco ( RS_UNDEFINED, pClient->GetGUIDesign () );
749+ pClient->Stop ();
765750 }
766751 else
767752 {
753+ // If the client isn't running, we assume that we weren't connected. Thus show the connect dialog
754+ // TODO: Refactor to have robust error handling
768755 ShowConnectionSetupDialog ();
769756 }
770757}
@@ -869,7 +856,7 @@ void CClientDlg::OnLicenceRequired ( ELicenceType eLicenceType )
869856 // disconnect from that server.
870857 if ( !LicenceDlg.exec () )
871858 {
872- Disconnect ();
859+ pClient-> Stop ();
873860 }
874861
875862 // unmute the client output stream if local mute button is not pressed
@@ -1174,7 +1161,7 @@ void CClientDlg::OnSoundDeviceChanged ( QString strError )
11741161 // the sound device setup has a problem, disconnect any active connection
11751162 if ( pClient->IsRunning () )
11761163 {
1177- Disconnect ();
1164+ pClient-> Stop ();
11781165 }
11791166
11801167 // show the error message of the device setup
@@ -1203,65 +1190,38 @@ void CClientDlg::OnCLPingTimeWithNumClientsReceived ( CHostAddress InetAddr, int
12031190 ConnectDlg.SetPingTimeAndNumClientsResult ( InetAddr, iPingTime, iNumClients );
12041191}
12051192
1206- void CClientDlg::Connect ( const QString& strSelectedAddress, const QString& strMixerBoardLabel )
1193+ void CClientDlg::OnConnect ( const QString& strMixerBoardLabel )
12071194{
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- }
12201195
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- }
1196+ // hide label connect to server
1197+ lblConnectToServer->hide ();
1198+ lbrInputLevelL->setEnabled ( true );
1199+ lbrInputLevelR->setEnabled ( true );
12271200
1228- // hide label connect to server
1229- lblConnectToServer->hide ();
1230- lbrInputLevelL->setEnabled ( true );
1231- lbrInputLevelR->setEnabled ( true );
1201+ // change connect button text to "disconnect"
1202+ butConnect->setText ( tr ( " &Disconnect" ) );
12321203
1233- // change connect button text to "disconnect"
1234- butConnect-> setText ( tr ( " &Disconnect " ) );
1204+ // set server name in audio mixer group box title
1205+ MainMixerBoard-> SetServerName ( strMixerBoardLabel );
12351206
1236- // set server name in audio mixer group box title
1237- MainMixerBoard->SetServerName ( strMixerBoardLabel );
1207+ // start timer for level meter bar and ping time measurement
1208+ TimerSigMet.start ( LEVELMETER_UPDATE_TIME_MS );
1209+ TimerBuffersLED.start ( BUFFER_LED_UPDATE_TIME_MS );
1210+ TimerPing.start ( PING_UPDATE_TIME_MS );
1211+ TimerCheckAudioDeviceOk.start ( CHECK_AUDIO_DEV_OK_TIME_MS ); // is single shot timer
12381212
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- }
1213+ // audio feedback detection
1214+ if ( pSettings->bEnableFeedbackDetection )
1215+ {
1216+ TimerDetectFeedback.start ( DETECT_FEEDBACK_TIME_MS ); // single shot timer
1217+ bDetectFeedback = true ;
12511218 }
12521219}
12531220
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- }
1221+ void CClientDlg::OnConnectingFailed ( const QString& strError ) { QMessageBox::critical ( this , APP_NAME, strError, " Close" , nullptr ); }
12641222
1223+ void CClientDlg::OnDisconnect ()
1224+ {
12651225 // change connect button text to "connect"
12661226 butConnect->setText ( tr ( " C&onnect" ) );
12671227
@@ -1303,6 +1263,9 @@ void CClientDlg::Disconnect()
13031263
13041264 // clear mixer board (remove all faders)
13051265 MainMixerBoard->HideAll ();
1266+
1267+ // Reset the deco
1268+ SetMixerBoardDeco ( RS_UNDEFINED, pClient->GetGUIDesign () );
13061269}
13071270
13081271void CClientDlg::UpdateDisplay ()
0 commit comments