3 #include "translucentbutton.h"
7 # define ICON_PREFIX ":/icons/mac/"
9 # define ICON_PREFIX ":/icons/"
12 const int TranslucentButton::pixels = 95;
14 TranslucentButton::TranslucentButton(const QString &name_, QWidget *parent):
15 QLabel(parent), name(name_), transparent(true)
17 setGeometry(0, 0, pixels, pixels);
18 timer = new QTimer(this);
19 timer->setSingleShot(true);
20 connect(timer, SIGNAL(timeout()), this, SLOT(stopFlash()));
24 void TranslucentButton::paintEvent(QPaintEvent *)
26 QPainter painter(this);
28 painter.setRenderHint(QPainter::Antialiasing, true);
29 painter.drawPixmap(0, 0, QPixmap(ICON_PREFIX + name + ".png").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)
42 timer->start(duration);
45 void TranslucentButton::stopFlash()
51 void TranslucentButton::mouseReleaseEvent(QMouseEvent *e)