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,6 +31,7 @@
/* Implementation *************************************************************/
CMultiColorLED::CMultiColorLED ( QWidget* parent, Qt::WindowFlags f )
: QLabel ( parent, f ),
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" ) ),
@ -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,7 +143,22 @@ 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 )
{
if ( this->isEnabled() )
{
switch ( iNewStatus )
{
@ -159,6 +183,7 @@ void CMultiColorLED::SetLight ( const int iNewStatus )
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_