Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
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
6#include "androidjnimenu.h"
7
9
15
20
22{
23 QMutexLocker lock(&m_menusListMutex);
24 m_menus.insert(std::find(m_menus.begin(),
25 m_menus.end(),
26 static_cast<QAndroidPlatformMenu *>(before)),
27 static_cast<QAndroidPlatformMenu *>(menu));
28 m_menuHash.insert(m_nextMenuId++, menu);
29}
30
32{
33 QMutexLocker lock(&m_menusListMutex);
34 m_menus.erase(std::find(m_menus.begin(),
35 m_menus.end(),
36 static_cast<QAndroidPlatformMenu *>(menu)));
37
38 int maxId = -1;
40 while (it != m_menuHash.end()) {
41 if (it.value() == menu) {
42 it = m_menuHash.erase(it);
43 } else {
44 maxId = qMax(maxId, it.key());
45 ++it;
46 }
47 }
48
49 m_nextMenuId = maxId + 1;
50}
51
53{
55 for (it = m_menuHash.constBegin(); it != m_menuHash.constEnd(); ++it) {
56 if (it.value() == menu)
57 return it.key();
58 }
59
60 return -1;
61}
62
67
69{
70 if (m_parentWindow == newParentWindow)
71 return;
72 m_parentWindow = newParentWindow;
73 QtAndroidMenu::setMenuBar(this, newParentWindow);
74}
75
77{
78 for (QAndroidPlatformMenu *menu : m_menus) {
79 if (menu->tag() == tag)
80 return menu;
81 }
82
83 return nullptr;
84}
85
87{
88 return m_menuHash.value(menuId);
89}
90
92{
93 return m_parentWindow;
94}
95
100
102{
103 return &m_menusListMutex;
104}
105
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
\inmodule QtCore
Definition qhash.h:1145
\inmodule QtCore
Definition qhash.h:1103
iterator begin()
Returns an \l{STL-style iterators}{STL-style iterator} pointing to the first item in the hash.
Definition qhash.h:1212
const_iterator constEnd() const noexcept
Returns a const \l{STL-style iterators}{STL-style iterator} pointing to the imaginary item after the ...
Definition qhash.h:1219
const_iterator constBegin() const noexcept
Returns a const \l{STL-style iterators}{STL-style iterator} pointing to the first item in the hash.
Definition qhash.h:1215
iterator erase(const_iterator it)
Definition qhash.h:1233
T value(const Key &key) const noexcept
Definition qhash.h:1054
iterator end() noexcept
Returns an \l{STL-style iterators}{STL-style iterator} pointing to the imaginary item after the last ...
Definition qhash.h:1216
iterator insert(const Key &key, const T &value)
Inserts a new item with the key and a value of value.
Definition qhash.h:1303
iterator erase(const_iterator begin, const_iterator end)
Definition qlist.h:889
iterator insert(qsizetype i, parameter_type t)
Definition qlist.h:488
iterator end()
Definition qlist.h:626
iterator begin()
Definition qlist.h:625
\inmodule QtCore
Definition qmutex.h:313
\inmodule QtCore
Definition qmutex.h:281
\inmodule QtGui
Definition qwindow.h:63
QSet< QString >::iterator it
Combined button and popup list for selecting options.
void removeMenuBar(QAndroidPlatformMenuBar *menuBar)
void syncMenu(QAndroidPlatformMenu *)
void addMenuBar(QAndroidPlatformMenuBar *menuBar)
void setMenuBar(QAndroidPlatformMenuBar *menuBar, QWindow *window)
AudioChannelLayoutTag tag
constexpr const T & qMax(const T &a, const T &b)
Definition qminmax.h:42
size_t quintptr
Definition qtypes.h:167
QReadWriteLock lock
[0]
QMenu menu
[5]