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/dtkgui #65

Closed
wants to merge 1 commit into from
Closed
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
23 changes: 22 additions & 1 deletion src/util/private/dbuiltiniconengine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,11 @@ class Q_DECL_HIDDEN ImageEntry : public QIconLoaderEngineEntry
}
}

#if QT_VERSION >= QT_VERSION_CHECK(6, 8, 0)
QPixmap pixmap(const QSize &size, QIcon::Mode mode, QIcon::State state, qreal scale) override {
#else
QPixmap pixmap(const QSize &size, QIcon::Mode mode, QIcon::State state) override {
#endif
Q_UNUSED(state)

QPixmap pm;
Expand Down Expand Up @@ -111,7 +115,11 @@ class Q_DECL_HIDDEN DirImageEntry : public ImageEntry
return dir.filePath("normal." + suffix);
}

#if QT_VERSION >= QT_VERSION_CHECK(6, 8, 0)
QPixmap pixmap(const QSize &size, QIcon::Mode mode, QIcon::State state, qreal scale) override {
#else
QPixmap pixmap(const QSize &size, QIcon::Mode mode, QIcon::State state) override {
#endif
if (iconFileMap.isEmpty()) {
const QString &suffix = QFileInfo(filename).suffix();
QDir dir(filename);
Expand All @@ -128,7 +136,11 @@ class Q_DECL_HIDDEN DirImageEntry : public ImageEntry

reader.setFileName(iconFileMap.value(mode << 8 | state));

#if QT_VERSION >= QT_VERSION_CHECK(6, 8, 0)
return ImageEntry::pixmap(size, mode, state, scale);
#else
return ImageEntry::pixmap(size, mode, state);
#endif
}

QMap<qint16, QString> iconFileMap;
Expand Down Expand Up @@ -192,7 +204,7 @@ QPixmap DBuiltinIconEngine::pixmap(const QSize &size, QIcon::Mode mode,

QIconLoaderEngineEntry *entry = QIconLoaderEngine::entryForSize(m_info, size);
if (entry)
return entry->pixmap(size, mode, state);
return entry->pixmap(size, mode, state, 1.0);

return QPixmap();
}
Expand Down Expand Up @@ -222,7 +234,12 @@ void DBuiltinIconEngine::paint(QPainter *painter, const QRect &rect,
QIcon(bgFileName).paint(painter, rect, Qt::AlignCenter, mode, state);
}

#if QT_VERSION >= QT_VERSION_CHECK(6, 8, 0)
QPixmap pm = entry->pixmap(pixmapSize, mode, state, 1.0);
#else
QPixmap pm = entry->pixmap(pixmapSize, mode, state);
#endif

ImageEntry::Type type = static_cast<ImageEntry *>(entry)->type;
if (type == ImageEntry::TextType || (type == ImageEntry::ActionType && mode != QIcon::Normal)) {
QPainter pa(&pm);
Expand Down Expand Up @@ -386,7 +403,11 @@ void DBuiltinIconEngine::virtual_hook(int id, void *data)
// QIcon::pixmap() multiplies size by the device pixel ratio.
const int integerScale = qCeil(arg.scale);
QIconLoaderEngineEntry *entry = QIconLoaderEngine::entryForSize(m_info, arg.size / integerScale, integerScale);
#if QT_VERSION >= QT_VERSION_CHECK(6, 8, 0)
arg.pixmap = entry ? entry->pixmap(arg.size, arg.mode, arg.state, 1.0) : QPixmap();
#else
arg.pixmap = entry ? entry->pixmap(arg.size, arg.mode, arg.state) : QPixmap();
#endif
}
break;
default:
Expand Down
10 changes: 9 additions & 1 deletion src/util/private/xdgiconproxyengine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,11 @@ QPixmap XdgIconProxyEngine::pixmapByEntry(QIconLoaderEngineEntry *entry, const Q
if (!XdgIconFollowColorScheme()) {
DEEPIN_XDG_THEME::colorScheme.setLocalData(DEEPIN_XDG_THEME::PALETTE_MAP());

#if QT_VERSION >= QT_VERSION_CHECK(6, 8, 0)
return entry->pixmap(size, mode, state, 1.0);
#else
return entry->pixmap(size, mode, state);
#endif
}

QPixmap pixmap;
Expand All @@ -206,7 +210,11 @@ QPixmap XdgIconProxyEngine::pixmapByEntry(QIconLoaderEngineEntry *entry, const Q

pixmap = followColorPixmap(static_cast<ScalableEntry *>(entry), size, mode, state);
} else {
#if QT_VERSION >= QT_VERSION_CHECK(6, 8, 0)
pixmap = entry->pixmap(size, mode, state, 1.0);
#else
pixmap = entry->pixmap(size, mode, state);
#endif
}

free(type_name);
Expand Down Expand Up @@ -302,7 +310,7 @@ void XdgIconProxyEngine::virtual_hook(int id, void *data)
QIconEngine::ScaledPixmapArgument &arg = *reinterpret_cast<QIconEngine::ScaledPixmapArgument *>(data);
// QIcon::pixmap() multiplies size by the device pixel ratio.
const int integerScale = qCeil(arg.scale);

#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
QIconLoaderEngineEntry *entry = engine->entryForSize(arg.size / integerScale, integerScale);
#else
Expand Down
4 changes: 4 additions & 0 deletions tests/src/ut_builtinengine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,11 @@ TEST_F(ut_DBuiltinIconEngine, loadIcon)
ASSERT_EQ(entry->dir.path, builtinActionPath);
ASSERT_EQ(entry->dir.size, ICONSIZE);
ASSERT_EQ(entry->dir.type, QIconDirInfo::Scalable);
#if QT_VERSION >= QT_VERSION_CHECK(6, 8, 0)
ASSERT_FALSE(entry->pixmap(QSize(ICONSIZE, ICONSIZE), QIcon::Normal, QIcon::On, 1.0).isNull());
#else
ASSERT_FALSE(entry->pixmap(QSize(ICONSIZE, ICONSIZE), QIcon::Normal, QIcon::On).isNull());
#endif

#if QT_VERSION < QT_VERSION_CHECK(6, 4, 0)
for (auto item : themeInfo.entries) {
Expand Down
Loading