feat: 添加ElaWidgetTool库

This commit is contained in:
sleepwithoutbz
2025-09-19 22:40:52 +08:00
parent 5f93e8caf6
commit 4eef5c7fd5
407 changed files with 36325 additions and 7 deletions

View File

@@ -0,0 +1,45 @@
#include "ElaMaskWidget.h"
#include <QPainter>
#include <QPropertyAnimation>
ElaMaskWidget::ElaMaskWidget(QWidget* parent)
: QWidget{parent}
{
setObjectName("ElaMaskWidget");
setStyleSheet("#ElaMaskWidget{background-color:transparent;}");
_pMaskAlpha = 0;
}
ElaMaskWidget::~ElaMaskWidget()
{
}
void ElaMaskWidget::doMaskAnimation(int endValue)
{
QPropertyAnimation* opacityAnimation = new QPropertyAnimation(this, "pMaskAlpha");
connect(opacityAnimation, &QPropertyAnimation::valueChanged, this, [=](const QVariant& value) {
update();
});
connect(opacityAnimation, &QPropertyAnimation::finished, this, [=]() {
if (endValue == 0)
{
setVisible(false);
}
});
opacityAnimation->setEasingCurve(QEasingCurve::InOutSine);
opacityAnimation->setDuration(250);
opacityAnimation->setStartValue(_pMaskAlpha);
opacityAnimation->setEndValue(endValue);
opacityAnimation->start(QAbstractAnimation::DeleteWhenStopped);
}
void ElaMaskWidget::paintEvent(QPaintEvent* event)
{
QPainter painter(this);
painter.save();
painter.setPen(Qt::NoPen);
painter.setRenderHint(QPainter::Antialiasing);
painter.setBrush(QColor(0x00, 0x00, 0x00, _pMaskAlpha));
painter.drawRect(rect());
painter.restore();
}