#include #include #include #include #include "raisedbutton.h" #include "lib/customshadoweffect.h" RaisedButton::RaisedButton(QWidget *parent) : FlatButton(parent) { CustomShadowEffect *effect = new CustomShadowEffect; effect->setBlurRadius(17); effect->setDistance(6); setGraphicsEffect(effect); setAutoFillBackground(true); QPropertyAnimation *animation; animation = new QPropertyAnimation; animation->setTargetObject(effect); animation->setPropertyName("distance"); animation->setStartValue(effect->distance()); animation->setEndValue(1); animation->setDuration(100); _group.addAnimation(animation); animation = new QPropertyAnimation; animation->setTargetObject(effect); animation->setPropertyName("blurRadius"); animation->setStartValue(effect->blurRadius()); animation->setEndValue(9); animation->setDuration(100); _group.addAnimation(animation); connect(animation, SIGNAL(valueChanged(QVariant)), this, SLOT(update())); } RaisedButton::~RaisedButton() { } void RaisedButton::mousePressEvent(QMouseEvent *event) { Q_UNUSED(event) _group.setDirection(QAbstractAnimation::Forward); _group.start(); FlatButton::mousePressEvent(event); } void RaisedButton::mouseReleaseEvent(QMouseEvent *event) { Q_UNUSED(event) _group.setDirection(QAbstractAnimation::Backward); _group.start(); FlatButton::mouseReleaseEvent(event); } void RaisedButton::paintEvent(QPaintEvent *event) { Q_UNUSED(event) QStylePainter painter(this); painter.drawControl(QStyle::CE_PushButton, getStyleOption()); }