diff --git a/src/widgets/styles/qcommonstyle.cpp b/src/widgets/styles/qcommonstyle.cpp index 109abbefb2a..b853a8e9632 100644 --- a/src/widgets/styles/qcommonstyle.cpp +++ b/src/widgets/styles/qcommonstyle.cpp @@ -759,7 +759,7 @@ void QCommonStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, Q const QString pixmapName = QStyleHelper::uniqueName("$qt_ia-"_L1 % QLatin1StringView(metaObject()->className()) % HexString(pe), - opt, QSize(size, size) * pixelRatio); + opt, QSize(size, size), pixelRatio); if (!QPixmapCache::find(pixmapName, &pixmap)) { const qreal border = pixelRatio * (size / 5.); const qreal sqsize = pixelRatio * size; diff --git a/src/widgets/styles/qfusionstyle.cpp b/src/widgets/styles/qfusionstyle.cpp index d98fd3601ce..34a0105b801 100644 --- a/src/widgets/styles/qfusionstyle.cpp +++ b/src/widgets/styles/qfusionstyle.cpp @@ -157,7 +157,7 @@ static void qt_fusion_draw_arrow(Qt::ArrowType type, QPainter *painter, const QS const QString cacheKey = QStyleHelper::uniqueName("fusion-arrow"_L1 % HexString(type) % HexString(color.rgba()), - option, rect.size()); + option, rect.size(), dpr); if (!QPixmapCache::find(cacheKey, &cachePixmap)) { cachePixmap = styleCachePixmap(rect.size(), dpr); QPainter cachePainter(&cachePixmap); @@ -1143,7 +1143,7 @@ void QFusionStyle::drawControl(ControlElement element, const QStyleOption *optio % HexString(header->position) % HexString(header->orientation) % QLatin1Char(isSectionDragTarget ? '1' : '0'), - option, option->rect.size()); + option, option->rect.size(), dpr); QPixmap cache; if (!QPixmapCache::find(pixmapName, &cache)) { cache = styleCachePixmap(rect.size(), dpr); @@ -1881,7 +1881,7 @@ void QFusionStyle::drawComplexControl(ComplexControl control, const QStyleOption if (const QStyleOptionSpinBox *spinBox = qstyleoption_cast(option)) { const qreal dpr = painter->device()->devicePixelRatio(); QPixmap cache; - QString pixmapName = QStyleHelper::uniqueName("spinbox"_L1, spinBox, spinBox->rect.size()); + QString pixmapName = QStyleHelper::uniqueName("spinbox"_L1, spinBox, spinBox->rect.size(), dpr); if (!QPixmapCache::find(pixmapName, &cache)) { cache = styleCachePixmap(spinBox->rect.size(), dpr); @@ -2583,7 +2583,7 @@ void QFusionStyle::drawComplexControl(ComplexControl control, const QStyleOption % QLatin1StringView(comboBox->editable ? "-editable" : "") % QLatin1StringView(isEnabled ? "-enabled" : "") % QLatin1StringView(!comboBox->frame ? "-frameless" : ""), - option, comboBox->rect.size()); + option, comboBox->rect.size(), dpr); if (!QPixmapCache::find(pixmapName, &cache)) { cache = styleCachePixmap(comboBox->rect.size(), dpr); QPainter cachePainter(&cache); @@ -2695,7 +2695,8 @@ void QFusionStyle::drawComplexControl(ComplexControl control, const QStyleOption grooveColor.setHsv(buttonColor.hue(), qMin(255, (int)(buttonColor.saturation())), qMin(255, (int)(buttonColor.value()*0.9))); - QString groovePixmapName = QStyleHelper::uniqueName("slider_groove"_L1, option, groove.size()); + QString groovePixmapName = QStyleHelper::uniqueName("slider_groove"_L1, option, + groove.size(), dpr); QRect pixmapRect(0, 0, groove.width(), groove.height()); // draw background groove @@ -2838,7 +2839,8 @@ void QFusionStyle::drawComplexControl(ComplexControl control, const QStyleOption } // draw handle if ((option->subControls & SC_SliderHandle) ) { - QString handlePixmapName = QStyleHelper::uniqueName("slider_handle"_L1, option, handle.size()); + QString handlePixmapName = QStyleHelper::uniqueName("slider_handle"_L1, option, + handle.size(), dpr); if (!QPixmapCache::find(handlePixmapName, &cache)) { cache = styleCachePixmap(handle.size(), dpr); QRect pixmapRect(0, 0, handle.width(), handle.height()); diff --git a/src/widgets/styles/qstyle_p.h b/src/widgets/styles/qstyle_p.h index 9a4e5794f88..59e87810c54 100644 --- a/src/widgets/styles/qstyle_p.h +++ b/src/widgets/styles/qstyle_p.h @@ -48,7 +48,7 @@ inline QPixmap styleCachePixmap(const QSize &size, qreal pixelRatio) QPixmap internalPixmapCache; \ QPainter *p = painter; \ const auto dpr = p->device()->devicePixelRatio(); \ - const QString unique = QStyleHelper::uniqueName((a), option, option->rect.size()); \ + const QString unique = QStyleHelper::uniqueName((a), option, option->rect.size(), dpr); \ int txType = painter->deviceTransform().type() | painter->worldTransform().type(); \ const bool doPixmapCache = (!option->rect.isEmpty()) \ && ((txType <= QTransform::TxTranslate) || (painter->deviceTransform().type() == QTransform::TxScale)); \ diff --git a/src/widgets/styles/qstylehelper.cpp b/src/widgets/styles/qstylehelper.cpp index 1084761d30d..02827de8470 100644 --- a/src/widgets/styles/qstylehelper.cpp +++ b/src/widgets/styles/qstylehelper.cpp @@ -32,7 +32,7 @@ static inline bool usePixmapCache(const QStyleOption *opt) return true; } -QString uniqueName(const QString &key, const QStyleOption *option, const QSize &size) +QString uniqueName(const QString &key, const QStyleOption *option, const QSize &size, qreal dpr) { if (!usePixmapCache(option)) return {}; @@ -43,7 +43,8 @@ QString uniqueName(const QString &key, const QStyleOption *option, const QSize & % HexString(complexOption ? uint(complexOption->activeSubControls) : 0u) % HexString(option->palette.cacheKey()) % HexString(size.width()) - % HexString(size.height()); + % HexString(size.height()) + % HexString(dpr); #if QT_CONFIG(spinbox) if (const QStyleOptionSpinBox *spinBox = qstyleoption_cast(option)) { diff --git a/src/widgets/styles/qstylehelper_p.h b/src/widgets/styles/qstylehelper_p.h index 524417e4058..98470ad1ced 100644 --- a/src/widgets/styles/qstylehelper_p.h +++ b/src/widgets/styles/qstylehelper_p.h @@ -39,7 +39,7 @@ class QWindow; namespace QStyleHelper { - QString uniqueName(const QString &key, const QStyleOption *option, const QSize &size); + QString uniqueName(const QString &key, const QStyleOption *option, const QSize &size, qreal dpr); Q_WIDGETS_EXPORT qreal dpi(const QStyleOption *option);