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,7 +67,36 @@ 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 )
|
||||
{
|
||||
if ( this->isEnabled() )
|
||||
{
|
||||
// update state of all LEDs for current level value
|
||||
for ( int iLEDIdx = 0; iLEDIdx < iNumLEDs; iLEDIdx++ )
|
||||
|
@ -102,8 +131,10 @@ void CMultiColorLEDBar::setValue ( const int value )
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
CMultiColorLEDBar::cLED::cLED ( QWidget* parent ) :
|
||||
BitmCubeRoundDisabled ( QString::fromUtf8 ( ":/png/LEDs/res/VLEDDisabledSmall.png" ) ),
|
||||
BitmCubeRoundGrey ( QString::fromUtf8 ( ":/png/LEDs/res/VLEDGreySmall.png" ) ),
|
||||
BitmCubeRoundGreen ( QString::fromUtf8 ( ":/png/LEDs/res/VLEDGreenSmall.png" ) ),
|
||||
BitmCubeRoundYellow ( QString::fromUtf8 ( ":/png/LEDs/res/VLEDYellowSmall.png" ) ),
|
||||
|
@ -128,6 +159,10 @@ void CMultiColorLEDBar::cLED::setColor ( const ELightColor eNewColor )
|
|||
{
|
||||
switch ( eNewColor )
|
||||
{
|
||||
case RL_DISABLED:
|
||||
pLEDLabel->setPixmap ( BitmCubeRoundDisabled );
|
||||
break;
|
||||
|
||||
case RL_GREY:
|
||||
pLEDLabel->setPixmap ( BitmCubeRoundGrey );
|
||||
break;
|
||||
|
|
|
@ -48,13 +48,21 @@ protected:
|
|||
class cLED
|
||||
{
|
||||
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 );
|
||||
void setColor ( const ELightColor eNewColor );
|
||||
QLabel* getLabelPointer() { return pLEDLabel; }
|
||||
|
||||
protected:
|
||||
QPixmap BitmCubeRoundDisabled;
|
||||
QPixmap BitmCubeRoundGrey;
|
||||
QPixmap BitmCubeRoundGreen;
|
||||
QPixmap BitmCubeRoundYellow;
|
||||
|
@ -64,6 +72,9 @@ protected:
|
|||
QLabel* pLEDLabel;
|
||||
};
|
||||
|
||||
void Reset ( const bool bEnabled );
|
||||
virtual void changeEvent ( QEvent* curEvent );
|
||||
|
||||
QHBoxLayout* pMainLayout;
|
||||
|
||||
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