1 | /*************************************************************************** |
---|
2 | * Copyright (C) 2010 by Tn * |
---|
3 | * thenobody@poczta.fm * |
---|
4 | * * |
---|
5 | * This program is free software; you can redistribute it and/or modify * |
---|
6 | * it under the terms of the GNU Library General Public License as * |
---|
7 | * published by the Free Software Foundation; either version 3 of the * |
---|
8 | * License, or (at your option) any later version. * |
---|
9 | * * |
---|
10 | * This program is distributed in the hope that it will be useful, * |
---|
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * |
---|
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * |
---|
13 | * GNU General Public License for more details. * |
---|
14 | * * |
---|
15 | * You should have received a copy of the GNU Library General Public * |
---|
16 | * License along with this program; if not, write to the * |
---|
17 | * Free Software Foundation, Inc., * |
---|
18 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * |
---|
19 | ***************************************************************************/ |
---|
20 | |
---|
21 | #ifndef QLEDINDICATOR_H |
---|
22 | #define QLEDINDICATOR_H |
---|
23 | |
---|
24 | #include <QAbstractButton> |
---|
25 | #include <QResizeEvent> |
---|
26 | #include <QColor> |
---|
27 | #include <QDebug> |
---|
28 | |
---|
29 | class QLedIndicator : public QAbstractButton |
---|
30 | { |
---|
31 | Q_PROPERTY(QColor onColor1 WRITE setOnColor1 READ getOnColor1 ); |
---|
32 | Q_PROPERTY(QColor onColor2 WRITE setOnColor2 READ getOnColor2 ); |
---|
33 | Q_PROPERTY(QColor offColor1 WRITE setOffColor1 READ getOffColor1 ); |
---|
34 | Q_PROPERTY(QColor offColor2 WRITE setOffColor2 READ getOffColor2 ); |
---|
35 | Q_OBJECT |
---|
36 | public: |
---|
37 | QLedIndicator(QWidget *parent); |
---|
38 | |
---|
39 | void setOnColor1(QColor c) { onColor1 = c; } |
---|
40 | void setOffColor1(QColor c) { offColor1 = c; } |
---|
41 | void setOnColor2(QColor c) { onColor2 = c; } |
---|
42 | void setOffColor2(QColor c) { offColor2 = c; } |
---|
43 | |
---|
44 | QColor getOnColor1(void) { return onColor1; } |
---|
45 | QColor getOffColor1(void) { return offColor1; } |
---|
46 | QColor getOnColor2(void) { return onColor2; } |
---|
47 | QColor getOffColor2(void) { return offColor2; } |
---|
48 | |
---|
49 | bool red; |
---|
50 | |
---|
51 | protected: |
---|
52 | virtual void paintEvent (QPaintEvent *event); |
---|
53 | virtual void resizeEvent(QResizeEvent *event); |
---|
54 | |
---|
55 | private: |
---|
56 | static const qreal scaledSize; /* init in cpp */ |
---|
57 | QColor onColor1, offColor1; |
---|
58 | QColor onColor2, offColor2; |
---|
59 | QColor onColor1r, offColor1r; |
---|
60 | QColor onColor2r, offColor2r; |
---|
61 | QPixmap ledBuffer; |
---|
62 | |
---|
63 | |
---|
64 | }; |
---|
65 | |
---|
66 | #endif // QLEDINDICATOR_H |
---|