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