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 *e)
19 QPainter painter(this);
20 painter.setRenderHint(QPainter::Antialiasing, true);
21 painter.drawPixmap(0, 0, QPixmap(ICON_PREFIX + name + ".png").
22 scaled(QSize(95, 95), Qt::IgnoreAspectRatio, Qt::SmoothTransformation));
25 void TranslucentButton::flash()
27 QPropertyAnimation *ani = new QPropertyAnimation(this, "opacity", 0);
28 ani->setDuration(2000);
29 ani->setStartValue(0.);
31 ani->setEasingCurve(QEasingCurve::OutQuart);
33 ani->start(QPropertyAnimation::DeleteWhenStopped);
34 connect(ani, SIGNAL(destroyed()), this, SLOT(onAnimationEnd()));
37 void TranslucentButton::setOpacity(qreal opacity)
43 void TranslucentButton::onAnimationEnd()