summaryrefslogtreecommitdiffstats
path: root/src/widgets/styles/qcommonstyle.cpp
diff options
context:
space:
mode:
authorChristian Ehrlicher <ch.ehrlicher@gmx.de>2024-04-19 17:16:19 +0200
committerChristian Ehrlicher <ch.ehrlicher@gmx.de>2024-04-22 20:26:51 +0200
commit74e8f673b827c57ebf2bf802840c19e4a1ac848b (patch)
tree0a41abc64c9f062d76ab5bd080f51c0d67f76142 /src/widgets/styles/qcommonstyle.cpp
parent9aac7b092d4ec1c51eee736cb86096ddceda762d (diff)
QCommonStyle: paint arrows with anti-aliasing
The high-dpi painting fix for the arrow painting was missing QPainter::AntiAliasing flag so the rectangle had some artifacts with certain (small) sizes. Also there is no reason to move the center by 1 pixel to the top left anymore now that we're using decimal values. This amends 3936d254ca0e7259cd97238c31df8413d03fd475. Pick-to: 6.7 Fixes: QTBUG-124554 Task-number: QTBUG-114539 Change-Id: I8a34d7ed937db261ce652bd66234783fb3338cbb Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
Diffstat (limited to 'src/widgets/styles/qcommonstyle.cpp')
-rw-r--r--src/widgets/styles/qcommonstyle.cpp11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/widgets/styles/qcommonstyle.cpp b/src/widgets/styles/qcommonstyle.cpp
index 046af3a073..109abbefb2 100644
--- a/src/widgets/styles/qcommonstyle.cpp
+++ b/src/widgets/styles/qcommonstyle.cpp
@@ -755,17 +755,18 @@ void QCommonStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, Q
QRect r = opt->rect;
int size = qMin(r.height(), r.width());
QPixmap pixmap;
+ const qreal pixelRatio = 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) * pixelRatio);
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);
+ imagePainter.setRenderHint(QPainter::Antialiasing);
QPolygonF poly;
switch (pe) {
@@ -793,9 +794,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());