summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/android/src
diff options
context:
space:
mode:
authorPaul Olav Tvete <paul.tvete@digia.com>2013-04-04 11:58:34 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-04-04 12:49:09 +0200
commitd9170e650c55015c2dbfb61315935322f821840b (patch)
treef1156a103ca62c8ecfe128657ee0d5389d080701 /src/plugins/platforms/android/src
parent87f890295bdd857571e5289687ffb5ff61d88ed9 (diff)
Android: Don't show '&' character in menus
Strip out shortcut indicator before showing the text. Task-number: QTBUG-30507 Change-Id: I8fa2ef8a2052f4c43d14b3babfd5aca0a08e29d5 Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@digia.com>
Diffstat (limited to 'src/plugins/platforms/android/src')
-rw-r--r--src/plugins/platforms/android/src/androidjnimenu.cpp29
1 files changed, 23 insertions, 6 deletions
diff --git a/src/plugins/platforms/android/src/androidjnimenu.cpp b/src/plugins/platforms/android/src/androidjnimenu.cpp
index e49af0fdac..bb180347c1 100644
--- a/src/plugins/platforms/android/src/androidjnimenu.cpp
+++ b/src/plugins/platforms/android/src/androidjnimenu.cpp
@@ -177,6 +177,20 @@ namespace QtAndroidMenu
resetMenuBar();
}
+ static QString removeAmpersandEscapes(QString s)
+ {
+ int i = 0;
+ while (i < s.size()) {
+ ++i;
+ if (s.at(i-1) != QLatin1Char('&'))
+ continue;
+ if (i < s.size() && s.at(i) == QLatin1Char('&'))
+ ++i;
+ s.remove(i-1,1);
+ }
+ return s.trimmed();
+ }
+
static void fillMenuItem(JNIEnv *env, jobject menuItem, bool checkable, bool checked, bool enabled, bool visible, const QIcon &icon=QIcon())
{
env->CallObjectMethod(menuItem, setCheckableMenuItemMethodID, checkable);
@@ -204,8 +218,9 @@ namespace QtAndroidMenu
foreach (QAndroidPlatformMenuItem *item, platformMenu->menuItems()) {
if (item->isSeparator())
continue;
- jstring jtext = env->NewString(reinterpret_cast<const jchar *>(item->text().data()),
- item->text().length());
+ QString itemText = removeAmpersandEscapes(item->text());
+ jstring jtext = env->NewString(reinterpret_cast<const jchar *>(itemText.data()),
+ itemText.length());
jobject menuItem = env->CallObjectMethod(menu,
addMenuItemMethodID,
menuNoneValue,
@@ -239,8 +254,9 @@ namespace QtAndroidMenu
order = addAllMenuItemsToMenu(env, menu, static_cast<QAndroidPlatformMenu *>(menus.front()));
} else {
foreach (QAndroidPlatformMenu *item, menus) {
- jstring jtext = env->NewString(reinterpret_cast<const jchar *>(item->text().data()),
- item->text().length());
+ QString itemText = removeAmpersandEscapes(item->text());
+ jstring jtext = env->NewString(reinterpret_cast<const jchar *>(itemText.data()),
+ itemText.length());
jobject menuItem = env->CallObjectMethod(menu,
addMenuItemMethodID,
menuNoneValue,
@@ -299,8 +315,9 @@ namespace QtAndroidMenu
if (!visibleMenu)
return;
- jstring jtext = env->NewString(reinterpret_cast<const jchar*>(visibleMenu->text().data()),
- visibleMenu->text().length());
+ QString menuText = removeAmpersandEscapes(visibleMenu->text());
+ jstring jtext = env->NewString(reinterpret_cast<const jchar*>(menuText.data()),
+ menuText.length());
env->CallObjectMethod(menu, setHeaderTitleContextMenuMethodID, jtext);
env->DeleteLocalRef(jtext);
addAllMenuItemsToMenu(env, menu, visibleMenu);