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
@@ -473,7 +464,11 @@ CClientDlg::CClientDlg ( CClient* pNCliP,
473464 // other
474465 QObject::connect ( pClient, &CClient::ConClientListMesReceived, this , &CClientDlg::OnConClientListMesReceived );
475466
476- QObject::connect ( pClient, &CClient::Disconnected, this , &CClientDlg::OnDisconnected );
467+ QObject::connect ( pClient, &CClient::Connected, this , &CClientDlg::OnConnect );
468+
469+ QObject::connect ( pClient, &CClient::ConnectingFailed, this , &CClientDlg::OnConnectingFailed );
470+
471+ QObject::connect ( pClient, &CClient::Disconnected, this , &CClientDlg::OnDisconnect );
477472
478473 QObject::connect ( pClient, &CClient::ChatTextReceived, this , &CClientDlg::OnChatTextReceived );
479474
@@ -608,11 +603,8 @@ void CClientDlg::closeEvent ( QCloseEvent* Event )
608603 ConnectDlg.close ();
609604 AnalyzerConsole.close ();
610605
611- // if connected, terminate connection
612- if ( pClient->IsRunning () )
613- {
614- pClient->Stop ();
615- }
606+ // Disconnect if needed
607+ pClient->Stop ();
616608
617609 // make sure all current fader settings are applied to the settings struct
618610 MainMixerBoard->StoreAllFaderSettings ();
@@ -730,15 +722,9 @@ void CClientDlg::OnConnectDlgAccepted()
730722 }
731723 }
732724
733- // first check if we are already connected, if this is the case we have to
734- // disconnect the old server first
735- if ( pClient->IsRunning () )
736- {
737- Disconnect ();
738- }
739-
740725 // initiate connection
741- Connect ( strSelectedAddress, strMixerBoardLabel );
726+
727+ pClient->Connect ( strSelectedAddress, strMixerBoardLabel );
742728
743729 // reset flag
744730 bConnectDlgWasShown = false ;
@@ -750,11 +736,12 @@ void CClientDlg::OnConnectDisconBut()
750736 // the connect/disconnect button implements a toggle functionality
751737 if ( pClient->IsRunning () )
752738 {
753- Disconnect ();
754- SetMixerBoardDeco ( RS_UNDEFINED, pClient->GetGUIDesign () );
739+ pClient->Stop ();
755740 }
756741 else
757742 {
743+ // If the client isn't running, we assume that we weren't connected. Thus show the connect dialog
744+ // TODO: Refactor to have robust error handling
758745 ShowConnectionSetupDialog ();
759746 }
760747}
@@ -859,7 +846,7 @@ void CClientDlg::OnLicenceRequired ( ELicenceType eLicenceType )
859846 // disconnect from that server.
860847 if ( !LicenceDlg.exec () )
861848 {
862- Disconnect ();
849+ pClient-> Stop ();
863850 }
864851
865852 // unmute the client output stream if local mute button is not pressed
@@ -1164,7 +1151,7 @@ void CClientDlg::OnSoundDeviceChanged ( QString strError )
11641151 // the sound device setup has a problem, disconnect any active connection
11651152 if ( pClient->IsRunning () )
11661153 {
1167- Disconnect ();
1154+ pClient-> Stop ();
11681155 }
11691156
11701157 // show the error message of the device setup
@@ -1193,65 +1180,38 @@ void CClientDlg::OnCLPingTimeWithNumClientsReceived ( CHostAddress InetAddr, int
11931180 ConnectDlg.SetPingTimeAndNumClientsResult ( InetAddr, iPingTime, iNumClients );
11941181}
11951182
1196- void CClientDlg::Connect ( const QString& strSelectedAddress, const QString& strMixerBoardLabel )
1183+ void CClientDlg::OnConnect ( const QString& strMixerBoardLabel )
11971184{
1198- // set address and check if address is valid
1199- if ( pClient->SetServerAddr ( strSelectedAddress ) )
1200- {
1201- // try to start client, if error occurred, do not go in
1202- // running state but show error message
1203- try
1204- {
1205- if ( !pClient->IsRunning () )
1206- {
1207- pClient->Start ();
1208- }
1209- }
12101185
1211- catch ( const CGenErr& generr )
1212- {
1213- // show error message and return the function
1214- QMessageBox::critical ( this , APP_NAME, generr.GetErrorText (), " Close" , nullptr );
1215- return ;
1216- }
1186+ // hide label connect to server
1187+ lblConnectToServer->hide ();
1188+ lbrInputLevelL->setEnabled ( true );
1189+ lbrInputLevelR->setEnabled ( true );
12171190
1218- // hide label connect to server
1219- lblConnectToServer->hide ();
1220- lbrInputLevelL->setEnabled ( true );
1221- lbrInputLevelR->setEnabled ( true );
1191+ // change connect button text to "disconnect"
1192+ butConnect->setText ( tr ( " &Disconnect" ) );
12221193
1223- // change connect button text to "disconnect"
1224- butConnect-> setText ( tr ( " &Disconnect " ) );
1194+ // set server name in audio mixer group box title
1195+ MainMixerBoard-> SetServerName ( strMixerBoardLabel );
12251196
1226- // set server name in audio mixer group box title
1227- MainMixerBoard->SetServerName ( strMixerBoardLabel );
1197+ // start timer for level meter bar and ping time measurement
1198+ TimerSigMet.start ( LEVELMETER_UPDATE_TIME_MS );
1199+ TimerBuffersLED.start ( BUFFER_LED_UPDATE_TIME_MS );
1200+ TimerPing.start ( PING_UPDATE_TIME_MS );
1201+ TimerCheckAudioDeviceOk.start ( CHECK_AUDIO_DEV_OK_TIME_MS ); // is single shot timer
12281202
1229- // start timer for level meter bar and ping time measurement
1230- TimerSigMet.start ( LEVELMETER_UPDATE_TIME_MS );
1231- TimerBuffersLED.start ( BUFFER_LED_UPDATE_TIME_MS );
1232- TimerPing.start ( PING_UPDATE_TIME_MS );
1233- TimerCheckAudioDeviceOk.start ( CHECK_AUDIO_DEV_OK_TIME_MS ); // is single shot timer
1234-
1235- // audio feedback detection
1236- if ( pSettings->bEnableFeedbackDetection )
1237- {
1238- TimerDetectFeedback.start ( DETECT_FEEDBACK_TIME_MS ); // single shot timer
1239- bDetectFeedback = true ;
1240- }
1203+ // audio feedback detection
1204+ if ( pSettings->bEnableFeedbackDetection )
1205+ {
1206+ TimerDetectFeedback.start ( DETECT_FEEDBACK_TIME_MS ); // single shot timer
1207+ bDetectFeedback = true ;
12411208 }
12421209}
12431210
1244- void CClientDlg::Disconnect ()
1245- {
1246- // only stop client if currently running, in case we received
1247- // the stopped message, the client is already stopped but the
1248- // connect/disconnect button and other GUI controls must be
1249- // updated
1250- if ( pClient->IsRunning () )
1251- {
1252- pClient->Stop ();
1253- }
1211+ void CClientDlg::OnConnectingFailed ( const QString& strError ) { QMessageBox::critical ( this , APP_NAME, strError, " Close" , nullptr ); }
12541212
1213+ void CClientDlg::OnDisconnect ()
1214+ {
12551215 // change connect button text to "connect"
12561216 butConnect->setText ( tr ( " C&onnect" ) );
12571217
@@ -1293,6 +1253,9 @@ void CClientDlg::Disconnect()
12931253
12941254 // clear mixer board (remove all faders)
12951255 MainMixerBoard->HideAll ();
1256+
1257+ // Reset the deco
1258+ SetMixerBoardDeco ( RS_UNDEFINED, pClient->GetGUIDesign () );
12961259}
12971260
12981261void CClientDlg::UpdateDisplay ()
0 commit comments