From c19cb39ddbfd93802bfe61ecaa4f737a1bd1c1bb Mon Sep 17 00:00:00 2001 From: Fabien Freling Date: Fri, 26 Mar 2010 12:34:54 +0100 Subject: Fix the bug where the ampersand symbol would be discarded. We are now checking that the QAction is not related to the About or Quit button on Mac OS X Task-number: QTBUG-7540 Reviewed-by: Morten Sorvig --- src/gui/styles/qmacstyle_mac.mm | 4 ++-- src/gui/widgets/qmenu_mac.mm | 6 +++++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/gui/styles/qmacstyle_mac.mm b/src/gui/styles/qmacstyle_mac.mm index 7097291..074dd89 100644 --- a/src/gui/styles/qmacstyle_mac.mm +++ b/src/gui/styles/qmacstyle_mac.mm @@ -434,13 +434,13 @@ static inline bool isTreeView(const QWidget *widget) QString qt_mac_removeMnemonics(const QString &original) { - // copied from qt_format_text (to be bug-for-bug compatible). QString returnText(original.size(), 0); int finalDest = 0; int currPos = 0; int l = original.length(); while (l) { - if (original.at(currPos) == QLatin1Char('&')) { + if (original.at(currPos) == QLatin1Char('&') + && (l == 1 || original.at(currPos + 1) != QLatin1Char('&'))) { ++currPos; --l; if (l == 0) diff --git a/src/gui/widgets/qmenu_mac.mm b/src/gui/widgets/qmenu_mac.mm index 9a14ce6..6a0eb53 100644 --- a/src/gui/widgets/qmenu_mac.mm +++ b/src/gui/widgets/qmenu_mac.mm @@ -1391,7 +1391,11 @@ QMenuPrivate::QMacMenuPrivate::syncAction(QMacMenuAction *action) } else { [item setTitle: qt_mac_QStringToNSString(finalString)]; } - [item setTitle:qt_mac_QStringToNSString(qt_mac_removeMnemonics(text))]; + + if (action->action->menuRole() == QAction::AboutRole || action->action->menuRole() == QAction::QuitRole) + [item setTitle:qt_mac_QStringToNSString(text)]; + else + [item setTitle:qt_mac_QStringToNSString(qt_mac_removeMnemonics(text))]; // Cocoa Enabled [item setEnabled: action->action->isEnabled()]; -- cgit v0.12