From 513ffc6edff67b5f7f121c3064b059ce82cbb842 Mon Sep 17 00:00:00 2001 From: Timothy Pearson Date: Sun, 1 Jul 2012 19:12:13 -0500 Subject: [PATCH] Add ability to set KLed off color --- tdeui/kled.cpp | 29 +++++++++++++++++++++++------ tdeui/kled.h | 29 ++++++++++++++++++++++++++++- 2 files changed, 51 insertions(+), 7 deletions(-) diff --git a/tdeui/kled.cpp b/tdeui/kled.cpp index 3a3aa2a83..dc245cd6f 100644 --- a/tdeui/kled.cpp +++ b/tdeui/kled.cpp @@ -1,5 +1,5 @@ /* This file is part of the KDE libraries - Copyright (C) 1998 Jörg Habenicht (j.habenicht@europemail.com) + Copyright (C) 1998 J�rg Habenicht (j.habenicht@europemail.com) This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public @@ -288,7 +288,7 @@ KLed::paintRound() // paint a ROUND RAISED led lamp paint.drawEllipse( scale, scale, width - scale*2, width - scale*2 ); // Draw the bright light spot of the LED now, using modified "old" - // painter routine taken from TDEUI´s KLed widget: + // painter routine taken from TDEUI�s KLed widget: // Setting the new width of the pen is essential to avoid "pixelized" // shadow like it can be observed with the old LED code @@ -300,7 +300,7 @@ KLed::paintRound() // paint a ROUND RAISED led lamp light_width *= 2; light_width /= 3; - // Calculate the LED´s "light factor": + // Calculate the LED�s "light factor": int light_quote = (130*2/(light_width?light_width:1))+100; // Now draw the bright spot on the LED: @@ -384,7 +384,7 @@ KLed::paintSunken() // paint a ROUND SUNKEN led lamp paint.drawEllipse( scale, scale, width - scale*2, width - scale*2 ); // Draw the bright light spot of the LED now, using modified "old" - // painter routine taken from TDEUI´s KLed widget: + // painter routine taken from TDEUI�s KLed widget: // Setting the new width of the pen is essential to avoid "pixelized" // shadow like it can be observed with the old LED code @@ -396,7 +396,7 @@ KLed::paintSunken() // paint a ROUND SUNKEN led lamp light_width *= 2; light_width /= 3; - // Calculate the LED´s "light factor": + // Calculate the LED�s "light factor": int light_quote = (130*2/(light_width?light_width:1))+100; // Now draw the bright spot on the LED: @@ -425,7 +425,7 @@ KLed::paintSunken() // paint a ROUND SUNKEN led lamp paint.setBrush( brush ); // This avoids filling of the ellipse // Set the initial color value to colorGroup().light() (bright) and start - // drawing the shadow border at 45° (45*16 = 720). + // drawing the shadow border at 45� (45*16 = 720). int angle = -720; color = colorGroup().light(); @@ -536,6 +536,12 @@ KLed::color() const return led_color; } +TQColor +KLed::offColor() const +{ + return led_off_color; +} + KLed::Look KLed::look() const { @@ -580,6 +586,17 @@ KLed::setColor(const TQColor& col) } } +void +KLed::setOffColor(const TQColor& col) +{ + if(led_off_color!=col) { + if(d->on_map) { delete d->on_map; d->on_map = 0; } + if(d->off_map) { delete d->off_map; d->off_map = 0; } + d->offcolor = col; + update(); + } +} + void KLed::setDarkFactor(int darkfactor) { diff --git a/tdeui/kled.h b/tdeui/kled.h index 7b9f327fa..b4f828ea4 100644 --- a/tdeui/kled.h +++ b/tdeui/kled.h @@ -1,5 +1,5 @@ /* This file is part of the KDE libraries - Copyright (C) 1998 Jörg Habenicht (j.habenicht@europemail.com) + Copyright (C) 1998 J�rg Habenicht (j.habenicht@europemail.com) This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public @@ -50,6 +50,7 @@ class TDEUI_EXPORT KLed : public TQWidget Q_PROPERTY( Shape shape READ shape WRITE setShape ) Q_PROPERTY( Look look READ look WRITE setLook ) Q_PROPERTY( TQColor color READ color WRITE setColor ) + Q_PROPERTY( TQColor offColor READ color WRITE setOffColor ) Q_PROPERTY( int darkFactor READ darkFactor WRITE setDarkFactor ) public: @@ -147,6 +148,14 @@ public: */ TQColor color() const; + /** + * Returns the off color of the widget + * + * @see OffColor + * @short Returns LED off color. + */ + TQColor offColor() const; + /** * Returns the look of the widget. * @@ -203,6 +212,23 @@ public: */ void setColor(const TQColor& color); + /** + * Set the off color of the widget. + * The Color is shown with the KLed::On state. + * The KLed::Off state is shown with this color if set + * + * The widget calls the update() method, so it will + * be updated when entering the main event loop. + * + * Note that calling setColor will override this value + * + * @see Color + * + * @param color New off color of the LED. + * @short Sets the LED off color. + */ + void setOffColor(const TQColor& color); + /** * Sets the factor to darken the LED in OFF state. * Same as TQColor::dark(). @@ -316,6 +342,7 @@ protected: private: State led_state; TQColor led_color; + TQColor led_off_color; Look led_look; Shape led_shape;