1 #include "translucentbutton.h"
4 # define ICON_PREFIX ":/icons/mac/"
6 # define ICON_PREFIX ":/icons/"
9 TranslucentButton::TranslucentButton(const QString &name_, QWidget *parent):
10 QWidget(parent), name(name_), mOpacity(1.)
12 setGeometry(0, 0, 50, 50);
16 void TranslucentButton::paintEvent(QPaintEvent *)
19 QPainter painter(this);
20 painter.setRenderHint(QPainter::Antialiasing, true);
21 painter.drawPixmap(0, 0, QPixmap(ICON_PREFIX + name + ".png").scaled(
22 QSize(95, 95), Qt::IgnoreAspectRatio, Qt::SmoothTransformation));
26 void TranslucentButton::flash()
28 QPropertyAnimation *ani = new QPropertyAnimation(this, "opacity", 0);
29 ani->setDuration(3000);
30 ani->setStartValue(0.);
32 ani->setEasingCurve(QEasingCurve::OutQuart);
33 ani->start(QPropertyAnimation::DeleteWhenStopped);
36 void TranslucentButton::setOpacity(qreal opacity)