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,22 +3,17 @@
#include <QPropertyAnimation>
#include "ElaToggleSwitch.h"
ElaToggleSwitchPrivate::ElaToggleSwitchPrivate(QObject* parent)
: QObject{parent}
{
}
ElaToggleSwitchPrivate::ElaToggleSwitchPrivate(QObject *parent) : QObject{parent} {}
ElaToggleSwitchPrivate::~ElaToggleSwitchPrivate()
{
}
ElaToggleSwitchPrivate::~ElaToggleSwitchPrivate() {}
void ElaToggleSwitchPrivate::_startPosAnimation(qreal startX, qreal endX, bool isToggle)
{
void ElaToggleSwitchPrivate::_startPosAnimation(qreal startX, qreal endX, bool isToggle) {
Q_Q(ElaToggleSwitch);
QPropertyAnimation* circleAnimation = new QPropertyAnimation(q, "circleCenterX");
connect(circleAnimation, &QPropertyAnimation::valueChanged, q, [=](const QVariant& value) {
this->_circleCenterX = value.toReal();
q->update(); });
QPropertyAnimation *circleAnimation = new QPropertyAnimation(q, "circleCenterX");
connect(circleAnimation, &QPropertyAnimation::valueChanged, q, [=](const QVariant &value) {
this->_circleCenterX = value.toReal();
q->update();
});
circleAnimation->setStartValue(startX);
circleAnimation->setEndValue(endX);
circleAnimation->setEasingCurve(QEasingCurve::InOutSine);
@@ -27,28 +22,25 @@ void ElaToggleSwitchPrivate::_startPosAnimation(qreal startX, qreal endX, bool i
Q_EMIT q->toggled(isToggle);
}
void ElaToggleSwitchPrivate::_startRadiusAnimation(qreal startRadius, qreal endRadius)
{
void ElaToggleSwitchPrivate::_startRadiusAnimation(qreal startRadius, qreal endRadius) {
Q_Q(ElaToggleSwitch);
QPropertyAnimation* circleRadiusAnimation = new QPropertyAnimation(q, "circleRadius");
connect(circleRadiusAnimation, &QPropertyAnimation::valueChanged, q, [=](const QVariant& value) {
QPropertyAnimation *circleRadiusAnimation = new QPropertyAnimation(q, "circleRadius");
connect(circleRadiusAnimation, &QPropertyAnimation::valueChanged, q, [=](const QVariant &value) {
this->_circleRadius = value.toReal();
q->update(); });
q->update();
});
circleRadiusAnimation->setEasingCurve(QEasingCurve::InOutSine);
circleRadiusAnimation->setStartValue(startRadius);
circleRadiusAnimation->setEndValue(endRadius);
circleRadiusAnimation->start(QAbstractAnimation::DeleteWhenStopped);
}
void ElaToggleSwitchPrivate::_adjustCircleCenterX()
{
void ElaToggleSwitchPrivate::_adjustCircleCenterX() {
Q_Q(ElaToggleSwitch);
if (_circleCenterX > q->width() - q->height() / 2 - _margin * 2)
{
if (_circleCenterX > q->width() - q->height() / 2 - _margin * 2) {
_circleCenterX = q->width() - q->height() / 2 - _margin * 2;
}
if (_circleCenterX < q->height() / 2)
{
if (_circleCenterX < q->height() / 2) {
_circleCenterX = q->height() / 2;
}
}