Skip to content

Commit

Permalink
sync: from linuxdeepin/dtkwidget
Browse files Browse the repository at this point in the history
Synchronize source files from linuxdeepin/dtkwidget.

Source-pull-request: linuxdeepin/dtkwidget#609
  • Loading branch information
deepin-ci-robot committed Oct 8, 2024
1 parent d88429a commit 0349f7a
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 2 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
2 changes: 1 addition & 1 deletion src/widgets/dbounceanimation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ bool DBounceAnimation::eventFilter(QObject *o, QEvent *e)
if (auto absscroll = dynamic_cast<QAbstractScrollArea *>(o)) {
if (auto wheelEvent = dynamic_cast<QWheelEvent *>(e)) {
if (absscroll->verticalScrollBar()->value() <= 0 || absscroll->verticalScrollBar()->value() >= absscroll->verticalScrollBar()->maximum()) {
d->m_deltaSum += wheelEvent->delta();
d->m_deltaSum += wheelEvent->pixelDelta().x() != 0 ? wheelEvent->pixelDelta().x() : wheelEvent->pixelDelta().y();
bounceBack(wheelEvent->angleDelta().x() == 0 ? Qt::Vertical : Qt::Horizontal);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/widgets/dmessagemanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class ImageLabel : public QLabel {
QPainter p(this);
p.setRenderHint(QPainter::Antialiasing);
p.setOpacity(m_opacity);
p.drawPixmap(rect().marginsRemoved(contentsMargins()), *pixmap());
p.drawPixmap(rect().marginsRemoved(contentsMargins()), pixmap(Qt::ReturnByValue));
};
private:
qreal m_opacity;
Expand Down
12 changes: 12 additions & 0 deletions src/widgets/dswitchbutton.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,18 @@ void DSwitchButton::initStyleOption(DStyleOptionButton *option) const
option->rect.adjust(4, 4, -4, -4);
}

void DSwitchButton::checkStateSet()
{
D_D(DSwitchButton);
if (isChecked() == d->checked) {
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 0349f7a

Please sign in to comment.