chore: 格式化ElaWidgetTools代码

This commit is contained in:
sleepwithoutbz
2025-09-20 01:39:00 +08:00
parent d2fded145d
commit 4ab391f8a1
394 changed files with 10913 additions and 15860 deletions

View File

@@ -3,35 +3,25 @@
#include <QPainter>
#include <QPainterPath>
#include <QPropertyAnimation>
ElaThemeAnimationWidget::ElaThemeAnimationWidget(QWidget* parent)
: QWidget{parent}
{
_pEndRadius = 0.01;
}
ElaThemeAnimationWidget::ElaThemeAnimationWidget(QWidget *parent) : QWidget{parent} { _pEndRadius = 0.01; }
ElaThemeAnimationWidget::~ElaThemeAnimationWidget()
{
}
ElaThemeAnimationWidget::~ElaThemeAnimationWidget() {}
void ElaThemeAnimationWidget::startAnimation(int msec)
{
QPropertyAnimation* themeChangeAnimation = new QPropertyAnimation(this, "pRadius");
void ElaThemeAnimationWidget::startAnimation(int msec) {
QPropertyAnimation *themeChangeAnimation = new QPropertyAnimation(this, "pRadius");
themeChangeAnimation->setDuration(msec);
themeChangeAnimation->setEasingCurve(QEasingCurve::InOutSine);
connect(themeChangeAnimation, &QPropertyAnimation::finished, this, [=]() {
Q_EMIT animationFinished();
this->deleteLater();
});
connect(themeChangeAnimation, &QPropertyAnimation::valueChanged, this, [=](const QVariant& value) {
update();
});
connect(themeChangeAnimation, &QPropertyAnimation::valueChanged, this, [=](const QVariant &value) { update(); });
themeChangeAnimation->setStartValue(0);
themeChangeAnimation->setEndValue(_pEndRadius);
themeChangeAnimation->start(QAbstractAnimation::DeleteWhenStopped);
}
void ElaThemeAnimationWidget::paintEvent(QPaintEvent* event)
{
void ElaThemeAnimationWidget::paintEvent(QPaintEvent *event) {
QPainter painter(this);
painter.save();
painter.setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform);
@@ -44,10 +34,11 @@ void ElaThemeAnimationWidget::paintEvent(QPaintEvent* event)
animationImagePainter.setRenderHints(QPainter::Antialiasing);
animationImagePainter.drawImage(_pOldWindowBackground.rect(), _pOldWindowBackground);
animationImagePainter.setCompositionMode(QPainter::CompositionMode::CompositionMode_SourceOut);
qreal devicePixelRatioF = _pOldWindowBackground.devicePixelRatioF();
qreal devicePixelRatioF = _pOldWindowBackground.devicePixelRatioF();
QPainterPath clipPath;
clipPath.moveTo(_pCenter.x() * devicePixelRatioF, _pCenter.y() * devicePixelRatioF);
clipPath.addEllipse(QPointF(_pCenter.x() * devicePixelRatioF, _pCenter.y() * devicePixelRatioF), _pRadius * devicePixelRatioF, _pRadius * devicePixelRatioF);
clipPath.addEllipse(QPointF(_pCenter.x() * devicePixelRatioF, _pCenter.y() * devicePixelRatioF), _pRadius * devicePixelRatioF,
_pRadius * devicePixelRatioF);
animationImagePainter.setClipPath(clipPath);
animationImagePainter.drawImage(animationImage.rect(), animationImage);
animationImagePainter.end();