Skip to content

Commit

Permalink
fix: wrong status of switch button
Browse files Browse the repository at this point in the history
correct the wrong initial status of switch button

Bug: https://pms.uniontech.com/bug-view-276221.html
Log:
  • Loading branch information
FeiWang1119 committed Oct 10, 2024
1 parent 8397688 commit b9b7c39
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
1 change: 1 addition & 0 deletions include/widgets/dswitchbutton.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ class LIBDTKWIDGETSHARED_EXPORT DSwitchButton : public QAbstractButton, public D
protected:
void paintEvent(QPaintEvent *e) Q_DECL_OVERRIDE;
void initStyleOption(DStyleOptionButton *option) const;
void checkStateSet() Q_DECL_OVERRIDE;

private:
D_DECLARE_PRIVATE(DSwitchButton)
Expand Down
11 changes: 11 additions & 0 deletions src/widgets/dswitchbutton.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,17 @@ void DSwitchButton::initStyleOption(DStyleOptionButton *option) const
option->rect.adjust(4, 4, -4, -4);
}

void DSwitchButton::checkStateSet()
{
D_D(DSwitchButton);
if (d->checked == isChecked())
return;

d->checked = isChecked();
DDciIcon icon = !d->checked ? DDciIcon::fromTheme("switch_on") : DDciIcon::fromTheme("switch_off");
d->player.setIcon(icon);
}

DSwitchButtonPrivate::DSwitchButtonPrivate(DSwitchButton *qq)
: DObjectPrivate(qq)
{
Expand Down

0 comments on commit b9b7c39

Please sign in to comment.