From 28d63449d578b11383aff47a9b12b86e2bba96cc Mon Sep 17 00:00:00 2001 From: Tsu Jan Date: Tue, 15 Oct 2024 11:08:46 +0330 Subject: [PATCH] Fixed the scaled pixmap of `Fm::IconEngine` MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Scaling is taken into account separately for Qt < 6.8 and Qt ≥ 6.8. Closes https://github.com/lxqt/libfm-qt/issues/788 --- src/core/iconinfo_p.h | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/core/iconinfo_p.h b/src/core/iconinfo_p.h index 50d124a5..8c857763 100644 --- a/src/core/iconinfo_p.h +++ b/src/core/iconinfo_p.h @@ -103,9 +103,17 @@ bool IconEngine::isNull() { return info ? info->internalQicon().isNull() : true; } -QPixmap IconEngine::scaledPixmap(const QSize &size, QIcon::Mode mode, QIcon::State state, qreal /*scale*/) { +QPixmap IconEngine::scaledPixmap(const QSize &size, QIcon::Mode mode, QIcon::State state, qreal scale) { auto info = info_.lock(); - return info ? info->internalQicon().pixmap(size, mode, state) : QPixmap{}; + return info ? + // According to Qt doc, "size" is device-independent since Qt 6.8, + // while it was device-dependent prior to Qt 6.8. +#if (QT_VERSION < QT_VERSION_CHECK(6,8,0)) + info->internalQicon().pixmap((size.toSizeF() / scale).toSize(), scale, mode, state) +#else + info->internalQicon().pixmap(size, scale, mode, state) +#endif + : QPixmap{}; } QList IconEngine::availableSizes(QIcon::Mode mode, QIcon::State state) {