summaryrefslogtreecommitdiffstats
path: root/src/gui/kernel
diff options
context:
space:
mode:
authorTarja Sundqvist <tarja.sundqvist@qt.io>2024-05-08 08:17:16 +0300
committerTarja Sundqvist <tarja.sundqvist@qt.io>2024-05-08 08:17:16 +0300
commit86c62c8f6088ec148512457cb7e964661ba643b0 (patch)
tree15f82dc1436a5dd229fed729e15afb18bfafde62 /src/gui/kernel
parent4e158f6bfa7d0747d8da70b3b15a44b52e35bb8a (diff)
parent5ca8cfaa56043163997be2a6188812a8cd1c289c (diff)
Merge remote-tracking branch 'origin/tqtc/lts-5.15.14' into tqtc/lts-5.15-opensourcev5.15.14-lts-lgpl5.15
Diffstat (limited to 'src/gui/kernel')
-rw-r--r--src/gui/kernel/qplatformtheme.cpp22
1 files changed, 16 insertions, 6 deletions
diff --git a/src/gui/kernel/qplatformtheme.cpp b/src/gui/kernel/qplatformtheme.cpp
index 71521c0339..a11388fdb6 100644
--- a/src/gui/kernel/qplatformtheme.cpp
+++ b/src/gui/kernel/qplatformtheme.cpp
@@ -748,7 +748,20 @@ QString QPlatformTheme::defaultStandardButtonText(int button)
QString QPlatformTheme::removeMnemonics(const QString &original)
{
- QString returnText(original.size(), 0);
+ const auto mnemonicInParentheses = [](QStringView text) {
+ /* Format of mnemonics to remove is /\(&[^&]\)/ but accept full-width
+ forms of ( and ) as equivalent, for cross-platform compatibility with
+ MS (and consequent behavior of translators, see QTBUG-110829).
+ */
+ Q_ASSERT(text.size() == 4); // Caller's responsibility.
+ const QChar wideOpen(0xff08), wideClose(0xff09), ampersand(QLatin1Char('&'));
+ if (!text.startsWith(QLatin1Char('(')) && !text.startsWith(wideOpen))
+ return false;
+ if (text[1] != ampersand || text[2] == ampersand)
+ return false;
+ return text.endsWith(QLatin1Char(')')) || text.endsWith(wideClose);
+ };
+ QString returnText(original.size(), QLatin1Char('\0'));
int finalDest = 0;
int currPos = 0;
int l = original.length();
@@ -758,11 +771,8 @@ QString QPlatformTheme::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)" */
+ } else if (l >= 4 && mnemonicInParentheses(QStringView{original}.mid(currPos, 4))) {
+ // Also strip any leading space before the mnemonic:
int n = 0;
while (finalDest > n && returnText.at(finalDest - n - 1).isSpace())
++n;