Skip to content
Merged
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
24 changes: 24 additions & 0 deletions 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,11 @@ QPixmap DBuiltinIconEngine::pixmap(const QSize &size, QIcon::Mode mode,

QIconLoaderEngineEntry *entry = QIconLoaderEngine::entryForSize(m_info, size);
if (entry)
#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

return QPixmap();
}
Expand Down Expand Up @@ -222,7 +238,11 @@ 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 +406,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
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