Widget styles: use palette brushes to set the painter's brush

Don't go through the brush's color just to construct a new (solid)
brush. It removes other brush information, unnecessarily constructs
a temporary QBrush object.

Change-Id: I0a02034225f8f1025c7395b31e2f32119f77a37c
Reviewed-by: Doris Verria <doris.verria@qt.io>
Reviewed-by: Christian Ehrlicher <ch.ehrlicher@gmx.de>
This commit is contained in:
Volker Hilsheimer 2024-11-28 10:25:06 +01:00
parent ab53500cfa
commit 3a825036a3
4 changed files with 9 additions and 9 deletions

View File

@ -832,7 +832,7 @@ void QWindows11Style::drawPrimitive(PrimitiveElement element, const QStyleOption
painter->setFont(assetFont);
painter->setPen(option->palette.highlightedText().color());
painter->setBrush(option->palette.highlightedText().color());
painter->setBrush(option->palette.highlightedText());
if (option->state & State_On)
painter->drawText(clipRect, Qt::AlignVCenter | Qt::AlignLeft,"\uE73E");
else if (option->state & State_NoChange)

View File

@ -801,12 +801,12 @@ void QCommonStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, Q
if (!(opt->state & State_Enabled)) {
const int ofs = qRound(1 * dpr);
imagePainter.translate(ofs, ofs);
imagePainter.setBrush(opt->palette.light().color());
imagePainter.setBrush(opt->palette.light());
imagePainter.setPen(opt->palette.light().color());
imagePainter.drawPolygon(poly.data(), int(poly.size()));
imagePainter.drawPoints(poly.data(), int(poly.size()));
imagePainter.translate(-ofs, -ofs);
imagePainter.setBrush(opt->palette.mid().color());
imagePainter.setBrush(opt->palette.mid());
imagePainter.setPen(opt->palette.mid().color());
}
imagePainter.drawPolygon(poly.data(), int(poly.size()));

View File

@ -1346,7 +1346,7 @@ void QFusionStyle::drawControl(ControlElement element, const QStyleOption *optio
bool dis = !(mbi->state & State_Enabled);
if (act) {
painter->setBrush(option->palette.highlight().color());
painter->setBrush(option->palette.highlight());
painter->setPen(QPen(highlightOutline));
painter->drawRect(rect.adjusted(0, 0, -1, -1));

View File

@ -766,7 +766,7 @@ void QWindowsStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt,
points[4] = { points[3].x(), points[3].y() - 2 * scalev };
points[5] = { points[4].x() - 4 * scaleh, points[4].y() + 4 * scalev };
p->setPen(QPen(opt->palette.text().color(), 0));
p->setBrush(opt->palette.text().color());
p->setBrush(opt->palette.text());
p->drawPolygon(points.data(), static_cast<int>(points.size()));
}
if (doRestore)
@ -824,18 +824,18 @@ void QWindowsStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt,
p->setClipRegion(QRegion(topLeftPol));
p->setPen(opt->palette.dark().color());
p->setBrush(opt->palette.dark().color());
p->setBrush(opt->palette.dark());
p->drawPath(path1);
p->setPen(opt->palette.shadow().color());
p->setBrush(opt->palette.shadow().color());
p->setBrush(opt->palette.shadow());
p->drawPath(path2);
p->setClipRegion(QRegion(bottomRightPol));
p->setPen(opt->palette.light().color());
p->setBrush(opt->palette.light().color());
p->setBrush(opt->palette.light());
p->drawPath(path1);
p->setPen(opt->palette.midlight().color());
p->setBrush(opt->palette.midlight().color());
p->setBrush(opt->palette.midlight());
p->drawPath(path2);
QColor fillColor = ((opt->state & State_Sunken) || !(opt->state & State_Enabled)) ?