diff --git a/src/clientdlg.cpp b/src/clientdlg.cpp index c3a428e3..4ca2eda0 100755 --- a/src/clientdlg.cpp +++ b/src/clientdlg.cpp @@ -908,21 +908,21 @@ void CClientDlg::OnTimerSigMet() void CClientDlg::OnTimerBuffersLED() { - int iCurStatus; + CMultiColorLED::ELightColor eCurStatus; // get and reset current buffer state and set LED from that flag if ( pClient->GetAndResetbJitterBufferOKFlag() ) { - iCurStatus = MUL_COL_LED_GREEN; + eCurStatus = CMultiColorLED::RL_GREEN; } else { - iCurStatus = MUL_COL_LED_RED; + eCurStatus = CMultiColorLED::RL_RED; } // update the buffer LED and the general settings dialog, too - ledBuffers->SetLight ( iCurStatus ); - ClientSettingsDlg.SetStatus ( iCurStatus ); + ledBuffers->SetLight ( eCurStatus ); + ClientSettingsDlg.SetStatus ( eCurStatus ); } void CClientDlg::OnTimerPing() @@ -937,20 +937,21 @@ void CClientDlg::OnPingTimeResult ( int iPingTime ) const int iOverallDelayMs = pClient->EstimatedOverallDelay ( iPingTime ); // color definition: <= 40 ms green, <= 65 ms yellow, otherwise red - int iOverallDelayLEDColor; + CMultiColorLED::ELightColor eOverallDelayLEDColor; + if ( iOverallDelayMs <= 40 ) { - iOverallDelayLEDColor = MUL_COL_LED_GREEN; + eOverallDelayLEDColor = CMultiColorLED::RL_GREEN; } else { if ( iOverallDelayMs <= 65 ) { - iOverallDelayLEDColor = MUL_COL_LED_YELLOW; + eOverallDelayLEDColor = CMultiColorLED::RL_YELLOW; } else { - iOverallDelayLEDColor = MUL_COL_LED_RED; + eOverallDelayLEDColor = CMultiColorLED::RL_RED; } } @@ -961,11 +962,11 @@ void CClientDlg::OnPingTimeResult ( int iPingTime ) // set ping time result to general settings dialog ClientSettingsDlg.SetPingTimeResult ( iPingTime, iOverallDelayMs, - iOverallDelayLEDColor ); + eOverallDelayLEDColor ); } // update delay LED on the main window - ledDelay->SetLight ( iOverallDelayLEDColor ); + ledDelay->SetLight ( eOverallDelayLEDColor ); } void CClientDlg::OnCLPingTimeWithNumClientsReceived ( CHostAddress InetAddr, @@ -973,27 +974,28 @@ void CClientDlg::OnCLPingTimeWithNumClientsReceived ( CHostAddress InetAddr, int iNumClients ) { // color definition: <= 25 ms green, <= 50 ms yellow, otherwise red - int iPingTimeLEDColor; + CMultiColorLED::ELightColor ePingTimeLEDColor; + if ( iPingTime <= 25 ) { - iPingTimeLEDColor = MUL_COL_LED_GREEN; + ePingTimeLEDColor = CMultiColorLED::RL_GREEN; } else { if ( iPingTime <= 50 ) { - iPingTimeLEDColor = MUL_COL_LED_YELLOW; + ePingTimeLEDColor = CMultiColorLED::RL_YELLOW; } else { - iPingTimeLEDColor = MUL_COL_LED_RED; + ePingTimeLEDColor = CMultiColorLED::RL_RED; } } // update connection dialog server list ConnectDlg.SetPingTimeAndNumClientsResult ( InetAddr, iPingTime, - iPingTimeLEDColor, + ePingTimeLEDColor, iNumClients ); } @@ -1033,7 +1035,7 @@ void CClientDlg::Connect ( const QString& strSelectedAddress, else { // show the error as red light - ledConnection->SetLight ( MUL_COL_LED_RED ); + ledConnection->SetLight ( CMultiColorLED::RL_RED ); } } @@ -1090,7 +1092,7 @@ void CClientDlg::UpdateDisplay() // chat LED if ( bUnreadChatMessage ) { - ledChat->SetLight ( MUL_COL_LED_GREEN ); + ledChat->SetLight ( CMultiColorLED::RL_GREEN ); } else { @@ -1098,12 +1100,12 @@ void CClientDlg::UpdateDisplay() } // connection LED - ledConnection->SetLight ( MUL_COL_LED_GREEN ); + ledConnection->SetLight ( CMultiColorLED::RL_GREEN ); } else { // connection LED - ledConnection->SetLight ( MUL_COL_LED_RED ); + ledConnection->SetLight ( CMultiColorLED::RL_RED ); } } diff --git a/src/clientsettingsdlg.cpp b/src/clientsettingsdlg.cpp index 9f82adce..82a880fe 100755 --- a/src/clientsettingsdlg.cpp +++ b/src/clientsettingsdlg.cpp @@ -705,9 +705,9 @@ void CClientSettingsDlg::OnSndCrdBufferDelayButtonGroupClicked ( QAbstractButton UpdateDisplay(); } -void CClientSettingsDlg::SetPingTimeResult ( const int iPingTime, - const int iOverallDelayMs, - const int iOverallDelayLEDColor ) +void CClientSettingsDlg::SetPingTimeResult ( const int iPingTime, + const int iOverallDelayMs, + const CMultiColorLED::ELightColor eOverallDelayLEDColor ) { // apply values to GUI labels, take special care if ping time exceeds // a certain value @@ -727,7 +727,7 @@ void CClientSettingsDlg::SetPingTimeResult ( const int iPingTime, } // set current LED status - ledOverallDelay->SetLight ( iOverallDelayLEDColor ); + ledOverallDelay->SetLight ( eOverallDelayLEDColor ); } void CClientSettingsDlg::UpdateDisplay() diff --git a/src/clientsettingsdlg.h b/src/clientsettingsdlg.h index f7807857..f42bb9f4 100755 --- a/src/clientsettingsdlg.h +++ b/src/clientsettingsdlg.h @@ -55,12 +55,12 @@ public: QWidget* parent = 0, Qt::WindowFlags f = 0 ); - void SetStatus ( const int iStatus ) { ledNetw->SetLight ( iStatus ); } + void SetStatus ( const CMultiColorLED::ELightColor eStatus ) { ledNetw->SetLight ( eStatus ); } void ResetStatus() { ledNetw->Reset(); } - void SetPingTimeResult ( const int iPingTime, - const int iOverallDelayMs, - const int iOverallDelayLEDColor ); + void SetPingTimeResult ( const int iPingTime, + const int iOverallDelayMs, + const CMultiColorLED::ELightColor eOverallDelayLEDColor ); void UpdateDisplay(); diff --git a/src/connectdlg.cpp b/src/connectdlg.cpp index 4e4356ce..6af57b7f 100755 --- a/src/connectdlg.cpp +++ b/src/connectdlg.cpp @@ -378,10 +378,10 @@ void CConnectDlg::OnTimerPing() } } -void CConnectDlg::SetPingTimeAndNumClientsResult ( CHostAddress& InetAddr, - const int iPingTime, - const int iPingTimeLEDColor, - const int iNumClients ) +void CConnectDlg::SetPingTimeAndNumClientsResult ( CHostAddress& InetAddr, + const int iPingTime, + const CMultiColorLED::ELightColor ePingTimeLEDColor, + const int iNumClients ) { // apply the received ping time to the correct server list entry const int iServerListLen = lvwServers->topLevelItemCount(); @@ -395,19 +395,19 @@ void CConnectDlg::SetPingTimeAndNumClientsResult ( CHostAddress& InetAddr, compare ( InetAddr.toString() ) ) { // update the color of the ping time font - switch ( iPingTimeLEDColor ) + switch ( ePingTimeLEDColor ) { - case MUL_COL_LED_GREEN: + case CMultiColorLED::RL_GREEN: lvwServers-> topLevelItem ( iIdx )->setTextColor ( 1, Qt::darkGreen ); break; - case MUL_COL_LED_YELLOW: + case CMultiColorLED::RL_YELLOW: lvwServers-> topLevelItem ( iIdx )->setTextColor ( 1, Qt::darkYellow ); break; - case MUL_COL_LED_RED: + case CMultiColorLED::RL_RED: lvwServers-> topLevelItem ( iIdx )->setTextColor ( 1, Qt::red ); break; diff --git a/src/connectdlg.h b/src/connectdlg.h index e7f0ac12..4b59866c 100755 --- a/src/connectdlg.h +++ b/src/connectdlg.h @@ -31,6 +31,7 @@ #include #include "global.h" #include "client.h" +#include "multicolorled.h" #include "ui_connectdlgbase.h" @@ -56,10 +57,10 @@ public: void SetServerList ( const CHostAddress& InetAddr, const CVector& vecServerInfo ); - void SetPingTimeAndNumClientsResult ( CHostAddress& InetAddr, - const int iPingTime, - const int iPingTimeLEDColor, - const int iNumClients ); + void SetPingTimeAndNumClientsResult ( CHostAddress& InetAddr, + const int iPingTime, + const CMultiColorLED::ELightColor ePingTimeLEDColor, + const int iNumClients ); bool GetServerListItemWasChosen() const { return bServerListItemWasChosen; } QString GetSelectedAddress() const { return strSelectedAddress; } diff --git a/src/global.h b/src/global.h index ca506b17..240d3ab5 100755 --- a/src/global.h +++ b/src/global.h @@ -261,10 +261,6 @@ typedef unsigned char uint8_t; /* Pseudo enum definitions -------------------------------------------------- */ -#define MUL_COL_LED_RED 0 -#define MUL_COL_LED_YELLOW 1 -#define MUL_COL_LED_GREEN 2 - // definition for custom event #define MS_PACKET_RECEIVED 0 diff --git a/src/multicolorled.cpp b/src/multicolorled.cpp index b2ce1534..38fa4e32 100755 --- a/src/multicolorled.cpp +++ b/src/multicolorled.cpp @@ -50,7 +50,7 @@ void CMultiColorLED::changeEvent ( QEvent* curEvent ) // act on enabled changed state if ( curEvent->type() == QEvent::EnabledChange ) { - if ( this->isEnabled() ) + if ( isEnabled() ) { setPixmap ( BitmCubeGrey ); eColorFlag = RL_GREY; @@ -107,29 +107,16 @@ void CMultiColorLED::SetColor ( const ELightColor eNewColorFlag ) void CMultiColorLED::Reset() { - if ( this->isEnabled() ) + if ( isEnabled() ) { SetColor ( RL_GREY ); } } -void CMultiColorLED::SetLight ( const int iNewStatus ) +void CMultiColorLED::SetLight ( const ELightColor eNewStatus ) { - if ( this->isEnabled() ) + if ( isEnabled() ) { - switch ( iNewStatus ) - { - case MUL_COL_LED_GREEN: - SetColor ( RL_GREEN ); - break; - - case MUL_COL_LED_YELLOW: - SetColor ( RL_YELLOW ); - break; - - case MUL_COL_LED_RED: - SetColor ( RL_RED ); - break; - } + SetColor ( eNewStatus ); } } diff --git a/src/multicolorled.h b/src/multicolorled.h index 206c2acf..43763285 100755 --- a/src/multicolorled.h +++ b/src/multicolorled.h @@ -42,12 +42,6 @@ class CMultiColorLED : public QLabel { public: - CMultiColorLED ( QWidget* parent = 0, Qt::WindowFlags f = 0 ); - - void Reset(); - void SetLight ( const int iNewStatus ); - -protected: enum ELightColor { RL_DISABLED, @@ -56,6 +50,13 @@ protected: RL_YELLOW, RL_RED }; + + CMultiColorLED ( QWidget* parent = 0, Qt::WindowFlags f = 0 ); + + void Reset(); + void SetLight ( const ELightColor eNewStatus ); + +protected: ELightColor eColorFlag; virtual void changeEvent ( QEvent* curEvent );