-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathQLed.h
66 lines (57 loc) · 2.31 KB
/
QLed.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
/***************************************************************************
* Copyright (C) 2010 by P. Sereno *
* http://www.sereno-online.com *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License *
* version 2.1 as published by the Free Software Foundation *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Lesser General Public License for more details. *
* http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. *
***************************************************************************/
#ifndef QLED_H
#define QLED_H
#include <Qt>
#include <QWidget>
// My Qt designer widget plugin class
class QColor;
class QSvgRenderer;
class QLed : public QWidget
{
Q_OBJECT
Q_ENUMS (ledColor)
Q_ENUMS (ledShape)
Q_PROPERTY(bool value READ value WRITE setValue);
Q_PROPERTY(ledColor onColor READ onColor WRITE setOnColor);
Q_PROPERTY(ledColor offColor READ offColor WRITE setOffColor);
Q_PROPERTY(ledShape shape READ shape WRITE setShape)
public:
QLed(QWidget *parent = 0);
virtual ~QLed();
bool value() const { return m_value; }
enum ledColor { Red=0,Green,Yellow,Grey,Orange,Purple,Blue };
enum ledShape { Circle=0,Square,Triangle,Rounded};
ledColor onColor() const { return m_onColor; }
ledColor offColor() const { return m_offColor; }
ledShape shape() const { return m_shape; }
public slots:
void setValue(bool);
void setOnColor(ledColor);
void setOffColor(ledColor);
void setShape(ledShape);
void toggleValue();
protected:
bool m_value;
ledColor m_onColor, m_offColor;
int id_Timer;
ledShape m_shape;
QStringList shapes;
QStringList colors;
void paintEvent(QPaintEvent *event);
private:
QSvgRenderer *renderer ;
};
#endif