1 #include "translucentbutton.h"
5 # define ICON_PREFIX ":/icons/mac/"
7 # define ICON_PREFIX ":/icons/"
10 TranslucentButton::TranslucentButton(const QString &name_, QWidget *parent):
11 QWidget(parent), name(name_), opacity(1)
13 setGeometry(0, 0, 95, 95);
14 timer = new QTimer(this);
15 timer->setSingleShot(true);
16 connect(timer, SIGNAL(timeout()), this, SLOT(stopFlash()));
20 void TranslucentButton::paintEvent(QPaintEvent *)
22 QPainter painter(this);
24 painter.setRenderHint(QPainter::Antialiasing, true);
25 painter.drawPixmap(0, 0, QPixmap(ICON_PREFIX + name + ".png").scaled(
26 QSize(95, 95), Qt::IgnoreAspectRatio, Qt::SmoothTransformation));
28 painter.fillRect(0, 0, 95, 95, Qt::NoBrush);
32 void TranslucentButton::flash(int duration)
36 timer->start(duration);
39 void TranslucentButton::stopFlash()
45 void TranslucentButton::mousePressEvent(QMouseEvent *e)
48 Trace t("TranslucentButton::mousePressEvent");