From 8e3aacf61bcfe036acdba8fac4d07d68ff0f5ab3 Mon Sep 17 00:00:00 2001 From: Takumi Asaki Date: Fri, 25 Apr 2014 17:14:31 +0900 Subject: OS X: Remove mnemonics in parentheses MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In some language, mnemonics put after label text within parentheses. e.g. "&Open" is translated to "開く(&O)" in Japanese. OS X doesn't use mnemonics and '&' in label text is removed. Mnemonics in parentheses (and spaces before them) also should be removed. Change-Id: I88c0a1f60af7e148b3cf24a4e215ce807d62bce3 Reviewed-by: Tasuku Suzuki Reviewed-by: Oswald Buddenhagen --- src/widgets/styles/qmacstyle_mac.mm | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'src/widgets') diff --git a/src/widgets/styles/qmacstyle_mac.mm b/src/widgets/styles/qmacstyle_mac.mm index 531f538820..242a1c1c9e 100644 --- a/src/widgets/styles/qmacstyle_mac.mm +++ b/src/widgets/styles/qmacstyle_mac.mm @@ -494,6 +494,18 @@ static QString qt_mac_removeMnemonics(const QString &original) --l; if (l == 0) break; + } else if (original.at(currPos) == QLatin1Char('(') && l >= 4 && + original.at(currPos + 1) == QLatin1Char('&') && + original.at(currPos + 2) != QLatin1Char('&') && + original.at(currPos + 3) == QLatin1Char(')')) { + /* remove mnemonics its format is "\s*(&X)" */ + int n = 0; + while (finalDest > n && returnText.at(finalDest - n - 1).isSpace()) + ++n; + finalDest -= n; + currPos += 4; + l -= 4; + continue; } returnText[finalDest] = original.at(currPos); ++currPos; -- cgit v1.2.3