Skip to content

Commit

Permalink
Fixed the scaled pixmap of Fm::IconEngine (#1015)
Browse files Browse the repository at this point in the history
Scaling is taken into account separately for Qt < 6.8 and Qt ≥ 6.8.

Closes #788
  • Loading branch information
tsujan authored Oct 20, 2024
1 parent a7b6049 commit 08c306d
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/core/iconinfo_p.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<QSize> IconEngine::availableSizes(QIcon::Mode mode, QIcon::State state) {
Expand Down

0 comments on commit 08c306d

Please sign in to comment.