QStyleSheetStyle: fix CT_MenuItem with custom font
When a menu has a custom font size set, the size was adjusted to reflect this *after* the additional widths for icon or checkmark was added. When the used font is larger, the additional width added for the icon or checkmark will not be honored then. Therefore the size with the new font has to be added before adding the size for the icon/checkmark. Pick-to: 6.8 Fixes: QTBUG-115356 Change-Id: I33e83022bea9e3a531ac8e1651d8655076d88b4b Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> (cherry picked from commit 5436c4a363aa856180ce2949c2f5eeed451abfa9) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
b338217360
commit
4003ca0d32
@ -5457,6 +5457,11 @@ QSize QStyleSheetStyle::sizeFromContents(ContentsType ct, const QStyleOption *op
|
||||
drawCheckMark = false; // ignore the checkmarks provided by the QComboMenuDelegate
|
||||
#endif
|
||||
QSize sz(csz);
|
||||
if (subRule.hasFont) {
|
||||
QFontMetrics fm(subRule.font.resolve(mi->font));
|
||||
const QRect r = fm.boundingRect(QRect(), Qt::TextSingleLine | Qt::TextShowMnemonic, mi->text);
|
||||
sz = sz.expandedTo(r.size());
|
||||
}
|
||||
if (mi->text.contains(u'\t'))
|
||||
sz.rwidth() += 12; //as in QCommonStyle
|
||||
if (!mi->icon.isNull()) {
|
||||
@ -5470,11 +5475,6 @@ QSize QStyleSheetStyle::sizeFromContents(ContentsType ct, const QStyleOption *op
|
||||
} else {
|
||||
sz.rwidth() += mi->maxIconWidth;
|
||||
}
|
||||
if (subRule.hasFont) {
|
||||
QFontMetrics fm(subRule.font.resolve(mi->font));
|
||||
const QRect r = fm.boundingRect(QRect(), Qt::TextSingleLine | Qt::TextShowMnemonic, mi->text);
|
||||
sz = sz.expandedTo(r.size());
|
||||
}
|
||||
return subRule.boxSize(subRule.adjustSize(sz));
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user