Chris@32
|
1 /* -*- c-basic-offset: 4 -*- vi:set ts=8 sts=4 sw=4: */
|
Chris@32
|
2
|
Chris@32
|
3 /*
|
Chris@32
|
4 A waveform viewer and audio annotation editor.
|
Chris@32
|
5 Chris Cannam, Queen Mary University of London, 2005-2006
|
Chris@32
|
6
|
Chris@32
|
7 This is experimental software. Not for distribution.
|
Chris@32
|
8 */
|
Chris@32
|
9
|
Chris@32
|
10 /*
|
Chris@32
|
11 This is a modified version of a source file from the KDE
|
Chris@32
|
12 libraries. Copyright (c) 1998-2004 Jörg Habenicht, Richard J
|
Chris@32
|
13 Moore and others, distributed under the GNU Lesser General Public
|
Chris@32
|
14 License.
|
Chris@32
|
15
|
Chris@32
|
16 Ported to Qt4 by Chris Cannam.
|
Chris@32
|
17
|
Chris@32
|
18 The original KDE widget comes in round and rectangular and flat,
|
Chris@32
|
19 raised, and sunken variants. This version retains only the round
|
Chris@33
|
20 sunken variant. This version also implements a simple button API.
|
Chris@32
|
21 */
|
Chris@32
|
22
|
Chris@32
|
23 #ifndef _LED_BUTTON_H_
|
Chris@32
|
24 #define _LED_BUTTON_H_
|
Chris@32
|
25
|
Chris@32
|
26 #include <QWidget>
|
Chris@32
|
27
|
Chris@32
|
28 class QColor;
|
Chris@32
|
29
|
Chris@32
|
30 class LEDButton : public QWidget
|
Chris@32
|
31 {
|
Chris@32
|
32 Q_OBJECT
|
Chris@32
|
33 Q_PROPERTY(QColor color READ color WRITE setColor)
|
Chris@32
|
34 Q_PROPERTY(int darkFactor READ darkFactor WRITE setDarkFactor)
|
Chris@32
|
35
|
Chris@32
|
36 public:
|
Chris@32
|
37 LEDButton(QWidget *parent = 0);
|
Chris@32
|
38 LEDButton(const QColor &col, QWidget *parent = 0);
|
Chris@34
|
39 LEDButton(const QColor& col, bool state, QWidget *parent = 0);
|
Chris@32
|
40 ~LEDButton();
|
Chris@32
|
41
|
Chris@34
|
42 bool state() const;
|
Chris@32
|
43 QColor color() const;
|
Chris@32
|
44 int darkFactor() const;
|
Chris@32
|
45
|
Chris@32
|
46 virtual QSize sizeHint() const;
|
Chris@32
|
47 virtual QSize minimumSizeHint() const;
|
Chris@32
|
48
|
Chris@33
|
49 signals:
|
Chris@33
|
50 void stateChanged(bool);
|
Chris@33
|
51
|
Chris@32
|
52 public slots:
|
Chris@32
|
53 void toggle();
|
Chris@32
|
54 void on();
|
Chris@32
|
55 void off();
|
Chris@32
|
56
|
Chris@34
|
57 void setState(bool);
|
Chris@34
|
58 void toggleState();
|
Chris@34
|
59 void setColor(const QColor& color);
|
Chris@34
|
60 void setDarkFactor(int darkfactor);
|
Chris@34
|
61
|
Chris@32
|
62 protected:
|
Chris@32
|
63 void paintEvent(QPaintEvent *);
|
Chris@33
|
64 void mousePressEvent(QMouseEvent *);
|
Chris@32
|
65
|
Chris@32
|
66 private:
|
Chris@34
|
67 bool led_state;
|
Chris@32
|
68 QColor led_color;
|
Chris@32
|
69
|
Chris@32
|
70 private:
|
Chris@32
|
71 class LEDButtonPrivate;
|
Chris@32
|
72 LEDButtonPrivate *d;
|
Chris@32
|
73 };
|
Chris@32
|
74
|
Chris@32
|
75 #endif
|