Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qandroidplatformmenubar.cpp
Go to the documentation of this file.
1// Copyright (C) 2012 BogDan Vatra <bogdan@kde.org>
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3// Qt-Security score:significant reason:default
4
8
10
11QAndroidPlatformMenuBar::QAndroidPlatformMenuBar()
12{
13 m_parentWindow = 0;
14 QtAndroidMenu::addMenuBar(this);
15}
16
21
22void QAndroidPlatformMenuBar::insertMenu(QPlatformMenu *menu, QPlatformMenu *before)
23{
24 {
25 QMutexLocker lock(&m_menusListMutex);
26 m_menus.insert(std::find(m_menus.begin(),
27 m_menus.end(),
28 static_cast<QAndroidPlatformMenu *>(before)),
29 static_cast<QAndroidPlatformMenu *>(menu));
30 m_menuHash.insert(m_nextMenuId++, menu);
31 }
33}
34
35void QAndroidPlatformMenuBar::removeMenu(QPlatformMenu *menu)
36{
37 {
38 QMutexLocker lock(&m_menusListMutex);
39 m_menus.erase(std::find(m_menus.begin(),
40 m_menus.end(),
41 static_cast<QAndroidPlatformMenu *>(menu)));
42
43 int maxId = -1;
44 QHash<int, QPlatformMenu *>::iterator it = m_menuHash.begin();
45 while (it != m_menuHash.end()) {
46 if (it.value() == menu) {
47 it = m_menuHash.erase(it);
48 } else {
49 maxId = qMax(maxId, it.key());
50 ++it;
51 }
52 }
53
54 m_nextMenuId = maxId + 1;
55 }
57}
58
59int QAndroidPlatformMenuBar::menuId(QPlatformMenu *menu) const
60{
61 QHash<int, QPlatformMenu *>::const_iterator it;
62 for (it = m_menuHash.constBegin(); it != m_menuHash.constEnd(); ++it) {
63 if (it.value() == menu)
64 return it.key();
65 }
66
67 return -1;
68}
69
70void QAndroidPlatformMenuBar::syncMenu(QPlatformMenu *menu)
71{
73}
74
75void QAndroidPlatformMenuBar::handleReparent(QWindow *newParentWindow)
76{
77 if (m_parentWindow == newParentWindow)
78 return;
79 m_parentWindow = newParentWindow;
80 QtAndroidMenu::setMenuBar(this, newParentWindow);
81}
82
84{
85 for (QAndroidPlatformMenu *menu : m_menus) {
86 if (menu->tag() == tag)
87 return menu;
88 }
89
90 return nullptr;
91}
92
94{
95 return m_menuHash.value(menuId);
96}
97
99{
100 return m_parentWindow;
101}
102
107
109{
110 return &m_menusListMutex;
111}
112
113QT_END_NAMESPACE
PlatformMenusType menus() const
QWindow * parentWindow() const override
void insertMenu(QPlatformMenu *menu, QPlatformMenu *before) override
void handleReparent(QWindow *newParentWindow) override
void syncMenu(QPlatformMenu *menu) override
int menuId(QPlatformMenu *menu) const
QPlatformMenu * menuForId(int menuId) const
QPlatformMenu * menuForTag(quintptr tag) const override
void removeMenu(QPlatformMenu *menu) override
QList< QAndroidPlatformMenu * > PlatformMenusType
\inmodule QtCore
Definition qmutex.h:347
Combined button and popup list for selecting options.
void menuBarChanged(QAndroidPlatformMenuBar *menuBar)
void syncMenu(QAndroidPlatformMenu *menu)
void removeMenuBar(QAndroidPlatformMenuBar *menuBar)
void setMenuBar(QAndroidPlatformMenuBar *menuBar, QWindow *window)