Skip to content

Commit

Permalink
refactor: use DciIco in wallpapertlist
Browse files Browse the repository at this point in the history
as title

log:
  • Loading branch information
Johnson-zs committed Aug 14, 2024
1 parent a0a7238 commit 5de3391
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 30 deletions.
2 changes: 2 additions & 0 deletions src/plugins/desktop/ddplugin-wallpapersetting/images.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,7 @@
<file>images/transparent_button_normal.svg</file>
<file>images/transparent_button_press.svg</file>
<file>images/edit.svg</file>
<file>images/arrow-left.dci</file>
<file>images/arrow-right.dci</file>
</qresource>
</RCC>
Binary file not shown.
Binary file not shown.
21 changes: 2 additions & 19 deletions src/plugins/desktop/ddplugin-wallpapersetting/wallpaperlist.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -389,20 +389,8 @@ void WallpaperList::updateItemThumb()

void WallpaperList::init()
{
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
prevButton = new DImageButton(":/images/previous_normal.svg",
":/images/previous_hover.svg",
":/images/previous_press.svg", this);
nextButton = new DImageButton(":/images/next_normal.svg",
":/images/next_hover.svg",
":/images/next_press.svg", this);
#else
// TODO #v25: 需要设计师提供 dci icon
prevButton = new DIconButton(this);
prevButton->setIcon(QIcon(":/images/previous_normal.svg"));
nextButton = new DIconButton(this);
nextButton->setIcon(QIcon(":/images/next_normal.svg"));
#endif
prevButton = new DIconButton(DDciIcon(QStringLiteral(":/images/arrow-left.dci")), this);
nextButton = new DIconButton(DDciIcon(QStringLiteral(":/images/arrow-right.dci")), this);

setObjectName("WallpaperList-QScrollArea");
setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
Expand Down Expand Up @@ -436,13 +424,8 @@ void WallpaperList::init()
nextButton.setAnchor(Qt::AnchorVerticalCenter, this, Qt::AnchorVerticalCenter);
nextButton.setAnchor(Qt::AnchorRight, this, Qt::AnchorRight);

#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
connect(prevButton.widget(), &DImageButton::clicked, this, &WallpaperList::prevPage);
connect(nextButton.widget(), &DImageButton::clicked, this, &WallpaperList::nextPage);
#else
connect(prevButton.widget(), &DIconButton::clicked, this, &WallpaperList::prevPage);
connect(nextButton.widget(), &DIconButton::clicked, this, &WallpaperList::nextPage);
#endif

scrollAnimation.setTargetObject(horizontalScrollBar());
scrollAnimation.setPropertyName("value");
Expand Down
13 changes: 2 additions & 11 deletions src/plugins/desktop/ddplugin-wallpapersetting/wallpaperlist.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,12 @@
#include "wallpaperitem.h"

#include <DAnchors>
#include <DIconButton>

#include <QScrollArea>
#include <QPropertyAnimation>
#include <QTimer>

#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
# include <DImageButton>
#else
# include <DIconButton>
#endif

class QHBoxLayout;

namespace ddplugin_wallpapersetting {
Expand Down Expand Up @@ -80,13 +75,9 @@ private slots:
static const int kItemHeight;

private:
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
DTK_WIDGET_NAMESPACE::DAnchors<DTK_WIDGET_NAMESPACE::DImageButton> prevButton = nullptr;
DTK_WIDGET_NAMESPACE::DAnchors<DTK_WIDGET_NAMESPACE::DImageButton> nextButton = nullptr;
#else
DTK_WIDGET_NAMESPACE::DAnchors<DTK_WIDGET_NAMESPACE::DIconButton> prevButton = nullptr;
DTK_WIDGET_NAMESPACE::DAnchors<DTK_WIDGET_NAMESPACE::DIconButton> nextButton = nullptr;
#endif

QTimer *updateTimer = nullptr;
QPropertyAnimation scrollAnimation;

Expand Down

0 comments on commit 5de3391

Please sign in to comment.