diff --git a/src/clientsettingsdlg.cpp b/src/clientsettingsdlg.cpp index 6498b66a..94adb8ea 100755 --- a/src/clientsettingsdlg.cpp +++ b/src/clientsettingsdlg.cpp @@ -330,9 +330,6 @@ cbGUIDesignFancy->setVisible ( false ); QObject::connect ( &TimerStatus, SIGNAL ( timeout() ), this, SLOT ( OnTimerStatus() ) ); - QObject::connect ( &TimerPing, SIGNAL ( timeout() ), - this, SLOT ( OnTimerPing() ) ); - // slider controls QObject::connect ( SliderNetBuf, SIGNAL ( valueChanged ( int ) ), this, SLOT ( OnSliderNetBuf ( int ) ) ); @@ -374,9 +371,6 @@ cbGUIDesignFancy->setVisible ( false ); this, SLOT ( OnDriverSetupBut() ) ); // misc - QObject::connect ( pClient, SIGNAL ( PingTimeReceived ( int ) ), - this, SLOT ( OnPingTimeResult ( int ) ) ); - QObject::connect ( &SndCrdBufferDelayButtonGroup, SIGNAL ( buttonClicked ( QAbstractButton* ) ), this, SLOT ( OnSndCrdBufferDelayButtonGroupClicked ( QAbstractButton* ) ) ); @@ -494,20 +488,6 @@ void CClientSettingsDlg::UpdateSoundChannelSelectionFrame() #endif } -void CClientSettingsDlg::showEvent ( QShowEvent* ) -{ - // only activate ping timer if window is actually shown - TimerPing.start ( PING_UPDATE_TIME ); - - UpdateDisplay(); -} - -void CClientSettingsDlg::hideEvent ( QHideEvent* ) -{ - // if window is closed, stop timer for ping - TimerPing.stop(); -} - void CClientSettingsDlg::OnDriverSetupBut() { pClient->OpenSndCrdDriverSetup(); @@ -627,17 +607,10 @@ void CClientSettingsDlg::OnSndCrdBufferDelayButtonGroupClicked ( QAbstractButton UpdateDisplay(); } -void CClientSettingsDlg::OnTimerPing() +void CClientSettingsDlg::SetPingTimeResult ( const int iPingTime, + const int iOverallDelayMs, + const int iOverallDelayLEDColor ) { - // send ping message to server - pClient->SendPingMess(); -} - -void CClientSettingsDlg::OnPingTimeResult ( int iPingTime ) -{ - // calculate overall delay - const int iOverallDelayMs = pClient->EstimatedOverallDelay ( iPingTime ); - // apply values to GUI labels, take special care if ping time exceeds // a certain value if ( iPingTime > 500 ) @@ -655,22 +628,8 @@ void CClientSettingsDlg::OnPingTimeResult ( int iPingTime ) QString().setNum ( iOverallDelayMs ) + " ms" ); } - // color definition: < 40 ms green, < 65 ms yellow, otherwise red - if ( iOverallDelayMs <= 40 ) - { - CLEDOverallDelay->SetLight ( MUL_COL_LED_GREEN ); - } - else - { - if ( iOverallDelayMs <= 65 ) - { - CLEDOverallDelay->SetLight ( MUL_COL_LED_YELLOW ); - } - else - { - CLEDOverallDelay->SetLight ( MUL_COL_LED_RED ); - } - } + // set current LED status + CLEDOverallDelay->SetLight ( iOverallDelayLEDColor ); } void CClientSettingsDlg::UpdateDisplay() diff --git a/src/clientsettingsdlg.h b/src/clientsettingsdlg.h index 438484f3..3fe3cc52 100755 --- a/src/clientsettingsdlg.h +++ b/src/clientsettingsdlg.h @@ -51,7 +51,7 @@ /* Definitions ****************************************************************/ // update time for GUI controls #define DISPLAY_UPDATE_TIME 1000 // ms -#define PING_UPDATE_TIME 500 // ms +#define PING_UPDATE_TIME 500 // ms /* Classes ********************************************************************/ @@ -64,6 +64,9 @@ public: Qt::WindowFlags f = 0 ); void SetStatus ( const int iMessType, const int iStatus ); + void SetPingTimeResult ( const int iPingTime, + const int iOverallDelayMs, + const int iOverallDelayLEDColor ); protected: void UpdateJitterBufferFrame(); @@ -72,18 +75,15 @@ protected: QString GenSndCrdBufferDelayString ( const int iFrameSize, const QString strAddText = "" ); - virtual void showEvent ( QShowEvent* ); - virtual void hideEvent ( QHideEvent* ); + virtual void showEvent ( QShowEvent* ) { UpdateDisplay(); } CClient* pClient; QTimer TimerStatus; - QTimer TimerPing; QButtonGroup SndCrdBufferDelayButtonGroup; void UpdateDisplay(); public slots: void OnTimerStatus() { UpdateDisplay(); } - void OnTimerPing(); void OnSliderNetBuf ( int value ); void OnSliderSndCrdBufferDelay ( int value ); void OnAutoJitBuf ( int value ); @@ -92,7 +92,6 @@ protected: void OnUseHighQualityAudioStateChanged ( int value ); void OnUseStereoStateChanged ( int value ); void OnSndCrdBufferDelayButtonGroupClicked ( QAbstractButton* button ); - void OnPingTimeResult ( int iPingTime ); void OnSoundCrdSelection ( int iSndDevIdx ); void OnSndCrdLeftInChannelSelection ( int iChanIdx ); void OnSndCrdRightInChannelSelection ( int iChanIdx ); diff --git a/src/llconclientdlg.cpp b/src/llconclientdlg.cpp index 43c4a7df..a21da3de 100755 --- a/src/llconclientdlg.cpp +++ b/src/llconclientdlg.cpp @@ -324,6 +324,9 @@ CLlconClientDlg::CLlconClientDlg ( CClient* pNCliP, QObject::connect ( &TimerStatus, SIGNAL ( timeout() ), this, SLOT ( OnTimerStatus() ) ); + QObject::connect ( &TimerPing, SIGNAL ( timeout() ), + this, SLOT ( OnTimerPing() ) ); + // sliders QObject::connect ( SliderAudInFader, SIGNAL ( valueChanged ( int ) ), this, SLOT ( OnSliderAudInFader ( int ) ) ); @@ -365,6 +368,9 @@ CLlconClientDlg::CLlconClientDlg ( CClient* pNCliP, SIGNAL ( ChatTextReceived ( QString ) ), this, SLOT ( OnChatTextReceived ( QString ) ) ); + QObject::connect ( pClient, SIGNAL ( PingTimeReceived ( int ) ), + this, SLOT ( OnPingTimeResult ( int ) ) ); + QObject::connect ( &ClientSettingsDlg, SIGNAL ( GUIDesignChanged() ), this, SLOT ( OnGUIDesignChanged() ) ); @@ -646,6 +652,41 @@ void CLlconClientDlg::OnTimerSigMet() MultiColorLEDBarInputLevelR->setValue ( (int) ceil ( dCurSigLevelR ) ); } +void CLlconClientDlg::OnTimerPing() +{ + // send ping message to server + pClient->SendPingMess(); +} + +void CLlconClientDlg::OnPingTimeResult ( int iPingTime ) +{ + // calculate overall delay + const int iOverallDelayMs = pClient->EstimatedOverallDelay ( iPingTime ); + + // color definition: <= 40 ms green, <= 65 ms yellow, otherwise red + int iOverallDelayLEDColor; + if ( iOverallDelayMs <= 40 ) + { + iOverallDelayLEDColor = MUL_COL_LED_GREEN; + } + else + { + if ( iOverallDelayMs <= 65 ) + { + iOverallDelayLEDColor = MUL_COL_LED_YELLOW; + } + else + { + iOverallDelayLEDColor = MUL_COL_LED_RED; + } + } + + // set ping time result to general settings dialog + ClientSettingsDlg.SetPingTimeResult ( iPingTime, + iOverallDelayMs, + iOverallDelayLEDColor ); +} + void CLlconClientDlg::ConnectDisconnect ( const bool bDoStart ) { // start/stop client, set button text @@ -675,8 +716,9 @@ void CLlconClientDlg::ConnectDisconnect ( const bool bDoStart ) { PushButtonConnect->setText ( CON_BUT_DISCONNECTTEXT ); - // start timer for level meter bar + // start timer for level meter bar and ping time measurement TimerSigMet.start ( LEVELMETER_UPDATE_TIME ); + TimerPing.start ( PING_UPDATE_TIME ); } } else @@ -707,6 +749,9 @@ void CLlconClientDlg::ConnectDisconnect ( const bool bDoStart ) MultiColorLEDBarInputLevelL->setValue ( 0 ); MultiColorLEDBarInputLevelR->setValue ( 0 ); + // stop ping time measurement timer + TimerPing.stop(); + // immediately update status bar OnTimerStatus(); diff --git a/src/llconclientdlg.h b/src/llconclientdlg.h index 592e05ab..839b973f 100755 --- a/src/llconclientdlg.h +++ b/src/llconclientdlg.h @@ -56,12 +56,12 @@ #define CON_BUT_DISCONNECTTEXT "D&isconnect" // update time for GUI controls -#define LEVELMETER_UPDATE_TIME 100 // ms +#define LEVELMETER_UPDATE_TIME 100 // ms #define STATUSBAR_UPDATE_TIME 1000 // ms // range for signal level meter #define LOW_BOUND_SIG_METER ( -50.0 ) // dB -#define UPPER_BOUND_SIG_METER ( 0.0 ) // dB +#define UPPER_BOUND_SIG_METER ( 0.0 ) // dB /* Classes ********************************************************************/ @@ -87,6 +87,7 @@ protected: bool bUnreadChatMessage; QTimer TimerSigMet; QTimer TimerStatus; + QTimer TimerPing; virtual void customEvent ( QEvent* Event ); virtual void closeEvent ( QCloseEvent* Event ); @@ -102,6 +103,8 @@ public slots: void OnConnectDisconBut(); void OnTimerSigMet(); void OnTimerStatus() { UpdateDisplay(); } + void OnTimerPing(); + void OnPingTimeResult ( int iPingTime ); void OnOpenGeneralSettings(); void OnOpenChatDialog() { ShowChatWindow(); } void OnSliderAudInFader ( int value );