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 <wladimir.leuschner@qt.io>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
(cherry picked from commit 9b35b477f7d4b37a33204c837309a0ede0101129)
This commit is contained in:
Christian Ehrlicher 2025-02-20 19:03:26 +01:00
parent d027d6d9da
commit 753e0032dc

View File

@ -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);
}
}