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 setFixedSize(pixels, pixels);
13 elevatorTimer = startTimer(elevatorInterval);
16 TranslucentButton::~TranslucentButton()
18 killTimer(elevatorTimer);
21 void TranslucentButton::paintEvent(QPaintEvent *)
23 QPainter painter(this);
25 painter.setRenderHint(QPainter::Antialiasing, true);
26 painter.drawPixmap(0, 0, QPixmap(Platform::instance()->icon(name)).scaled(
27 QSize(pixels, pixels), Qt::IgnoreAspectRatio,
28 Qt::SmoothTransformation));
30 painter.fillRect(0, 0, pixels, pixels, Qt::NoBrush);
34 void TranslucentButton::flash(int duration)
40 QTimer::singleShot(duration, this, SLOT(stopFlash()));
43 void TranslucentButton::stopFlash()
49 void TranslucentButton::mouseReleaseEvent(QMouseEvent *e)
56 void TranslucentButton::timerEvent(QTimerEvent *e)
58 if (e->timerId() == elevatorTimer) {
61 QLabel::timerEvent(e);