Wed, 29 Jun 2022 08:44:57 +0200
Prepare for DetailFermenter
314 | 1 | #ifndef _LED_H_ |
2 | #define _LED_H_ | |
3 | ||
4 | #include <QtDesigner/QtDesigner> | |
5 | #include <QWidget> | |
6 | ||
7 | class QTimer; | |
8 | ||
9 | class QDESIGNER_WIDGET_EXPORT LED : public QWidget | |
10 | { | |
11 | Q_OBJECT | |
12 | ||
13 | Q_PROPERTY(double diameter READ diameter WRITE setDiameter) // mm | |
14 | Q_PROPERTY(QColor color READ color WRITE setColor) | |
15 | Q_PROPERTY(Qt::Alignment alignment READ alignment WRITE setAlignment) | |
16 | Q_PROPERTY(bool state READ state WRITE setState) | |
17 | Q_PROPERTY(bool flashing READ isFlashing WRITE setFlashing) | |
18 | Q_PROPERTY(int flashRate READ flashRate WRITE setFlashRate) | |
19 | ||
20 | public: | |
21 | explicit LED(QWidget* parent=0); | |
22 | ~LED(); | |
23 | ||
24 | double diameter() const; | |
25 | void setDiameter(double diameter); | |
26 | ||
27 | QColor color() const; | |
28 | void setColor(const QColor& color); | |
29 | ||
30 | Qt::Alignment alignment() const; | |
31 | void setAlignment(Qt::Alignment alignment); | |
32 | ||
33 | bool state() const; | |
34 | ||
35 | bool isFlashing() const; | |
36 | ||
37 | int flashRate() const; | |
38 | ||
39 | public slots: | |
40 | void setState(bool state); | |
41 | void toggleState(); | |
42 | void setFlashing(bool flashing); | |
43 | void setFlashRate(int rate); | |
44 | void startFlashing(); | |
45 | void stopFlashing(); | |
46 | ||
47 | public: | |
48 | int heightForWidth(int width) const; | |
49 | QSize sizeHint() const; | |
50 | QSize minimumSizeHint() const; | |
51 | ||
52 | protected: | |
53 | void paintEvent(QPaintEvent* event); | |
54 | ||
55 | private: | |
56 | double diameter_; | |
57 | QColor color_; | |
58 | Qt::Alignment alignment_; | |
59 | bool initialState_; | |
60 | bool state_; | |
61 | int flashRate_; | |
62 | bool flashing_; | |
63 | ||
64 | // | |
65 | // Pixels per mm for x and y... | |
66 | // | |
67 | int pixX_, pixY_; | |
68 | ||
69 | // | |
70 | // Scaled values for x and y diameter. | |
71 | // | |
72 | int diamX_, diamY_; | |
73 | ||
74 | QRadialGradient gradient_; | |
75 | QTimer* timer_; | |
76 | }; | |
77 | ||
78 | #endif |