From 753e0032dc70c2dc075dfd3f135eeaa69be9306f Mon Sep 17 00:00:00 2001 From: Christian Ehrlicher Date: Thu, 20 Feb 2025 19:03:26 +0100 Subject: [PATCH] Fusion style: Fix drawing mdi close button with dpr != 1.0 Fix the drawing of the SC_TitleBarCloseButton for fractional dpr by only drawing two lines with a width of 2 instead 6 single ones as the single ones might get disturbed due to rounding. Pick-to: 6.8 Fixes: QTBUG-133834 Change-Id: I711cef885ed04fa695c24ee3e536697a0ebb3868 Reviewed-by: Wladimir Leuschner Reviewed-by: Volker Hilsheimer (cherry picked from commit 9b35b477f7d4b37a33204c837309a0ede0101129) --- src/widgets/styles/qfusionstyle.cpp | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/src/widgets/styles/qfusionstyle.cpp b/src/widgets/styles/qfusionstyle.cpp index 529babba74e..8382f6418f0 100644 --- a/src/widgets/styles/qfusionstyle.cpp +++ b/src/widgets/styles/qfusionstyle.cpp @@ -2044,16 +2044,14 @@ void QFusionStyle::drawComplexControl(ComplexControl control, const QStyleOption const auto buttonRect = proxy()->subControlRect(CC_TitleBar, titleBar, sc, widget); if (buttonRect.isValid()) { qt_fusion_draw_mdibutton(painter, titleBar, buttonRect, isHover(sc), isSunken(sc)); - - const QRect rect = buttonRect.marginsRemoved(buttonMargins); - const QLine lines[6] = {{rect.left() + 1, rect.top(), rect.right(), rect.bottom() - 1}, - {rect.left(), rect.top() + 1, rect.right() - 1, rect.bottom()}, - {rect.right() - 1, rect.top(), rect.left(), rect.bottom() - 1}, - {rect.right(), rect.top() + 1, rect.left() + 1, rect.bottom()}, - {rect.left(), rect.top(), rect.right(), rect.bottom()}, - {rect.left(), rect.bottom(), rect.right(), rect.top()}}; - painter->setPen(buttonPaintingsColor); - painter->drawLines(lines, 6); + QRect rect = buttonRect.marginsRemoved(buttonMargins); + rect.setWidth((rect.width() / 2) * 2 + 1); + rect.setHeight((rect.height() / 2) * 2 + 1); + const QLine lines[2] = { { rect.topLeft(), rect.bottomRight() }, + { rect.topRight(), rect.bottomLeft() }, }; + const auto pen = QPen(buttonPaintingsColor, 2); + painter->setPen(pen); + painter->drawLines(lines, 2); } }