# class KLed

###

Module | kdeui
Namespace |
Class | KLed
Inherits | QWidget

An LED widget.

Displays a round or rectangular light emitting diode.

It is configurable to arbitrary colors, the two on/off states and three styles (or "looks");

It may display itself in a performant flat view, a round view with light spot or a round view sunken in the screen.

Author Joerg Habenicht, Richard J. Moore (rich@kde.org) 1998, 1999

### enums

- Look { Flat, Raised, Sunken }
- Shape { Rectangular, Circular }
- State { Off, On }

enum details

### methods

- KLed (parent)

  returns ctor
  KDE 4.1.0 and later only

  Argument | Type | Default
  --- | --- | ---
  parent | QWidget | 0

  Constructs a green, round LED widget which will initially be turned on.

  parent - The parent widget.

- KLed (color, parent)

  returns ctor
  KDE 4.1.0 and later only

  Argument | Type | Default
  --- | --- | ---
  color | QColor |
  parent | QWidget | 0

  Constructs a round LED widget with the supplied color which will initially be turned on.

  color - Initial color of the LED.

  parent - The parent widget. Constructor

- KLed (color, state, look, shape, parent)

  returns ctor

  Argument | Type | Default
  --- | --- | ---
  color | QColor |
  state | KLed.State |
  look | KLed.Look |
  shape | KLed.Shape |
  parent | QWidget | 0

  Constructor with the color, state and look.

  Differs from above only in the parameters, which configure all settings.

  color - Initial color of the LED.

  state - Sets the State.

  look - Sets the Look.

  shape - Sets the Shape (rectangular or circular).

  parent - The parent widget. Constructor

- KLed (a0)

  returns ctor
  before KDE 4.1.0 only

  Argument | Type | Default
  --- | --- | ---
  a0 | QWidget | 0

- KLed (a0, a1)

  returns ctor
  before KDE 4.1.0 only

  Argument | Type | Default
  --- | --- | ---
  a0 | QColor |
  a1 | QWidget | 0

- color ( )

  returns QColor

  Returns the current color of the widget.

  See also Color Returns LED color.

- darkFactor ( )

  returns int

  Returns the factor to darken the LED.

  See also setDarkFactor() Returns dark factor.

- ledWidth ( )

  returns int

  Returns the width of the led.

- look ( )

  returns KLed.Look

  Returns the current look of the widget.

  See also Look Returns LED look.

- minimumSizeHint ( )

  returns QSize

- off ( )

  returns Nothing

  Sets the state of the widget to Off.

  The widget will be painted immediately.

  See also on() toggle() setState()

- on ( )

  returns Nothing

  Sets the state of the widget to On.

  The widget will be painted immediately.

  See also off() toggle() setState()

- paintCachedPixmap ( )

  returns bool

  Paint the cached antialiased pixmap corresponding to the state if any Returns true if the pixmap was painted, false if it hasn't been created yet

- paintEvent (a0)

  returns Nothing

  Argument | Type | Default
  --- | --- | ---
  a0 | QPaintEvent |

- paintFlat ( )

  returns Nothing

  Paints a circular, flat LED.

- paintRaised ( )

  returns Nothing

  Paints a circular, raised LED.

- paintRect ( )

  returns Nothing

  Paints a rectangular, flat LED.

- paintRectFrame (raised)

  returns Nothing

  Argument | Type | Default
  --- | --- | ---
  raised | bool |

  Paints a rectangular LED, either raised or sunken, depending on its argument.

- paintSunken ( )

  returns Nothing

  Paints a circular, sunken LED.

- setColor (color)

  returns Nothing

  Argument | Type | Default
  --- | --- | ---
  color | QColor |

  Set the color of the widget.

  The LED is shown with Color when in the KLed.On state or with the darken Color (@see setDarkFactor) in KLed.Off state.

  The widget calls the update() method, so it will be updated when entering the main event loop.

  See also Color

  color - New color of the LED. Sets the LED color.

- setDarkFactor (darkFactor)

  returns Nothing

  Argument | Type | Default
  --- | --- | ---
  darkFactor | int |

  Sets the factor to darken the LED in KLed.Off state.

  The darkFactor - should be greater than 100, otherwise the LED becomes lighter in KLed.Off state.

  Defaults to 300.

  See also QColor

  darkFactor - Sets the factor to darken the LED. Sets the factor to darken the LED.

- setLook (look)

  returns Nothing

  Argument | Type | Default
  --- | --- | ---
  look | KLed.Look |

  Sets the look of the widget.

  The look may be Flat, Raised or Sunken.

  The widget calls the update() method, so it will be updated when entering the main event loop.

  See also Look

  look - New look of the LED. Sets LED look.

- setShape (shape)

  returns Nothing

  Argument | Type | Default
  --- | --- | ---
  shape | KLed.Shape |

  Set the shape of the LED.

  shape - The LED shape. Set LED shape.

- setState (state)

  returns Nothing

  Argument | Type | Default
  --- | --- | ---
  state | KLed.State |

  Sets the state of the widget to On or Off.

  The widget will be painted immediately.

  See also on() off() toggle()

  state - The LED state: on or off. Set LED state.

- shape ( )

  returns KLed.Shape

  Returns the current shape of the widget.

  See also Shape Returns LED shape.

- sizeHint ( )

  returns QSize

- state ( )

  returns KLed.State

  Returns the current state of the widget (on/off).

  See also State Returns LED state.

- toggle ( )

  returns Nothing

  Toggles the state of the led from Off to On or vice versa.

  The widget repaints itself immediately.

### enums - detail

- Look { Flat, Raised, Sunken }

  Displays a flat, round or sunken LED.

  Displaying the LED flat is less time and color consuming, but not so nice to see.

  The sunken LED itself is (certainly) smaller than the round LED because of the 3 shading circles and is most time consuming. Makes sense for LED > 15x15 pixels.

  Timings: \n ( AMD K5/133, Diamond Stealth 64 PCI Graphics, widgetsize 29x29 )

- flat Approximately 0.7 msec per paint
- round Approximately 2.9 msec per paint
- sunken Approximately 3.3 msec per paint

The widget will be updated on the next repaining event.

LED look.

| Flat | - | - |
| Raised | - | - |
| Sunken | - | - |

- Shape { Rectangular, Circular }

  Shades of the lamp. LED shape

  | Rectangular | - | - |
  | Circular | - | - |

- State { Off, On }

  Status of the light is on/off. LED on/off.

  | Off | - | - |
  | On | - | - |