replaced global "MUL_COL_LED_*" definitions by actual enum definitions in the multicolor LED class

This commit is contained in:
Volker Fischer 2014-01-05 18:26:38 +00:00
parent c0a67a9884
commit 4baf2c5ef5
8 changed files with 55 additions and 68 deletions

View File

@ -908,21 +908,21 @@ void CClientDlg::OnTimerSigMet()
void CClientDlg::OnTimerBuffersLED() void CClientDlg::OnTimerBuffersLED()
{ {
int iCurStatus; CMultiColorLED::ELightColor eCurStatus;
// get and reset current buffer state and set LED from that flag // get and reset current buffer state and set LED from that flag
if ( pClient->GetAndResetbJitterBufferOKFlag() ) if ( pClient->GetAndResetbJitterBufferOKFlag() )
{ {
iCurStatus = MUL_COL_LED_GREEN; eCurStatus = CMultiColorLED::RL_GREEN;
} }
else else
{ {
iCurStatus = MUL_COL_LED_RED; eCurStatus = CMultiColorLED::RL_RED;
} }
// update the buffer LED and the general settings dialog, too // update the buffer LED and the general settings dialog, too
ledBuffers->SetLight ( iCurStatus ); ledBuffers->SetLight ( eCurStatus );
ClientSettingsDlg.SetStatus ( iCurStatus ); ClientSettingsDlg.SetStatus ( eCurStatus );
} }
void CClientDlg::OnTimerPing() void CClientDlg::OnTimerPing()
@ -937,20 +937,21 @@ void CClientDlg::OnPingTimeResult ( int iPingTime )
const int iOverallDelayMs = pClient->EstimatedOverallDelay ( iPingTime ); const int iOverallDelayMs = pClient->EstimatedOverallDelay ( iPingTime );
// color definition: <= 40 ms green, <= 65 ms yellow, otherwise red // color definition: <= 40 ms green, <= 65 ms yellow, otherwise red
int iOverallDelayLEDColor; CMultiColorLED::ELightColor eOverallDelayLEDColor;
if ( iOverallDelayMs <= 40 ) if ( iOverallDelayMs <= 40 )
{ {
iOverallDelayLEDColor = MUL_COL_LED_GREEN; eOverallDelayLEDColor = CMultiColorLED::RL_GREEN;
} }
else else
{ {
if ( iOverallDelayMs <= 65 ) if ( iOverallDelayMs <= 65 )
{ {
iOverallDelayLEDColor = MUL_COL_LED_YELLOW; eOverallDelayLEDColor = CMultiColorLED::RL_YELLOW;
} }
else 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 // set ping time result to general settings dialog
ClientSettingsDlg.SetPingTimeResult ( iPingTime, ClientSettingsDlg.SetPingTimeResult ( iPingTime,
iOverallDelayMs, iOverallDelayMs,
iOverallDelayLEDColor ); eOverallDelayLEDColor );
} }
// update delay LED on the main window // update delay LED on the main window
ledDelay->SetLight ( iOverallDelayLEDColor ); ledDelay->SetLight ( eOverallDelayLEDColor );
} }
void CClientDlg::OnCLPingTimeWithNumClientsReceived ( CHostAddress InetAddr, void CClientDlg::OnCLPingTimeWithNumClientsReceived ( CHostAddress InetAddr,
@ -973,27 +974,28 @@ void CClientDlg::OnCLPingTimeWithNumClientsReceived ( CHostAddress InetAddr,
int iNumClients ) int iNumClients )
{ {
// color definition: <= 25 ms green, <= 50 ms yellow, otherwise red // color definition: <= 25 ms green, <= 50 ms yellow, otherwise red
int iPingTimeLEDColor; CMultiColorLED::ELightColor ePingTimeLEDColor;
if ( iPingTime <= 25 ) if ( iPingTime <= 25 )
{ {
iPingTimeLEDColor = MUL_COL_LED_GREEN; ePingTimeLEDColor = CMultiColorLED::RL_GREEN;
} }
else else
{ {
if ( iPingTime <= 50 ) if ( iPingTime <= 50 )
{ {
iPingTimeLEDColor = MUL_COL_LED_YELLOW; ePingTimeLEDColor = CMultiColorLED::RL_YELLOW;
} }
else else
{ {
iPingTimeLEDColor = MUL_COL_LED_RED; ePingTimeLEDColor = CMultiColorLED::RL_RED;
} }
} }
// update connection dialog server list // update connection dialog server list
ConnectDlg.SetPingTimeAndNumClientsResult ( InetAddr, ConnectDlg.SetPingTimeAndNumClientsResult ( InetAddr,
iPingTime, iPingTime,
iPingTimeLEDColor, ePingTimeLEDColor,
iNumClients ); iNumClients );
} }
@ -1033,7 +1035,7 @@ void CClientDlg::Connect ( const QString& strSelectedAddress,
else else
{ {
// show the error as red light // 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 // chat LED
if ( bUnreadChatMessage ) if ( bUnreadChatMessage )
{ {
ledChat->SetLight ( MUL_COL_LED_GREEN ); ledChat->SetLight ( CMultiColorLED::RL_GREEN );
} }
else else
{ {
@ -1098,12 +1100,12 @@ void CClientDlg::UpdateDisplay()
} }
// connection LED // connection LED
ledConnection->SetLight ( MUL_COL_LED_GREEN ); ledConnection->SetLight ( CMultiColorLED::RL_GREEN );
} }
else else
{ {
// connection LED // connection LED
ledConnection->SetLight ( MUL_COL_LED_RED ); ledConnection->SetLight ( CMultiColorLED::RL_RED );
} }
} }

