diff --git a/src/widgets/assets/icons/bloom/switch_off.dci b/src/widgets/assets/icons/bloom/switch_off.dci index 957f499a4..a02a0ed1e 100644 Binary files a/src/widgets/assets/icons/bloom/switch_off.dci and b/src/widgets/assets/icons/bloom/switch_off.dci differ diff --git a/src/widgets/assets/icons/bloom/switch_on.dci b/src/widgets/assets/icons/bloom/switch_on.dci index 20ec32c84..a0cc26539 100644 Binary files a/src/widgets/assets/icons/bloom/switch_on.dci and b/src/widgets/assets/icons/bloom/switch_on.dci differ diff --git a/src/widgets/dswitchbutton.cpp b/src/widgets/dswitchbutton.cpp index 9aed27f4d..48e5d1bc0 100644 --- a/src/widgets/dswitchbutton.cpp +++ b/src/widgets/dswitchbutton.cpp @@ -11,12 +11,10 @@ #include #include -#include DWIDGET_BEGIN_NAMESPACE constexpr int DCI_ICON_SIZE = 120; -constexpr int TIMER_INTERVAL = 200; /*! @~english @@ -63,7 +61,7 @@ void DSwitchButton::paintEvent(QPaintEvent *e) painter.drawControl(DStyle::CE_SwitchButton, opt); painter.setRenderHint(QPainter::SmoothPixmapTransform); - painter.drawImage(rect().adjusted(2, -10, -2, 8), d->player.currentImage()); // 为了显示按钮的阴影所留的空白 + painter.drawImage(rect().adjusted(4, -8, -4, 8), d->player.currentImage()); // 为了显示按钮的阴影所留的空白 } /*! @@ -98,7 +96,6 @@ void DSwitchButton::initStyleOption(DStyleOptionButton *option) const DSwitchButtonPrivate::DSwitchButtonPrivate(DSwitchButton *qq) : DObjectPrivate(qq) - , timer(new QTimer(qq)) { } @@ -113,7 +110,6 @@ void DSwitchButtonPrivate::init() checked = false; animationStartValue = 0; animationEndValue = 1; - timer->setInterval(TIMER_INTERVAL); D_Q(DSwitchButton); @@ -143,7 +139,6 @@ void DSwitchButtonPrivate::init() DDciIcon icon = checked ? DDciIcon::fromTheme("switch_on") : DDciIcon::fromTheme("switch_off"); player.setIcon(icon); player.play(DDciIcon::Mode::Normal); - timer->start(); Q_EMIT q->checkedChanged(checked); }); @@ -152,13 +147,6 @@ void DSwitchButtonPrivate::init() q->update(); }); - q->connect(timer, &QTimer::timeout, q, [q, this]() { - player.stop(); - player.setIcon(!q->isChecked() ? DDciIcon::fromTheme("switch_on") : DDciIcon::fromTheme("switch_off")); - player.setMode(DDciIcon::Normal); - timer->stop(); - }); - q->connect(DGuiApplicationHelper::instance(), &DGuiApplicationHelper::themeTypeChanged, q, initPlayer); } diff --git a/src/widgets/private/dswitchbutton_p.h b/src/widgets/private/dswitchbutton_p.h index 32f265aaf..81c8513ad 100644 --- a/src/widgets/private/dswitchbutton_p.h +++ b/src/widgets/private/dswitchbutton_p.h @@ -31,7 +31,6 @@ class DSwitchButtonPrivate : public DTK_CORE_NAMESPACE::DObjectPrivate double animationEndValue = 0.0; DDciIconPlayer player; - QTimer *timer; public: D_DECLARE_PUBLIC(DSwitchButton)