Commit 5760545e authored by Timur Pocheptsov's avatar Timur Pocheptsov
Browse files

QCocoaMenuItem: ignore font hints


Native applications do not use custom fonts in menus, so we should
avoid it - our own example app 'menus' demonstrates the problem.
To quote Gabriel: Although the Mac HIG don't say that you shouldn't, and there's
even a API to do it (which we're obviously not using properly), the truth
is that nobody does it. Simply put, it looks wrong on Mac (although it's
arguable whether it looks good or bad regardless of the platform).

Task-number: QTBUG-29654
Change-Id: Iffd08ad63d419164102b2e738cdf1ebda1967a05
Reviewed-by: default avatarTor Arne Vestbø <tor.arne.vestbo@qt.io>
Showing with 2 additions and 17 deletions
......@@ -119,7 +119,6 @@ private:
QString m_text;
QIcon m_icon;
QPointer<QCocoaMenu> m_menu;
QFont m_font;
MenuRole m_role;
MenuRole m_detectedRole;
#ifndef QT_NO_SHORTCUT
......
......@@ -173,7 +173,7 @@ void QCocoaMenuItem::setIsSeparator(bool isSeparator)
void QCocoaMenuItem::setFont(const QFont &font)
{
m_font = font;
Q_UNUSED(font)
}
void QCocoaMenuItem::setRole(MenuRole role)
......@@ -319,21 +319,7 @@ NSMenuItem *QCocoaMenuItem::sync()
text += QLatin1String(" (") + accel.toString(QKeySequence::NativeText) + QLatin1String(")");
#endif
QString finalString = QPlatformTheme::removeMnemonics(text);
bool useAttributedTitle = false;
// Cocoa Font and title
if (m_font.resolve()) {
NSFont *customMenuFont = [NSFont fontWithName:m_font.family().toNSString()
size:m_font.pointSize()];
if (customMenuFont) {
NSAttributedString *str = [[[NSAttributedString alloc] initWithString:finalString.toNSString()
attributes:@{NSFontAttributeName: customMenuFont}] autorelease];
m_native.attributedTitle = str;
useAttributedTitle = true;
}
}
if (!useAttributedTitle)
m_native.title = finalString.toNSString();
m_native.title = QPlatformTheme::removeMnemonics(text).toNSString();
#ifndef QT_NO_SHORTCUT
if (accel.count() == 1) {
......
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