View File

@ -705,9 +705,9 @@ void CClientSettingsDlg::OnSndCrdBufferDelayButtonGroupClicked ( QAbstractButton
UpdateDisplay(); UpdateDisplay();
} }
void CClientSettingsDlg::SetPingTimeResult ( const int iPingTime, void CClientSettingsDlg::SetPingTimeResult ( const int iPingTime,
const int iOverallDelayMs, const int iOverallDelayMs,
const int iOverallDelayLEDColor ) const CMultiColorLED::ELightColor eOverallDelayLEDColor )
{ {
// apply values to GUI labels, take special care if ping time exceeds // apply values to GUI labels, take special care if ping time exceeds
// a certain value // a certain value
@ -727,7 +727,7 @@ void CClientSettingsDlg::SetPingTimeResult ( const int iPingTime,
} }
// set current LED status // set current LED status
ledOverallDelay->SetLight ( iOverallDelayLEDColor ); ledOverallDelay->SetLight ( eOverallDelayLEDColor );
} }
void CClientSettingsDlg::UpdateDisplay() void CClientSettingsDlg::UpdateDisplay()

View File

@ -55,12 +55,12 @@ public:
QWidget* parent = 0, QWidget* parent = 0,
Qt::WindowFlags f = 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 ResetStatus() { ledNetw->Reset(); }
void SetPingTimeResult ( const int iPingTime, void SetPingTimeResult ( const int iPingTime,
const int iOverallDelayMs, const int iOverallDelayMs,
const int iOverallDelayLEDColor ); const CMultiColorLED::ELightColor eOverallDelayLEDColor );
void UpdateDisplay(); void UpdateDisplay();

View File

@ -378,10 +378,10 @@ void CConnectDlg::OnTimerPing()
} }
} }
void CConnectDlg::SetPingTimeAndNumClientsResult ( CHostAddress& InetAddr, void CConnectDlg::SetPingTimeAndNumClientsResult ( CHostAddress& InetAddr,
const int iPingTime, const int iPingTime,
const int iPingTimeLEDColor, const CMultiColorLED::ELightColor ePingTimeLEDColor,
const int iNumClients ) const int iNumClients )
{ {
// apply the received ping time to the correct server list entry // apply the received ping time to the correct server list entry
const int iServerListLen = lvwServers->topLevelItemCount(); const int iServerListLen = lvwServers->topLevelItemCount();
@ -395,19 +395,19 @@ void CConnectDlg::SetPingTimeAndNumClientsResult ( CHostAddress& InetAddr,
compare ( InetAddr.toString() ) ) compare ( InetAddr.toString() ) )
{ {
// update the color of the ping time font // update the color of the ping time font
switch ( iPingTimeLEDColor ) switch ( ePingTimeLEDColor )
{ {
case MUL_COL_LED_GREEN: case CMultiColorLED::RL_GREEN:
lvwServers-> lvwServers->
topLevelItem ( iIdx )->setTextColor ( 1, Qt::darkGreen ); topLevelItem ( iIdx )->setTextColor ( 1, Qt::darkGreen );
break; break;
case MUL_COL_LED_YELLOW: case CMultiColorLED::RL_YELLOW:
lvwServers-> lvwServers->
topLevelItem ( iIdx )->setTextColor ( 1, Qt::darkYellow ); topLevelItem ( iIdx )->setTextColor ( 1, Qt::darkYellow );
break; break;
case MUL_COL_LED_RED: case CMultiColorLED::RL_RED:
lvwServers-> lvwServers->
topLevelItem ( iIdx )->setTextColor ( 1, Qt::red ); topLevelItem ( iIdx )->setTextColor ( 1, Qt::red );
break; break;

View File

@ -31,6 +31,7 @@
#include <QLocale> #include <QLocale>
#include "global.h" #include "global.h"
#include "client.h" #include "client.h"
#include "multicolorled.h"
#include "ui_connectdlgbase.h" #include "ui_connectdlgbase.h"
@ -56,10 +57,10 @@ public:
void SetServerList ( const CHostAddress& InetAddr, void SetServerList ( const CHostAddress& InetAddr,
const CVector<CServerInfo>& vecServerInfo ); const CVector<CServerInfo>& vecServerInfo );
void SetPingTimeAndNumClientsResult ( CHostAddress& InetAddr, void SetPingTimeAndNumClientsResult ( CHostAddress& InetAddr,
const int iPingTime, const int iPingTime,
const int iPingTimeLEDColor, const CMultiColorLED::ELightColor ePingTimeLEDColor,
const int iNumClients ); const int iNumClients );
bool GetServerListItemWasChosen() const { return bServerListItemWasChosen; } bool GetServerListItemWasChosen() const { return bServerListItemWasChosen; }
QString GetSelectedAddress() const { return strSelectedAddress; } QString GetSelectedAddress() const { return strSelectedAddress; }

View File

@ -261,10 +261,6 @@ typedef unsigned char uint8_t;
/* Pseudo enum definitions -------------------------------------------------- */ /* 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 // definition for custom event
#define MS_PACKET_RECEIVED 0 #define MS_PACKET_RECEIVED 0

View File

@ -50,7 +50,7 @@ void CMultiColorLED::changeEvent ( QEvent* curEvent )
// act on enabled changed state // act on enabled changed state
if ( curEvent->type() == QEvent::EnabledChange ) if ( curEvent->type() == QEvent::EnabledChange )
{ {
if ( this->isEnabled() ) if ( isEnabled() )
{ {
setPixmap ( BitmCubeGrey ); setPixmap ( BitmCubeGrey );
eColorFlag = RL_GREY; eColorFlag = RL_GREY;
@ -107,29 +107,16 @@ void CMultiColorLED::SetColor ( const ELightColor eNewColorFlag )
void CMultiColorLED::Reset() void CMultiColorLED::Reset()
{ {
if ( this->isEnabled() ) if ( isEnabled() )
{ {
SetColor ( RL_GREY ); SetColor ( RL_GREY );
} }
} }
void CMultiColorLED::SetLight ( const int iNewStatus ) void CMultiColorLED::SetLight ( const ELightColor eNewStatus )
{ {
if ( this->isEnabled() ) if ( isEnabled() )
{ {
switch ( iNewStatus ) SetColor ( eNewStatus );
{
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;
}
} }
} }

View File

@ -42,12 +42,6 @@
class CMultiColorLED : public QLabel class CMultiColorLED : public QLabel
{ {
public: public:
CMultiColorLED ( QWidget* parent = 0, Qt::WindowFlags f = 0 );
void Reset();
void SetLight ( const int iNewStatus );
protected:
enum ELightColor enum ELightColor
{ {
RL_DISABLED, RL_DISABLED,
@ -56,6 +50,13 @@ protected:
RL_YELLOW, RL_YELLOW,
RL_RED RL_RED
}; };
CMultiColorLED ( QWidget* parent = 0, Qt::WindowFlags f = 0 );
void Reset();
void SetLight ( const ELightColor eNewStatus );
protected:
ELightColor eColorFlag; ELightColor eColorFlag;
virtual void changeEvent ( QEvent* curEvent ); virtual void changeEvent ( QEvent* curEvent );