OSX MenuRole detection: remove ampersand before looking for keywords
The chosen shortcut should not affect the menu role. Task-number: QTBUG-40181 Change-Id: I5a77d0109999b2fb8d40f8c526e0bbcfa31ad5e7 Reviewed-by: Gabriel de Dietrich <gabriel.dedietrich@digia.com>
This commit is contained in:
parent
c2badc7423
commit
296142ba05
@ -76,27 +76,29 @@ QString qt_mac_applicationmenu_string(int type)
|
||||
|
||||
QPlatformMenuItem::MenuRole detectMenuRole(const QString &caption)
|
||||
{
|
||||
QString captionNoAmpersand(caption);
|
||||
captionNoAmpersand.remove(QChar('&'));
|
||||
const QString aboutString = QCoreApplication::translate("QCocoaMenuItem", "About");
|
||||
if (caption.startsWith(aboutString, Qt::CaseInsensitive) || caption.endsWith(aboutString, Qt::CaseInsensitive))
|
||||
if (captionNoAmpersand.startsWith(aboutString, Qt::CaseInsensitive) || caption.endsWith(aboutString, Qt::CaseInsensitive))
|
||||
return QPlatformMenuItem::AboutRole;
|
||||
if (caption.startsWith(QCoreApplication::translate("QCocoaMenuItem", "Config"), Qt::CaseInsensitive)
|
||||
|| caption.startsWith(QCoreApplication::translate("QCocoaMenuItem", "Preference"), Qt::CaseInsensitive)
|
||||
|| caption.startsWith(QCoreApplication::translate("QCocoaMenuItem", "Options"), Qt::CaseInsensitive)
|
||||
|| caption.startsWith(QCoreApplication::translate("QCocoaMenuItem", "Setting"), Qt::CaseInsensitive)
|
||||
|| caption.startsWith(QCoreApplication::translate("QCocoaMenuItem", "Setup"), Qt::CaseInsensitive)) {
|
||||
if (captionNoAmpersand.startsWith(QCoreApplication::translate("QCocoaMenuItem", "Config"), Qt::CaseInsensitive)
|
||||
|| captionNoAmpersand.startsWith(QCoreApplication::translate("QCocoaMenuItem", "Preference"), Qt::CaseInsensitive)
|
||||
|| captionNoAmpersand.startsWith(QCoreApplication::translate("QCocoaMenuItem", "Options"), Qt::CaseInsensitive)
|
||||
|| captionNoAmpersand.startsWith(QCoreApplication::translate("QCocoaMenuItem", "Setting"), Qt::CaseInsensitive)
|
||||
|| captionNoAmpersand.startsWith(QCoreApplication::translate("QCocoaMenuItem", "Setup"), Qt::CaseInsensitive)) {
|
||||
return QPlatformMenuItem::PreferencesRole;
|
||||
}
|
||||
if (caption.startsWith(QCoreApplication::translate("QCocoaMenuItem", "Quit"), Qt::CaseInsensitive)
|
||||
|| caption.startsWith(QCoreApplication::translate("QCocoaMenuItem", "Exit"), Qt::CaseInsensitive)) {
|
||||
if (captionNoAmpersand.startsWith(QCoreApplication::translate("QCocoaMenuItem", "Quit"), Qt::CaseInsensitive)
|
||||
|| captionNoAmpersand.startsWith(QCoreApplication::translate("QCocoaMenuItem", "Exit"), Qt::CaseInsensitive)) {
|
||||
return QPlatformMenuItem::QuitRole;
|
||||
}
|
||||
if (!caption.compare(QCoreApplication::translate("QCocoaMenuItem", "Cut"), Qt::CaseInsensitive))
|
||||
if (!captionNoAmpersand.compare(QCoreApplication::translate("QCocoaMenuItem", "Cut"), Qt::CaseInsensitive))
|
||||
return QPlatformMenuItem::CutRole;
|
||||
if (!caption.compare(QCoreApplication::translate("QCocoaMenuItem", "Copy"), Qt::CaseInsensitive))
|
||||
if (!captionNoAmpersand.compare(QCoreApplication::translate("QCocoaMenuItem", "Copy"), Qt::CaseInsensitive))
|
||||
return QPlatformMenuItem::CopyRole;
|
||||
if (!caption.compare(QCoreApplication::translate("QCocoaMenuItem", "Paste"), Qt::CaseInsensitive))
|
||||
if (!captionNoAmpersand.compare(QCoreApplication::translate("QCocoaMenuItem", "Paste"), Qt::CaseInsensitive))
|
||||
return QPlatformMenuItem::PasteRole;
|
||||
if (!caption.compare(QCoreApplication::translate("QCocoaMenuItem", "Select All"), Qt::CaseInsensitive))
|
||||
if (!captionNoAmpersand.compare(QCoreApplication::translate("QCocoaMenuItem", "Select All"), Qt::CaseInsensitive))
|
||||
return QPlatformMenuItem::SelectAllRole;
|
||||
return QPlatformMenuItem::NoRole;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user