KWidgetsAddons

kled.h
1 /*
2  This file is part of the KDE libraries
3  SPDX-FileCopyrightText: 1998 Jörg Habenicht <[email protected]>
4 
5  SPDX-License-Identifier: LGPL-2.0-or-later
6 */
7 
8 #ifndef KLED_H
9 #define KLED_H
10 
11 #include <kwidgetsaddons_export.h>
12 
13 #include <QWidget>
14 
15 class QColor;
16 
34 class KWIDGETSADDONS_EXPORT KLed : public QWidget
35 {
36  Q_OBJECT
37  Q_PROPERTY(State state READ state WRITE setState)
38  Q_PROPERTY(Shape shape READ shape WRITE setShape)
39  Q_PROPERTY(Look look READ look WRITE setLook)
40  Q_PROPERTY(QColor color READ color WRITE setColor)
41  Q_PROPERTY(int darkFactor READ darkFactor WRITE setDarkFactor)
42 
43 public:
44 
49  enum State { Off, On };
50  Q_ENUM(State)
51 
52 
56  enum Shape { Rectangular, Circular };
57  Q_ENUM(Shape)
58 
59 
64  enum Look { Flat, Raised, Sunken };
65  Q_ENUM(Look)
66 
67 
73  explicit KLed(QWidget *parent = nullptr);
74 
83  explicit KLed(const QColor &color, QWidget *parent = nullptr);
84 
97  KLed(const QColor &color, KLed::State state, KLed::Look look, KLed::Shape shape,
98  QWidget *parent = nullptr);
99 
104  ~KLed() override;
105 
112  QColor color() const;
113 
120  State state() const;
121 
128  Look look() const;
129 
136  Shape shape() const;
137 
144  int darkFactor() const;
145 
159  void setColor(const QColor &color);
160 
168  void setState(State state);
169 
182  void setLook(Look look);
183 
190  void setShape(Shape shape);
191 
204  void setDarkFactor(int darkFactor);
205 
206  QSize sizeHint() const override;
207  QSize minimumSizeHint() const override;
208 
209 public Q_SLOTS:
210 
214  void toggle();
215 
221  void on();
222 
228  void off();
229 
230 protected:
231  void paintEvent(QPaintEvent *) override;
232  void resizeEvent(QResizeEvent *) override;
233 
238  void updateCachedPixmap();
239 
240 private:
241  class Private;
242  Private *const d;
243 
244  void updateAccessibleName();
245 };
246 
247 #endif
Q_ENUM(...)
An LED widget.
Definition: kled.h:34
virtual QSize minimumSizeHint() const const
Look
Displays a flat, round or sunken LED.
Definition: kled.h:64
virtual void paintEvent(QPaintEvent *event)
Q_PROPERTY(...)
virtual QSize sizeHint() const const
State
Status of the light is on/off.
Definition: kled.h:49
Shape
Shades of the lamp.
Definition: kled.h:56
virtual void resizeEvent(QResizeEvent *event)
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Fri Jul 10 2020 22:42:36 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.