From 6f353bb066b4d0e1e0c334da2d5588523decb38d Mon Sep 17 00:00:00 2001 From: Christian Ehrlicher Date: Fri, 22 Nov 2024 21:19:21 +0100 Subject: [PATCH] Fusion style: cleanup PE_IndicatorToolBarSeparator drawing Cleanup drawing of PE_IndicatorToolBarSeparator - there is no need to call QRect::topLeft/bottomRight() and then only use x or y. No need to stress the optimizer that much. Change-Id: I477dcea6c9bebd981777fdc1eb53963074257e01 Reviewed-by: Volker Hilsheimer (cherry picked from commit 9fa471f9c7b4f2218109fa4bd17d66cf5b24101d) Reviewed-by: Qt Cherry-pick Bot --- src/widgets/styles/qfusionstyle.cpp | 36 +++++++++++------------------ 1 file changed, 14 insertions(+), 22 deletions(-) diff --git a/src/widgets/styles/qfusionstyle.cpp b/src/widgets/styles/qfusionstyle.cpp index b0bc41739cd..95e52b41ef5 100644 --- a/src/widgets/styles/qfusionstyle.cpp +++ b/src/widgets/styles/qfusionstyle.cpp @@ -477,30 +477,22 @@ void QFusionStyle::drawPrimitive(PrimitiveElement elem, { QRect rect = option->rect; const int margin = 6; + const QColor col = option->palette.window().color(); + painter->setPen(col.darker(110)); if (option->state & State_Horizontal) { - const int offset = rect.width()/2; - painter->setPen(QPen(option->palette.window().color().darker(110))); - painter->drawLine(rect.bottomLeft().x() + offset, - rect.bottomLeft().y() - margin, - rect.topLeft().x() + offset, - rect.topLeft().y() + margin); - painter->setPen(QPen(option->palette.window().color().lighter(110))); - painter->drawLine(rect.bottomLeft().x() + offset + 1, - rect.bottomLeft().y() - margin, - rect.topLeft().x() + offset + 1, - rect.topLeft().y() + margin); + const int offset = rect.width() / 2; + painter->drawLine(rect.left() + offset, rect.bottom() - margin, + rect.left() + offset, rect.top() + margin); + painter->setPen(col.lighter(110)); + painter->drawLine(rect.left() + offset + 1, rect.bottom() - margin, + rect.left() + offset + 1, rect.top() + margin); } else { //Draw vertical separator - const int offset = rect.height()/2; - painter->setPen(QPen(option->palette.window().color().darker(110))); - painter->drawLine(rect.topLeft().x() + margin , - rect.topLeft().y() + offset, - rect.topRight().x() - margin, - rect.topRight().y() + offset); - painter->setPen(QPen(option->palette.window().color().lighter(110))); - painter->drawLine(rect.topLeft().x() + margin , - rect.topLeft().y() + offset + 1, - rect.topRight().x() - margin, - rect.topRight().y() + offset + 1); + const int offset = rect.height() / 2; + painter->drawLine(rect.left() + margin, rect.top() + offset, + rect.right() - margin, rect.top() + offset); + painter->setPen(col.lighter(110)); + painter->drawLine(rect.left() + margin, rect.top() + offset + 1, + rect.right() - margin, rect.top() + offset + 1); } } break;