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