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 3936d254ca.
Pick-to: 6.7
Fixes: QTBUG-124554
Task-number: QTBUG-114539
Change-Id: I8a34d7ed937db261ce652bd66234783fb3338cbb
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
bb10
parent
9aac7b092d
commit
74e8f673b8
|
|
@ -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());
|
||||
|
|
|
|||
Loading…
Reference in New Issue