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. Fixes: QTBUG-124554 Task-number: QTBUG-114539 Change-Id: I8a34d7ed937db261ce652bd66234783fb3338cbb Reviewed-by: Axel Spoerl <axel.spoerl@qt.io> (cherry picked from commit 74e8f673b827c57ebf2bf802840c19e4a1ac848b) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
e0ee9cfe31
commit
15ce2b8b7a
@ -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…
x
Reference in New Issue
Block a user