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#611
  • Loading branch information
deepin-ci-robot committed Oct 14, 2024
1 parent d88429a commit 5c48fc0
Show file tree
Hide file tree
Showing 11 changed files with 33 additions and 6 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
Binary file not shown.
Binary file not shown.
Binary file added src/widgets/assets/icons/bloom/radio_checked.dci
Binary file not shown.
Binary file not shown.
4 changes: 4 additions & 0 deletions src/widgets/assets/icons/dtk-icon-theme.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -74,5 +74,9 @@
<file alias="window_normal.dci">bloom/window_normal.dci</file>
<file alias="switch_on.dci">bloom/switch_on.dci</file>
<file alias="switch_off.dci">bloom/switch_off.dci</file>
<file alias="radio_checked.dci">bloom/radio_checked.dci</file>
<file alias="radio_unchecked.dci">bloom/radio_unchecked.dci</file>
<file alias="checkbox_checked.dci">bloom/checkbox_checked.dci</file>
<file alias="checkbox_unchecked.dci">bloom/checkbox_unchecked.dci</file>
</qresource>
</RCC>
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
11 changes: 11 additions & 0 deletions src/widgets/dlabel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -262,21 +262,32 @@ void DLabel::paintEvent(QPaintEvent *event)
if (d->scaledcontents) {
QSize scaledSize = cr.size() * devicePixelRatioF();
if (!d->scaledpixmap || d->scaledpixmap->size() != scaledSize) {
#if QT_VERSION < QT_VERSION_CHECK(6, 8, 0)
if (!d->cachedimage)
#endif
#if QT_VERSION < QT_VERSION_CHECK(6, 4, 2)
d->cachedimage = new QImage(d->pixmap->toImage());
delete d->scaledpixmap;
#else
#if QT_VERSION < QT_VERSION_CHECK(6, 8, 0)
d->cachedimage = QImage(d->pixmap->toImage());
#endif
d->scaledpixmap.reset();
#endif
#if QT_VERSION < QT_VERSION_CHECK(6, 8, 0)
QImage scaledImage =
d->cachedimage->scaled(scaledSize,
Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
#else
d->scaledpixmap = d->pixmap->scaled(scaledSize,
Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
#endif
#if QT_VERSION < QT_VERSION_CHECK(6, 4, 2)
d->scaledpixmap = new QPixmap(QPixmap::fromImage(scaledImage));
#else
#if QT_VERSION < QT_VERSION_CHECK(6, 8, 0)
d->scaledpixmap = QPixmap(QPixmap::fromImage(scaledImage));
#endif
#endif
d->scaledpixmap->setDevicePixelRatio(devicePixelRatioF());
}
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
8 changes: 4 additions & 4 deletions src/widgets/dsimplelistview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -955,10 +955,10 @@ void DSimpleListView::mouseMoveEvent(QMouseEvent *mouseEvent)
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
auto point = QPoint{mouseEvent->x() - columnRenderX, d->renderOffset + mouseEvent->y() - hoverItemIndex * d->rowHeight};
#else
auto point = QPoint{mouseEvent->position().x() - columnRenderX,
auto point = QPointF{mouseEvent->position().x() - columnRenderX,
d->renderOffset + mouseEvent->position().y() - hoverItemIndex * d->rowHeight};
#endif
mouseHoverChanged(d->mouseHoverItem, item, columnCounter,point);
mouseHoverChanged(d->mouseHoverItem, item, columnCounter,point.toPoint());
d->mouseHoverItem = item;

if (d->lastHoverItem == NULL || !item->sameAs(d->lastHoverItem) || columnCounter != d->lastHoverColumnIndex) {
Expand Down Expand Up @@ -1235,10 +1235,10 @@ void DSimpleListView::mouseReleaseEvent(QMouseEvent *mouseEvent)
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
auto point = QPoint{mouseEvent->x() - columnRenderX, d->renderOffset + mouseEvent->y() - releaseItemIndex * d->rowHeight};
#else
auto point = QPoint{mouseEvent->position().x() - columnRenderX,
auto point = QPointF{mouseEvent->position().x() - columnRenderX,
d->renderOffset + mouseEvent->position().y() - releaseItemIndex * d->rowHeight};
#endif
mouseReleaseChanged((*d->renderItems)[releaseItemIndex], columnCounter, point);
mouseReleaseChanged((*d->renderItems)[releaseItemIndex], columnCounter, point.toPoint());
}
}

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 5c48fc0

Please sign in to comment.