summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/android/qandroidplatformmenubar.cpp
diff options
context:
space:
mode:
authorLiang Qi <liang.qi@qt.io>2019-08-12 13:23:11 +0200
committerLiang Qi <liang.qi@qt.io>2019-08-12 13:23:11 +0200
commit44c393f9b61797a240bfcbff1364ecdf7af41787 (patch)
tree94cca729399f5df23cf904f7bd866397d84aac7c /src/plugins/platforms/android/qandroidplatformmenubar.cpp
parentffc2d5722317fcab86865b11491d7bf7fef3e16d (diff)
parente66f247ccf345f1d303a92e53c21bb53d96c5af2 (diff)
Merge remote-tracking branch 'origin/5.12' into 5.13
Conflicts: config.tests/arch/write_info.pri Repair architecture config test for the WASM_OBJECT_FILES=1 build mode configure.pri tests/auto/gui/text/qtextdocument/tst_qtextdocument.cpp Done-With: Jörg Bornemann <joerg.bornemann@qt.io> Change-Id: I9e12088356eb5bc65b53211cd7a8e330cccd1bb4
Diffstat (limited to 'src/plugins/platforms/android/qandroidplatformmenubar.cpp')
-rw-r--r--src/plugins/platforms/android/qandroidplatformmenubar.cpp34
1 files changed, 32 insertions, 2 deletions
diff --git a/src/plugins/platforms/android/qandroidplatformmenubar.cpp b/src/plugins/platforms/android/qandroidplatformmenubar.cpp
index 35930f0628..7c6299b4b7 100644
--- a/src/plugins/platforms/android/qandroidplatformmenubar.cpp
+++ b/src/plugins/platforms/android/qandroidplatformmenubar.cpp
@@ -61,6 +61,7 @@ void QAndroidPlatformMenuBar::insertMenu(QPlatformMenu *menu, QPlatformMenu *bef
m_menus.end(),
static_cast<QAndroidPlatformMenu *>(before)),
static_cast<QAndroidPlatformMenu *>(menu));
+ m_menuHash.insert(m_nextMenuId++, menu);
}
void QAndroidPlatformMenuBar::removeMenu(QPlatformMenu *menu)
@@ -69,6 +70,30 @@ void QAndroidPlatformMenuBar::removeMenu(QPlatformMenu *menu)
m_menus.erase(std::find(m_menus.begin(),
m_menus.end(),
static_cast<QAndroidPlatformMenu *>(menu)));
+
+ int maxId = -1;
+ QHash<int, QPlatformMenu *>::iterator it = m_menuHash.begin();
+ while (it != m_menuHash.end()) {
+ if (it.value() == menu) {
+ it = m_menuHash.erase(it);
+ } else {
+ maxId = qMax(maxId, it.key());
+ ++it;
+ }
+ }
+
+ m_nextMenuId = maxId + 1;
+}
+
+int QAndroidPlatformMenuBar::menuId(QPlatformMenu *menu) const
+{
+ QHash<int, QPlatformMenu *>::const_iterator it;
+ for (it = m_menuHash.constBegin(); it != m_menuHash.constEnd(); ++it) {
+ if (it.value() == menu)
+ return it.key();
+ }
+
+ return -1;
}
void QAndroidPlatformMenuBar::syncMenu(QPlatformMenu *menu)
@@ -86,12 +111,17 @@ void QAndroidPlatformMenuBar::handleReparent(QWindow *newParentWindow)
QPlatformMenu *QAndroidPlatformMenuBar::menuForTag(quintptr tag) const
{
- for (QPlatformMenu *menu : m_menus) {
+ for (QAndroidPlatformMenu *menu : m_menus) {
if (menu->tag() == tag)
return menu;
}
- return 0;
+ return nullptr;
+}
+
+QPlatformMenu *QAndroidPlatformMenuBar::menuForId(int menuId) const
+{
+ return m_menuHash.value(menuId);
}
QWindow *QAndroidPlatformMenuBar::parentWindow() const