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()
{
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 );
}
}

View File

@ -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()

View File

@ -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();

View File

@ -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;

View File

@ -31,6 +31,7 @@
#include <QLocale>
#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<CServerInfo>& 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; }

View File

@ -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

View File

@ -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 );
}
}

View File

@ -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 );