.
[dorian] / widgets / translucentbutton.h
index 7160d12..5e26707 100644 (file)
@@ -1,28 +1,44 @@
 #ifndef TRANSLUCENTBUTTON_H
 #define TRANSLUCENTBUTTON_H
 
-#include <QtGui>
+#include <QLabel>
 #include <QString>
 
-class TranslucentButton: public QWidget
+class QWidget;
+class QPaintEvent;
+class QMouseEvent;
+class QTimer;
+
+/**
+ * A button that is transparent, but can temporarily be made opaque by
+ * flashing it.
+ */
+class TranslucentButton: public QLabel
 {
     Q_OBJECT
-    Q_PROPERTY(qreal opacity READ opacity WRITE setOpacity)
 
 public:
-    explicit TranslucentButton(const QString &name, QWidget *parent);
-    qreal opacity() const {return mOpacity;}
-    void setOpacity(qreal opacity);
+    explicit TranslucentButton(const QString &iconName, QWidget *parent);
+    ~TranslucentButton();
+    static const int pixels;
+    static const int elevatorInterval;
 
 public slots:
-    void flash(int duration = 3000);
+    void flash(int duration = 700);
+    void stopFlash();
+
+signals:
+    void triggered();
 
 protected:
-    virtual void paintEvent(QPaintEvent *);
+    void paintEvent(QPaintEvent *);
+    void mouseReleaseEvent(QMouseEvent *);
+    void timerEvent(QTimerEvent *e);
 
 private:
     QString name;
-    qreal mOpacity;
+    bool transparent;
+    int elevatorTimer;
 };
 
 #endif // TRANSLUCENTBUTTON_H