pineapple-pictures/toolbutton.cpp

27 lines
643 B
C++
Raw Normal View History

2019-10-06 14:12:52 +08:00
#include "toolbutton.h"
2019-10-06 14:58:01 +08:00
#include "opacityhelper.h"
2019-10-06 14:12:52 +08:00
#include <QPainter>
#include <QGraphicsOpacityEffect>
#include <QPropertyAnimation>
ToolButton::ToolButton(QWidget *parent)
: QPushButton(parent)
2019-10-06 14:58:01 +08:00
, m_opacityHelper(new OpacityHelper(this))
2019-10-06 14:12:52 +08:00
{
setFlat(true);
setFixedSize(50, 50);
setStyleSheet("QPushButton {"
"background: transparent;"
"}"
"QPushButton:hover {"
"background: red;"
"}");
}
2019-10-06 14:58:01 +08:00
void ToolButton::setOpacity(qreal opacity, bool animated)
2019-10-06 14:12:52 +08:00
{
2019-10-06 14:58:01 +08:00
m_opacityHelper->setOpacity(opacity, animated);
2019-10-06 14:12:52 +08:00
}