diff options
author | Gabriel de Dietrich <gabriel.dedietrich@qt.io> | 2018-04-20 11:16:17 -0700 |
---|---|---|
committer | Gabriel de Dietrich <gabriel.dedietrich@qt.io> | 2018-04-26 17:51:18 +0000 |
commit | 8412009de62ff0c9540290b6fb0b8d1f470b2cb8 (patch) | |
tree | f3146c8c153727b23161bd1693619387bc51214e /src/plugins/platforms/cocoa/messages.cpp | |
parent | 25d5c8fe5d06ab0a1161c36ddc021edc2ed76197 (diff) |
Cocoa Menus: Refactor QCocoaMenuItem::sync()
And move some logic into detectMenuRole(), where it belongs.
This refactoring will enable fixes for the issues below.
Change-Id: Id03bb5c26d7dd0bb3b94f01e69935e1f3321bb95
Task-number: QTBUG-17291
Task-number: QTBUG-30812
Task-number: QTBUG-38705
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
Diffstat (limited to 'src/plugins/platforms/cocoa/messages.cpp')
-rw-r--r-- | src/plugins/platforms/cocoa/messages.cpp | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/plugins/platforms/cocoa/messages.cpp b/src/plugins/platforms/cocoa/messages.cpp index c7e7f82bae..06e3dd454e 100644 --- a/src/plugins/platforms/cocoa/messages.cpp +++ b/src/plugins/platforms/cocoa/messages.cpp @@ -39,7 +39,8 @@ #include "messages.h" -#include <QCoreApplication> +#include <QtCore/qcoreapplication.h> +#include <QtCore/qregularexpression.h> // Translatable messages should go into this .cpp file for them to be picked up by lupdate. @@ -77,8 +78,13 @@ QPlatformMenuItem::MenuRole detectMenuRole(const QString &caption) QString captionNoAmpersand(caption); captionNoAmpersand.remove(QLatin1Char('&')); const QString aboutString = QCoreApplication::translate("QCocoaMenuItem", "About"); - if (captionNoAmpersand.startsWith(aboutString, Qt::CaseInsensitive) || caption.endsWith(aboutString, Qt::CaseInsensitive)) + if (captionNoAmpersand.startsWith(aboutString, Qt::CaseInsensitive) + || captionNoAmpersand.endsWith(aboutString, Qt::CaseInsensitive)) { + static const QRegularExpression qtRegExp(QLatin1String("qt$"), QRegularExpression::CaseInsensitiveOption); + if (captionNoAmpersand.contains(qtRegExp)) + return QPlatformMenuItem::AboutQtRole; return QPlatformMenuItem::AboutRole; + } 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) |