diff options
author | Volker Hilsheimer <[email protected]> | 2024-11-28 10:25:06 +0100 |
---|---|---|
committer | Volker Hilsheimer <[email protected]> | 2024-11-29 21:56:14 +0100 |
commit | 3a825036a3cb2e29fe5822e5a158fb3fb4c63c32 (patch) | |
tree | 59274fcd004977ed09951552726e5e517dbc0981 | |
parent | ab53500cfa11b988e7e4234583fa6eb5027b4c08 (diff) |
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 <[email protected]>
Reviewed-by: Christian Ehrlicher <[email protected]>
-rw-r--r-- | src/plugins/styles/modernwindows/qwindows11style.cpp | 2 | ||||
-rw-r--r-- | src/widgets/styles/qcommonstyle.cpp | 4 | ||||
-rw-r--r-- | src/widgets/styles/qfusionstyle.cpp | 2 | ||||
-rw-r--r-- | src/widgets/styles/qwindowsstyle.cpp | 10 |
4 files changed, 9 insertions, 9 deletions
diff --git a/src/plugins/styles/modernwindows/qwindows11style.cpp b/src/plugins/styles/modernwindows/qwindows11style.cpp index 138eb3f83e2..b40676cd3d7 100644 --- a/src/plugins/styles/modernwindows/qwindows11style.cpp +++ b/src/plugins/styles/modernwindows/qwindows11style.cpp @@ -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) diff --git a/src/widgets/styles/qcommonstyle.cpp b/src/widgets/styles/qcommonstyle.cpp index 63740829bc0..d1f17ff2832 100644 --- a/src/widgets/styles/qcommonstyle.cpp +++ b/src/widgets/styles/qcommonstyle.cpp @@ -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())); diff --git a/src/widgets/styles/qfusionstyle.cpp b/src/widgets/styles/qfusionstyle.cpp index 7e062009cca..aa672cca91f 100644 --- a/src/widgets/styles/qfusionstyle.cpp +++ b/src/widgets/styles/qfusionstyle.cpp @@ -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)); diff --git a/src/widgets/styles/qwindowsstyle.cpp b/src/widgets/styles/qwindowsstyle.cpp index bae182b4676..ca1ab05e4a7 100644 --- a/src/widgets/styles/qwindowsstyle.cpp +++ b/src/widgets/styles/qwindowsstyle.cpp @@ -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)) ? |