Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sync: from linuxdeepin/dtkwidget #86

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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 (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
Loading