3 #include "translucentbutton.h"
6 const int TranslucentButton::pixels = 95;
7 const int TranslucentButton::elevatorInterval = 750;
9 TranslucentButton::TranslucentButton(const QString &name_, QWidget *parent):
10 QLabel(parent), name(name_), transparent(true)
12 setGeometry(0, 0, pixels, pixels);
13 timer = new QTimer(this);
14 timer->setSingleShot(true);
15 connect(timer, SIGNAL(timeout()), this, SLOT(stopFlash()));
16 elevatorTimer = startTimer(elevatorInterval);
19 TranslucentButton::~TranslucentButton()
21 killTimer(elevatorTimer);
24 void TranslucentButton::paintEvent(QPaintEvent *)
26 QPainter painter(this);
28 painter.setRenderHint(QPainter::Antialiasing, true);
29 painter.drawPixmap(0, 0, QPixmap(Platform::icon(name)).scaled(
30 QSize(pixels, pixels), Qt::IgnoreAspectRatio,
31 Qt::SmoothTransformation));
33 painter.fillRect(0, 0, pixels, pixels, Qt::NoBrush);
37 void TranslucentButton::flash(int duration)
43 timer->start(duration);
46 void TranslucentButton::stopFlash()
52 void TranslucentButton::mouseReleaseEvent(QMouseEvent *e)
59 void TranslucentButton::timerEvent(QTimerEvent *e)
61 if (e->timerId() == elevatorTimer) {