summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWladimir Leuschner <wladimir.leuschner@qt.io>2024-01-22 15:37:19 +0100
committerJani Heikkinen <jani.heikkinen@qt.io>2024-03-07 15:53:40 +0000
commitd11d503850488d268e856e0737777672f317ad2d (patch)
treedbb91246c8c7fbf6a5b49a3b55707463a006c985
parent1e96139cf273d144e6d90b4b925f7b8670a5f788 (diff)
QWindows11Style: Update font size in menubar items and spacing between items
Reduce the spacing between menu bar items and change font size to 10pt. Fixes: QTBUG-120639 Change-Id: Ic16e74f4a2426be6d6ef40904919d92785d96ce5 Reviewed-by: Robert Löhning <robert.loehning@qt.io> Reviewed-by: Oliver Wolff <oliver.wolff@qt.io> (cherry picked from commit f75e554c6af7ea00bb5e6aa62a2af26350b67d98)
-rw-r--r--src/plugins/styles/modernwindows/qwindows11style.cpp17
1 files changed, 14 insertions, 3 deletions
diff --git a/src/plugins/styles/modernwindows/qwindows11style.cpp b/src/plugins/styles/modernwindows/qwindows11style.cpp
index d25a6323c0..e54dc5d9e8 100644
--- a/src/plugins/styles/modernwindows/qwindows11style.cpp
+++ b/src/plugins/styles/modernwindows/qwindows11style.cpp
@@ -1365,21 +1365,27 @@ void QWindows11Style::drawControl(ControlElement element, const QStyleOption *op
break;
case CE_MenuBarItem:
if (const auto *mbi = qstyleoption_cast<const QStyleOptionMenuItem *>(option)) {
+ constexpr int hPadding = 11;
+ constexpr int topPadding = 4;
+ constexpr int bottomPadding = 6;
bool active = mbi->state & State_Selected;
bool hasFocus = mbi->state & State_HasFocus;
bool down = mbi->state & State_Sunken;
bool enabled = mbi->state & State_Enabled;
QStyleOptionMenuItem newMbi = *mbi;
+ newMbi.font.setPointSize(10);
if (enabled && (active || hasFocus)) {
if (active && down)
painter->setBrushOrigin(painter->brushOrigin() + QPoint(1, 1));
if (active && hasFocus) {
painter->setBrush(WINUI3Colors[colorSchemeIndex][subtleHighlightColor]);
painter->setPen(Qt::NoPen);
- QRect rect = mbi->rect.marginsRemoved(QMargins(2,2,2,2));
+ QRect rect = mbi->rect.marginsRemoved(QMargins(5,0,5,0));
painter->drawRoundedRect(rect,secondLevelRoundingRadius,secondLevelRoundingRadius,Qt::AbsoluteSize);
}
}
+ newMbi.rect.adjust(hPadding,topPadding,-hPadding,-bottomPadding);
+ painter->setFont(newMbi.font);
QCommonStyle::drawControl(element, &newMbi, painter, widget);
}
break;
@@ -1880,8 +1886,13 @@ QSize QWindows11Style::sizeFromContents(ContentsType type, const QStyleOption *o
#if QT_CONFIG(menubar)
case CT_MenuBarItem:
- if (!contentSize.isEmpty())
- contentSize += QSize(QWindowsVistaStylePrivate::windowsItemHMargin * 5 + 1 + 16, 5 + 16);
+ if (!contentSize.isEmpty()) {
+ constexpr int hMargin = 2 * 6;
+ constexpr int hPadding = 2 * 11;
+ constexpr int itemHeight = 32;
+ contentSize.setWidth(contentSize.width() + hMargin + hPadding);
+ contentSize.setHeight(itemHeight);
+ }
break;
#endif