summaryrefslogtreecommitdiffstats
path: root/src/widgets/styles/qcommonstyle.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/widgets/styles/qcommonstyle.cpp')
-rw-r--r--src/widgets/styles/qcommonstyle.cpp27
1 files changed, 13 insertions, 14 deletions
diff --git a/src/widgets/styles/qcommonstyle.cpp b/src/widgets/styles/qcommonstyle.cpp
index 046af3a073..6ff85e2c1b 100644
--- a/src/widgets/styles/qcommonstyle.cpp
+++ b/src/widgets/styles/qcommonstyle.cpp
@@ -750,22 +750,22 @@ void QCommonStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, Q
case PE_IndicatorArrowRight:
case PE_IndicatorArrowLeft:
{
- if (opt->rect.width() <= 1 || opt->rect.height() <= 1)
+ const QRect &r = opt->rect;
+ if (r.width() <= 1 || r.height() <= 1)
break;
- QRect r = opt->rect;
int size = qMin(r.height(), r.width());
QPixmap pixmap;
+ const qreal dpr = p->device()->devicePixelRatio();
const QString pixmapName = QStyleHelper::uniqueName("$qt_ia-"_L1
% QLatin1StringView(metaObject()->className())
% HexString<uint>(pe),
- opt, QSize(size, size));
+ opt, QSize(size, size), dpr);
if (!QPixmapCache::find(pixmapName, &pixmap)) {
- const qreal pixelRatio = p->device()->devicePixelRatio();
- const qreal border = pixelRatio * (size / 5.);
- const qreal sqsize = pixelRatio * size;
- QImage image(sqsize, sqsize, QImage::Format_ARGB32_Premultiplied);
- image.fill(Qt::transparent);
- QPainter imagePainter(&image);
+ const qreal border = dpr * (size / 5.);
+ const qreal sqsize = dpr * size;
+ pixmap = QPixmap(QSize(size, size));
+ pixmap.fill(Qt::transparent);
+ QPainter imagePainter(&pixmap);
QPolygonF poly;
switch (pe) {
@@ -793,9 +793,9 @@ void QCommonStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, Q
bsy = proxy()->pixelMetric(PM_ButtonShiftVertical, opt, widget);
}
- const QRectF bounds = poly.boundingRect();
- const qreal sx = sqsize / 2 - bounds.center().x() - 1;
- const qreal sy = sqsize / 2 - bounds.center().y() - 1;
+ const QPointF boundsCenter = poly.boundingRect().center();
+ const qreal sx = sqsize / 2 - boundsCenter.x();
+ const qreal sy = sqsize / 2 - boundsCenter.y();
imagePainter.translate(sx + bsx, sy + bsy);
imagePainter.setPen(opt->palette.buttonText().color());
imagePainter.setBrush(opt->palette.buttonText());
@@ -812,8 +812,7 @@ void QCommonStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, Q
imagePainter.drawPolygon(poly);
imagePainter.end();
- pixmap = QPixmap::fromImage(image);
- pixmap.setDevicePixelRatio(pixelRatio);
+ pixmap.setDevicePixelRatio(dpr);
QPixmapCache::insert(pixmapName, pixmap);
}
int xOffset = r.x() + (r.width() - size)/2;