bug fixes and some minor changes
This commit is contained in:
parent
c9bb67ae14
commit
59b1a0de1e
3 changed files with 38 additions and 32 deletions
|
@ -5,8 +5,8 @@
|
|||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>488</width>
|
||||
<height>336</height>
|
||||
<width>520</width>
|
||||
<height>355</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle" >
|
||||
|
@ -106,7 +106,7 @@
|
|||
<item>
|
||||
<layout class="QVBoxLayout" >
|
||||
<property name="spacing" >
|
||||
<number>0</number>
|
||||
<number>6</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="CMultiColorLEDBar" native="1" name="MultiColorLEDBarInputLevelL" >
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
|
||||
/* Implementation *************************************************************/
|
||||
CMultiColorLEDBar::CMultiColorLEDBar ( QWidget* parent, Qt::WindowFlags f )
|
||||
: QLabel ( parent, f ),
|
||||
: QFrame ( parent, f ),
|
||||
BitmCubeRoundGrey ( QString::fromUtf8 ( ":/png/LEDs/res/VLEDGreySmall.png" ) ),
|
||||
BitmCubeRoundGreen ( QString::fromUtf8 ( ":/png/LEDs/res/VLEDGreenSmall.png" ) ),
|
||||
BitmCubeRoundYellow ( QString::fromUtf8 ( ":/png/LEDs/res/VLEDYellowSmall.png" ) ),
|
||||
|
@ -41,6 +41,7 @@ CMultiColorLEDBar::CMultiColorLEDBar ( QWidget* parent, Qt::WindowFlags f )
|
|||
|
||||
// create layout and set spacing to zero
|
||||
pMainLayout = new QHBoxLayout ( this );
|
||||
pMainLayout->setAlignment ( Qt::AlignVCenter );
|
||||
pMainLayout->setSpacing ( 0 );
|
||||
|
||||
// create LEDs
|
||||
|
@ -68,38 +69,41 @@ void CMultiColorLEDBar::setValue ( const int value )
|
|||
// TODO speed optimiation: only change bitmaps of LEDs which
|
||||
// actually have to be changed
|
||||
|
||||
// use green LEDs for the range from 0 to the YELLOW_BOUND_INP_LEV_METER,
|
||||
// yellow in the range YELLOW_BOUND_INP_LEV_METER to
|
||||
// RED_BOUND_INP_LEV_METER and red for up to value and grey for the rest
|
||||
// update state of all LEDs for current level value
|
||||
for ( int i = 0; i < iNumLEDs; i++ )
|
||||
{
|
||||
if ( i < value )
|
||||
// set active if value is above current LED index
|
||||
SetLED ( i, i < value );
|
||||
}
|
||||
}
|
||||
|
||||
void CMultiColorLEDBar::SetLED ( const int iLEDIdx, const bool bActive )
|
||||
{
|
||||
// we are below current input level, check which color
|
||||
// we should use (green, yellow or red)
|
||||
if ( i < YELLOW_BOUND_INP_LEV_METER )
|
||||
if ( bActive )
|
||||
{
|
||||
// check which color we should use (green, yellow or red)
|
||||
if ( iLEDIdx < YELLOW_BOUND_INP_LEV_METER )
|
||||
{
|
||||
// green region
|
||||
vecpLEDs[i]->setPixmap ( BitmCubeRoundGreen );
|
||||
vecpLEDs[iLEDIdx]->setPixmap ( BitmCubeRoundGreen );
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( i < RED_BOUND_INP_LEV_METER )
|
||||
if ( iLEDIdx < RED_BOUND_INP_LEV_METER )
|
||||
{
|
||||
// yellow region
|
||||
vecpLEDs[i]->setPixmap ( BitmCubeRoundYellow );
|
||||
vecpLEDs[iLEDIdx]->setPixmap ( BitmCubeRoundYellow );
|
||||
}
|
||||
else
|
||||
{
|
||||
// red region
|
||||
vecpLEDs[i]->setPixmap ( BitmCubeRoundRed );
|
||||
vecpLEDs[iLEDIdx]->setPixmap ( BitmCubeRoundRed );
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// we are above current input level -> use grey LED
|
||||
vecpLEDs[i]->setPixmap ( BitmCubeRoundGrey );
|
||||
}
|
||||
// we use grey LED for inactive state
|
||||
vecpLEDs[iLEDIdx]->setPixmap ( BitmCubeRoundGrey );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
#if !defined ( _MULTCOLORLEDBAR_H__FD6B49B5_87DF_48DD_E1606C2AC__INCLUDED_ )
|
||||
#define _MULTCOLORLEDBAR_H__FD6B49B5_87DF_48DD_E1606C2AC__INCLUDED_
|
||||
|
||||
#include <qlabel.h>
|
||||
#include <qframe.h>
|
||||
#include <qpixmap.h>
|
||||
#include <qtimer.h>
|
||||
#include <qlayout.h>
|
||||
|
@ -34,7 +34,7 @@
|
|||
|
||||
|
||||
/* Classes ********************************************************************/
|
||||
class CMultiColorLEDBar : public QLabel
|
||||
class CMultiColorLEDBar : public QFrame
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
|
@ -44,6 +44,8 @@ public:
|
|||
void setValue ( const int value );
|
||||
|
||||
protected:
|
||||
void SetLED ( const int iLEDIdx, const bool bActive = true );
|
||||
|
||||
QPixmap BitmCubeRoundGrey;
|
||||
QPixmap BitmCubeRoundGreen;
|
||||
QPixmap BitmCubeRoundYellow;
|
||||
|
|
Loading…
Reference in a new issue