put connect/disconnect button functionality in separate function

This commit is contained in:
Volker Fischer 2009-08-17 17:39:40 +00:00
parent 61b086d898
commit 9ac8be8af1
2 changed files with 65 additions and 55 deletions

View File

@ -335,61 +335,9 @@ void CLlconClientDlg::OnLineEditServerAddrActivated ( int index )
void CLlconClientDlg::OnConnectDisconBut()
{
// start/stop client, set button text
if ( !pClient->IsRunning() )
{
// set address and check if address is valid
if ( pClient->SetServerAddr ( LineEditServerAddr->currentText() ) )
{
bool bStartOk = true;
try
{
pClient->Start();
}
catch ( CGenErr generr )
{
QMessageBox::critical (
this, APP_NAME, generr.GetErrorText(), "Close", 0 );
bStartOk = false;
}
if ( bStartOk )
{
PushButtonConnect->setText ( CON_BUT_DISCONNECTTEXT );
// start timer for level meter bar
TimerSigMet.start ( LEVELMETER_UPDATE_TIME );
}
}
else
{
// Restart timer to ensure that the text is visible at
// least the time for one complete interval
TimerStatus.start ( STATUSBAR_UPDATE_TIME );
// show the error in the status bar
TextLabelStatus->setText ( tr ( "Invalid address" ) );
}
}
else
{
pClient->Stop();
PushButtonConnect->setText ( CON_BUT_CONNECTTEXT );
// stop timer for level meter bars and reset them
TimerSigMet.stop();
MultiColorLEDBarInputLevelL->setValue ( 0 );
MultiColorLEDBarInputLevelR->setValue ( 0 );
// immediately update status bar
OnTimerStatus();
// clear mixer board (remove all faders)
MainMixerBoard->HideAll();
}
// the connect/disconnect button implements a toggle functionality
// -> apply inverted running state
ConnectDisconnect ( !pClient->IsRunning() );
}
void CLlconClientDlg::OnOpenGeneralSettings()
@ -471,6 +419,67 @@ void CLlconClientDlg::OnTimerSigMet()
MultiColorLEDBarInputLevelR->setValue ( (int) ceil ( dCurSigLevelR ) );
}
void CLlconClientDlg::ConnectDisconnect ( const bool bDoStart )
{
// start/stop client, set button text
if ( bDoStart )
{
// set address and check if address is valid
if ( pClient->SetServerAddr ( LineEditServerAddr->currentText() ) )
{
bool bStartOk = true;
// try to start client, if error occurred, do not go in
// 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 )
{
PushButtonConnect->setText ( CON_BUT_DISCONNECTTEXT );
// start timer for level meter bar
TimerSigMet.start ( LEVELMETER_UPDATE_TIME );
}
}
else
{
// Restart timer to ensure that the text is visible at
// least the time for one complete interval
TimerStatus.start ( STATUSBAR_UPDATE_TIME );
// show the error in the status bar
TextLabelStatus->setText ( tr ( "Invalid address" ) );
}
}
else
{
pClient->Stop();
PushButtonConnect->setText ( CON_BUT_CONNECTTEXT );
// stop timer for level meter bars and reset them
TimerSigMet.stop();
MultiColorLEDBarInputLevelL->setValue ( 0 );
MultiColorLEDBarInputLevelR->setValue ( 0 );
// immediately update status bar
OnTimerStatus();
// clear mixer board (remove all faders)
MainMixerBoard->HideAll();
}
}
void CLlconClientDlg::UpdateDisplay()
{
// show connection status in status bar

View File

@ -74,6 +74,7 @@ public:
protected:
void ShowChatWindow();
void UpdateAudioFaderSlider();
void ConnectDisconnect ( const bool bDoStart );
CClient* pClient;
bool bConnected;