comparison widgets/LEDButton.h @ 34:c43f2c4f66f2

* As previous commit
author Chris Cannam
date Fri, 17 Feb 2006 18:11:08 +0000
parents 651e4e868bcc
children 01ab51f72e84
comparison
equal deleted inserted replaced
33:651e4e868bcc 34:c43f2c4f66f2
28 class QColor; 28 class QColor;
29 29
30 class LEDButton : public QWidget 30 class LEDButton : public QWidget
31 { 31 {
32 Q_OBJECT 32 Q_OBJECT
33 Q_ENUMS(State)
34 Q_PROPERTY(State state READ state WRITE setState)
35 Q_PROPERTY(QColor color READ color WRITE setColor) 33 Q_PROPERTY(QColor color READ color WRITE setColor)
36 Q_PROPERTY(int darkFactor READ darkFactor WRITE setDarkFactor) 34 Q_PROPERTY(int darkFactor READ darkFactor WRITE setDarkFactor)
37 35
38 public: 36 public:
39 enum State { Off, On };
40
41 LEDButton(QWidget *parent = 0); 37 LEDButton(QWidget *parent = 0);
42 LEDButton(const QColor &col, QWidget *parent = 0); 38 LEDButton(const QColor &col, QWidget *parent = 0);
43 LEDButton(const QColor& col, LEDButton::State state, QWidget *parent = 0); 39 LEDButton(const QColor& col, bool state, QWidget *parent = 0);
44 ~LEDButton(); 40 ~LEDButton();
45 41
46 State state() const; 42 bool state() const;
47 QColor color() const; 43 QColor color() const;
48 int darkFactor() const; 44 int darkFactor() const;
49
50 void setState(State state);
51 void toggleState();
52 void setColor(const QColor& color);
53 void setDarkFactor(int darkfactor);
54 45
55 virtual QSize sizeHint() const; 46 virtual QSize sizeHint() const;
56 virtual QSize minimumSizeHint() const; 47 virtual QSize minimumSizeHint() const;
57 48
58 signals: 49 signals:
61 public slots: 52 public slots:
62 void toggle(); 53 void toggle();
63 void on(); 54 void on();
64 void off(); 55 void off();
65 56
57 void setState(bool);
58 void toggleState();
59 void setColor(const QColor& color);
60 void setDarkFactor(int darkfactor);
61
66 protected: 62 protected:
67 void paintEvent(QPaintEvent *); 63 void paintEvent(QPaintEvent *);
68 void mousePressEvent(QMouseEvent *); 64 void mousePressEvent(QMouseEvent *);
69 65
70 private: 66 private:
71 State led_state; 67 bool led_state;
72 QColor led_color; 68 QColor led_color;
73 69
74 private: 70 private:
75 class LEDButtonPrivate; 71 class LEDButtonPrivate;
76 LEDButtonPrivate *d; 72 LEDButtonPrivate *d;