Improve translucent button visibility... again.
[dorian] / widgets / translucentbutton.h
1 #ifndef TRANSLUCENTBUTTON_H
2 #define TRANSLUCENTBUTTON_H
3
4 #include <QLabel>
5 #include <QString>
6
7 class QWidget;
8 class QPaintEvent;
9 class QMouseEvent;
10 class QTimer;
11
12 /**
13  * A button that is transparent, but can temporarily made opaque by flashing it.
14  */
15 class TranslucentButton: public QLabel
16 {
17     Q_OBJECT
18
19 public:
20     explicit TranslucentButton(const QString &iconName, QWidget *parent);
21     ~TranslucentButton();
22     static const int pixels;
23     static const int elevatorInterval;
24
25 public slots:
26     void flash(int duration = 700);
27     void stopFlash();
28
29 signals:
30     void triggered();
31
32 protected:
33     void paintEvent(QPaintEvent *);
34     void mouseReleaseEvent(QMouseEvent *);
35     void timerEvent(QTimerEvent *e);
36
37 private:
38     QString name;
39     bool transparent;
40     QTimer *timer;
41     int elevatorTimer;
42 };
43
44 #endif // TRANSLUCENTBUTTON_H