Windows11Style: Use correct font when a pushbutton has a menu

When a pushbutton has a menu, the menu indicator is drawn as the glyph
ChevronDown from Segoe Fluent Icons font. But later the font is not
reset so it's also used for the push buttons label. Since the icon font
has no valid glyphs for most of the characters, a replacement is used
but this might not be the one set for the pushbutton.

Pick-to: 6.9 6.8
Change-Id: I25c9b993450e7fe740addb153259f46b570ad8f7
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
This commit is contained in:
Christian Ehrlicher 2025-03-17 19:54:34 +01:00
parent ada114f8b3
commit 1c26a93b3d

View File

@ -1390,6 +1390,7 @@ void QWindows11Style::drawControl(ControlElement element, const QStyleOption *op
int indicatorSize = proxy()->pixelMetric(PM_MenuButtonIndicator, btn, widget); int indicatorSize = proxy()->pixelMetric(PM_MenuButtonIndicator, btn, widget);
QLineF menuSplitter; QLineF menuSplitter;
QRectF indicatorRect; QRectF indicatorRect;
painter->save();
painter->setFont(assetFont); painter->setFont(assetFont);
if (btn->direction == Qt::LeftToRight) { if (btn->direction == Qt::LeftToRight) {
@ -1406,6 +1407,7 @@ void QWindows11Style::drawControl(ControlElement element, const QStyleOption *op
painter->drawText(indicatorRect, QStringLiteral(u"\uE70D"), Qt::AlignVCenter | Qt::AlignHCenter); painter->drawText(indicatorRect, QStringLiteral(u"\uE70D"), Qt::AlignVCenter | Qt::AlignHCenter);
painter->setPen(WINUI3Colors[colorSchemeIndex][controlStrokePrimary]); painter->setPen(WINUI3Colors[colorSchemeIndex][controlStrokePrimary]);
painter->drawLine(menuSplitter); painter->drawLine(menuSplitter);
painter->restore();
} }
if (!btn->icon.isNull()) { if (!btn->icon.isNull()) {
//Center both icon and text //Center both icon and text