Commit 04d7c7ed authored by Kai Uwe Broulik's avatar Kai Uwe Broulik 🍇
Browse files

kstyle: Use menuTitle font metrics for size calculation

Ensures the size of the heading is taken into account properly.

BUG: 443805


(cherry picked from commit c0f7505c)
parent ef7af7ea
Pipeline #207318 passed with stage
in 2 minutes and 38 seconds
......@@ -3135,15 +3135,16 @@ QSize Style::menuItemSizeFromContents(const QStyleOption *option, const QSize &c
} else {
// build toolbutton option
const QStyleOptionToolButton toolButtonOption(separatorMenuItemOption(menuItemOption, widget));
const QFontMetrics fm(menuTitleFont(toolButtonOption));
// make sure height is large enough for icon and text
const int iconWidth(menuItemOption->maxIconWidth);
const int textHeight(menuItemOption->fontMetrics.height());
const int textHeight(fm.height());
if (!menuItemOption->icon.isNull())
size.setHeight(qMax(size.height(), iconWidth));
if (!menuItemOption->text.isEmpty()) {
size.setHeight(qMax(size.height(), textHeight));
size.setWidth(qMax(size.width(), menuItemOption->fontMetrics.boundingRect(menuItemOption->text).width()));
size.setWidth(qMax(size.width(), fm.boundingRect(menuItemOption->text).width()));
}
return sizeFromContents(CT_ToolButton, &toolButtonOption, size, widget);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment