added disabled state for LED bar
This commit is contained in:
parent
04da12c959
commit
bcf39db392
4 changed files with 76 additions and 30 deletions
|
@ -67,8 +67,37 @@ CMultiColorLEDBar::~CMultiColorLEDBar()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CMultiColorLEDBar::changeEvent ( QEvent* curEvent )
|
||||||
|
{
|
||||||
|
// act on enabled changed state
|
||||||
|
if ( (*curEvent).type() == QEvent::EnabledChange )
|
||||||
|
{
|
||||||
|
// reset all LEDs
|
||||||
|
Reset ( this->isEnabled() );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void CMultiColorLEDBar::Reset ( const bool bEnabled )
|
||||||
|
{
|
||||||
|
// update state of all LEDs
|
||||||
|
for ( int iLEDIdx = 0; iLEDIdx < iNumLEDs; iLEDIdx++ )
|
||||||
|
{
|
||||||
|
// different reset behavoiur for enabled and disabled control
|
||||||
|
if ( bEnabled )
|
||||||
|
{
|
||||||
|
vecpLEDs[iLEDIdx]->setColor ( cLED::RL_GREY );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
vecpLEDs[iLEDIdx]->setColor ( cLED::RL_DISABLED );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void CMultiColorLEDBar::setValue ( const int value )
|
void CMultiColorLEDBar::setValue ( const int value )
|
||||||
{
|
{
|
||||||
|
if ( this->isEnabled() )
|
||||||
|
{
|
||||||
// update state of all LEDs for current level value
|
// update state of all LEDs for current level value
|
||||||
for ( int iLEDIdx = 0; iLEDIdx < iNumLEDs; iLEDIdx++ )
|
for ( int iLEDIdx = 0; iLEDIdx < iNumLEDs; iLEDIdx++ )
|
||||||
{
|
{
|
||||||
|
@ -101,9 +130,11 @@ void CMultiColorLEDBar::setValue ( const int value )
|
||||||
vecpLEDs[iLEDIdx]->setColor ( cLED::RL_GREY );
|
vecpLEDs[iLEDIdx]->setColor ( cLED::RL_GREY );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
CMultiColorLEDBar::cLED::cLED ( QWidget* parent ) :
|
CMultiColorLEDBar::cLED::cLED ( QWidget* parent ) :
|
||||||
|
BitmCubeRoundDisabled ( QString::fromUtf8 ( ":/png/LEDs/res/VLEDDisabledSmall.png" ) ),
|
||||||
BitmCubeRoundGrey ( QString::fromUtf8 ( ":/png/LEDs/res/VLEDGreySmall.png" ) ),
|
BitmCubeRoundGrey ( QString::fromUtf8 ( ":/png/LEDs/res/VLEDGreySmall.png" ) ),
|
||||||
BitmCubeRoundGreen ( QString::fromUtf8 ( ":/png/LEDs/res/VLEDGreenSmall.png" ) ),
|
BitmCubeRoundGreen ( QString::fromUtf8 ( ":/png/LEDs/res/VLEDGreenSmall.png" ) ),
|
||||||
BitmCubeRoundYellow ( QString::fromUtf8 ( ":/png/LEDs/res/VLEDYellowSmall.png" ) ),
|
BitmCubeRoundYellow ( QString::fromUtf8 ( ":/png/LEDs/res/VLEDYellowSmall.png" ) ),
|
||||||
|
@ -128,6 +159,10 @@ void CMultiColorLEDBar::cLED::setColor ( const ELightColor eNewColor )
|
||||||
{
|
{
|
||||||
switch ( eNewColor )
|
switch ( eNewColor )
|
||||||
{
|
{
|
||||||
|
case RL_DISABLED:
|
||||||
|
pLEDLabel->setPixmap ( BitmCubeRoundDisabled );
|
||||||
|
break;
|
||||||
|
|
||||||
case RL_GREY:
|
case RL_GREY:
|
||||||
pLEDLabel->setPixmap ( BitmCubeRoundGrey );
|
pLEDLabel->setPixmap ( BitmCubeRoundGrey );
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -48,13 +48,21 @@ protected:
|
||||||
class cLED
|
class cLED
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
enum ELightColor { RL_GREY, RL_GREEN, RL_YELLOW, RL_RED };
|
enum ELightColor
|
||||||
|
{
|
||||||
|
RL_DISABLED,
|
||||||
|
RL_GREY,
|
||||||
|
RL_GREEN,
|
||||||
|
RL_YELLOW,
|
||||||
|
RL_RED
|
||||||
|
};
|
||||||
|
|
||||||
cLED ( QWidget* parent );
|
cLED ( QWidget* parent );
|
||||||
void setColor ( const ELightColor eNewColor );
|
void setColor ( const ELightColor eNewColor );
|
||||||
QLabel* getLabelPointer() { return pLEDLabel; }
|
QLabel* getLabelPointer() { return pLEDLabel; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
QPixmap BitmCubeRoundDisabled;
|
||||||
QPixmap BitmCubeRoundGrey;
|
QPixmap BitmCubeRoundGrey;
|
||||||
QPixmap BitmCubeRoundGreen;
|
QPixmap BitmCubeRoundGreen;
|
||||||
QPixmap BitmCubeRoundYellow;
|
QPixmap BitmCubeRoundYellow;
|
||||||
|
@ -64,6 +72,9 @@ protected:
|
||||||
QLabel* pLEDLabel;
|
QLabel* pLEDLabel;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
void Reset ( const bool bEnabled );
|
||||||
|
virtual void changeEvent ( QEvent* curEvent );
|
||||||
|
|
||||||
QHBoxLayout* pMainLayout;
|
QHBoxLayout* pMainLayout;
|
||||||
|
|
||||||
int iNumLEDs;
|
int iNumLEDs;
|
||||||
|
|
BIN
src/res/CLEDDisabledSmall.png
Executable file
BIN
src/res/CLEDDisabledSmall.png
Executable file
Binary file not shown.
After Width: | Height: | Size: 1.1 KiB |
BIN
src/res/VLEDDisabledSmall.png
Executable file
BIN
src/res/VLEDDisabledSmall.png
Executable file
Binary file not shown.
After Width: | Height: | Size: 798 B |
Loading…
Reference in a new issue