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 QMutexLocker lock(&m_menusListMutex);
25 m_menus.insert(std::find(m_menus.begin(),
26 m_menus.end(),
27 static_cast<QAndroidPlatformMenu *>(before)),
28 static_cast<QAndroidPlatformMenu *>(menu));
29 m_menuHash.insert(m_nextMenuId++, menu);
30}
31
32void QAndroidPlatformMenuBar::removeMenu(QPlatformMenu *menu)
33{
34 QMutexLocker lock(&m_menusListMutex);
35 m_menus.erase(std::find(m_menus.begin(),
36 m_menus.end(),
37 static_cast<QAndroidPlatformMenu *>(menu)));
38
39 int maxId = -1;
40 QHash<int, QPlatformMenu *>::iterator it = m_menuHash.begin();
41 while (it != m_menuHash.end()) {
42 if (it.value() == menu) {
43 it = m_menuHash.erase(it);
44 } else {
45 maxId = qMax(maxId, it.key());
46 ++it;
47 }
48 }
49
50 m_nextMenuId = maxId + 1;
51}
52
53int QAndroidPlatformMenuBar::menuId(QPlatformMenu *menu) const
54{
55 QHash<int, QPlatformMenu *>::const_iterator it;
56 for (it = m_menuHash.constBegin(); it != m_menuHash.constEnd(); ++it) {
57 if (it.value() == menu)
58 return it.key();
59 }
60
61 return -1;
62}
63
64void QAndroidPlatformMenuBar::syncMenu(QPlatformMenu *menu)
65{
67}
68
69void QAndroidPlatformMenuBar::handleReparent(QWindow *newParentWindow)
70{
71 if (m_parentWindow == newParentWindow)
72 return;
73 m_parentWindow = newParentWindow;
74 QtAndroidMenu::setMenuBar(this, newParentWindow);
75}
76
78{
79 for (QAndroidPlatformMenu *menu : m_menus) {
80 if (menu->tag() == tag)
81 return menu;
82 }
83
84 return nullptr;
85}
86
88{
89 return m_menuHash.value(menuId);
90}
91
93{
94 return m_parentWindow;
95}
96
101
103{
104 return &m_menusListMutex;
105}
106
107QT_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:346
Combined button and popup list for selecting options.
void removeMenuBar(QAndroidPlatformMenuBar *menuBar)
void syncMenu(QAndroidPlatformMenu *)
void setMenuBar(QAndroidPlatformMenuBar *menuBar, QWindow *window)