added command line argument and function to disable all LEDs on main window to save CPU on slow computers

This commit is contained in:
Volker Fischer 2009-06-13 08:14:11 +00:00
parent b21af7809b
commit 355aca41be
5 changed files with 88 additions and 37 deletions

View file

@ -28,6 +28,7 @@
/* Implementation *************************************************************/
CLlconClientDlg::CLlconClientDlg ( CClient* pNCliP,
const bool bNewConnectOnStartup,
const bool bNewDisalbeLEDs,
QWidget* parent, Qt::WindowFlags f ) :
pClient ( pNCliP ), QDialog ( parent, f ),
ClientSettingsDlg ( pNCliP, parent
@ -129,11 +130,6 @@ CLlconClientDlg::CLlconClientDlg ( CClient* pNCliP,
MultiColorLEDBarInputLevelR->setValue ( 0 );
// TEST
MultiColorLEDBarInputLevelL->setEnabled ( false );
// init slider controls ---
// audio in fader
SliderAudInFader->setRange ( AUD_FADER_IN_MIN, AUD_FADER_IN_MAX );
@ -169,6 +165,15 @@ MultiColorLEDBarInputLevelL->setEnabled ( false );
}
// disable controls on request ---
// disable LEDs in main window if requested
if ( bNewDisalbeLEDs )
{
MultiColorLEDBarInputLevelL->setEnabled ( false );
LEDOverallStatus->setEnabled ( false );
}
// Settings menu ----------------------------------------------------------
pSettingsMenu = new QMenu ( "&View", this );
pSettingsMenu->addAction ( tr ( "&Chat..." ), this,

View file

@ -67,6 +67,7 @@ class CLlconClientDlg : public QDialog, private Ui_CLlconClientDlgBase
public:
CLlconClientDlg ( CClient* pNCliP, const bool bNewConnectOnStartup,
const bool bNewDisalbeLEDs,
QWidget* parent = 0, Qt::WindowFlags f = 0 );
virtual ~CLlconClientDlg();

View file

@ -47,6 +47,7 @@ int main ( int argc, char** argv )
bool bIsClient = true;
bool bUseGUI = true;
bool bConnectOnStartup = false;
bool bDisalbeLEDs = false;
int iUploadRateLimitKbps = DEF_MAX_UPLOAD_RATE_KBPS;
quint16 iPortNumber = LLCON_DEFAULT_PORT_NUMBER;
std::string strIniFileName = "";
@ -78,6 +79,15 @@ int main ( int argc, char** argv )
}
// disable LEDs flag ---------------------------------------------------
if ( GetFlagArgument ( argc, argv, i, "-d", "--disableleds" ) )
{
bDisalbeLEDs = true;
cout << "disable LEDs in main window" << std::endl;
continue;
}
// use logging ---------------------------------------------------------
if ( GetStringArgument ( argc, argv, i, "-l", "--log", strArgument ) )
{
@ -203,7 +213,7 @@ int main ( int argc, char** argv )
// GUI object
CLlconClientDlg ClientDlg (
&Client, bConnectOnStartup,
&Client, bConnectOnStartup, bDisalbeLEDs,
0
#ifdef _WIN32
// this somehow only works reliable on Windows
@ -303,6 +313,8 @@ std::string UsageArguments ( char **argv )
" -u, --maxuploadrate maximum upload rate (only avaiable for server)\n"
" -c, --connect connect to last server on startup (only\n"
" available for client)\n"
" -d, --disableleds disable LEDs in main window (only available\n"
" for client)\n"
" -h, -?, --help this help text\n"
"Example: " + std::string ( argv[0] ) + " -l -inifile myinifile.ini\n";
}

View file

@ -31,10 +31,11 @@
/* Implementation *************************************************************/
CMultiColorLED::CMultiColorLED ( QWidget* parent, Qt::WindowFlags f )
: QLabel ( parent, f ),
BitmCubeGrey ( QString::fromUtf8 ( ":/png/LEDs/res/CLEDGreySmall.png" ) ),
BitmCubeGreen ( QString::fromUtf8 ( ":/png/LEDs/res/CLEDGreenSmall.png" ) ),
BitmCubeYellow ( QString::fromUtf8 ( ":/png/LEDs/res/CLEDYellowSmall.png" ) ),
BitmCubeRed ( QString::fromUtf8 ( ":/png/LEDs/res/CLEDRedSmall.png" ) )
BitmCubeDisabled ( QString::fromUtf8 ( ":/png/LEDs/res/CLEDDisabledSmall.png" ) ),
BitmCubeGrey ( QString::fromUtf8 ( ":/png/LEDs/res/CLEDGreySmall.png" ) ),
BitmCubeGreen ( QString::fromUtf8 ( ":/png/LEDs/res/CLEDGreenSmall.png" ) ),
BitmCubeYellow ( QString::fromUtf8 ( ":/png/LEDs/res/CLEDYellowSmall.png" ) ),
BitmCubeRed ( QString::fromUtf8 ( ":/png/LEDs/res/CLEDRedSmall.png" ) )
{
// init color flags
Reset();
@ -63,14 +64,22 @@ CMultiColorLED::CMultiColorLED ( QWidget* parent, Qt::WindowFlags f )
this, SLOT ( OnNewPixmap ( const QPixmap& ) ) );
}
void CMultiColorLED::Reset()
void CMultiColorLED::changeEvent ( QEvent* curEvent )
{
// reset color flags
bFlagRedLi = false;
bFlagGreenLi = false;
bFlagYellowLi = false;
UpdateColor();
// act on enabled changed state
if ( curEvent->type() == QEvent::EnabledChange )
{
if ( this->isEnabled() )
{
emit newPixmap ( BitmCubeGrey );
eColorFlag = RL_GREY;
}
else
{
emit newPixmap ( BitmCubeDisabled );
eColorFlag = RL_DISABLED;
}
}
}
void CMultiColorLED::OnTimerRedLight()
@ -134,30 +143,46 @@ void CMultiColorLED::UpdateColor()
}
}
void CMultiColorLED::Reset()
{
if ( this->isEnabled() )
{
// reset color flags
bFlagRedLi = false;
bFlagGreenLi = false;
bFlagYellowLi = false;
UpdateColor();
}
}
void CMultiColorLED::SetLight ( const int iNewStatus )
{
switch ( iNewStatus )
if ( this->isEnabled() )
{
case MUL_COL_LED_GREEN:
// green light
bFlagGreenLi = true;
TimerGreenLight.start();
break;
switch ( iNewStatus )
{
case MUL_COL_LED_GREEN:
// green light
bFlagGreenLi = true;
TimerGreenLight.start();
break;
case MUL_COL_LED_YELLOW:
// yellow light
bFlagYellowLi = true;
TimerYellowLight.start();
break;
case MUL_COL_LED_YELLOW:
// yellow light
bFlagYellowLi = true;
TimerYellowLight.start();
break;
case MUL_COL_LED_RED:
// red light
bFlagRedLi = true;
TimerRedLight.start();
break;
case MUL_COL_LED_RED:
// red light
bFlagRedLi = true;
TimerRedLight.start();
break;
}
UpdateColor();
}
UpdateColor();
}
void CMultiColorLED::SetUpdateTime ( const int iNUTi )

View file

@ -60,11 +60,20 @@ public:
void SetLight ( const int iNewStatus );
protected:
enum ELightColor { RL_GREY, RL_GREEN, RL_YELLOW, RL_RED };
enum ELightColor
{
RL_DISABLED,
RL_GREY,
RL_GREEN,
RL_YELLOW,
RL_RED
};
ELightColor eColorFlag;
virtual void changeEvent ( QEvent* curEvent );
void UpdateColor();
QPixmap BitmCubeDisabled;
QPixmap BitmCubeGrey;
QPixmap BitmCubeGreen;
QPixmap BitmCubeYellow;
@ -142,5 +151,4 @@ protected:
CMultColLEDListViewItem LED0, LED1;
};
#endif // _MULTCOLORLED_H__FD6B49B5_87DF_48DD_A873_804E1606C2AC__INCLUDED_