Qt 6.x
The Qt SDK
Loading...
Searching...
No Matches
QtAndroidMenu Namespace Reference

Functions

void resetMenuBar ()
 
void openOptionsMenu ()
 
void showContextMenu (QAndroidPlatformMenu *menu, const QRect &anchorRect, JNIEnv *env)
 
void hideContextMenu (QAndroidPlatformMenu *menu)
 
void syncMenu (QAndroidPlatformMenu *)
 
void androidPlatformMenuDestroyed (QAndroidPlatformMenu *menu)
 
void setMenuBar (QAndroidPlatformMenuBar *menuBar, QWindow *window)
 
void setActiveTopLevelWindow (QWindow *window)
 
void addMenuBar (QAndroidPlatformMenuBar *menuBar)
 
void removeMenuBar (QAndroidPlatformMenuBar *menuBar)
 
static QString removeAmpersandEscapes (QString s)
 
static void fillMenuItem (JNIEnv *env, jobject menuItem, bool checkable, bool checked, bool enabled, bool visible, const QIcon &icon=QIcon())
 
static int addAllMenuItemsToMenu (JNIEnv *env, jobject menu, QAndroidPlatformMenu *platformMenu)
 
static jboolean onPrepareOptionsMenu (JNIEnv *env, jobject, jobject menu)
 
static jboolean onOptionsItemSelected (JNIEnv *env, jobject, jint menuId, jboolean checked)
 
static void onOptionsMenuClosed (JNIEnv *, jobject, jobject)
 
static void onCreateContextMenu (JNIEnv *env, jobject, jobject menu)
 
static void fillContextMenu (JNIEnv *env, jobject, jobject menu)
 
static jboolean onContextItemSelected (JNIEnv *env, jobject, jint menuId, jboolean checked)
 
static void onContextMenuClosed (JNIEnv *env, jobject, jobject)
 
bool registerNatives (JNIEnv *env)
 

Variables

static QList< QAndroidPlatformMenu * > pendingContextMenus
 
static QAndroidPlatformMenuvisibleMenu = nullptr
 
static Q_CONSTINIT QRecursiveMutex visibleMenuMutex
 
static QSet< QAndroidPlatformMenuBar * > menuBars
 
static QAndroidPlatformMenuBarvisibleMenuBar = nullptr
 
static QWindowactiveTopLevelWindow = nullptr
 
static Q_CONSTINIT QRecursiveMutex menuBarMutex
 
static jmethodID openContextMenuMethodID = 0
 
static jmethodID clearMenuMethodID = 0
 
static jmethodID addMenuItemMethodID = 0
 
static int menuNoneValue = 0
 
static jmethodID setHeaderTitleContextMenuMethodID = 0
 
static jmethodID setCheckableMenuItemMethodID = 0
 
static jmethodID setCheckedMenuItemMethodID = 0
 
static jmethodID setEnabledMenuItemMethodID = 0
 
static jmethodID setIconMenuItemMethodID = 0
 
static jmethodID setVisibleMenuItemMethodID = 0
 
static JNINativeMethod methods []
 

Function Documentation

◆ addAllMenuItemsToMenu()

static int QtAndroidMenu::addAllMenuItemsToMenu ( JNIEnv *  env,
jobject  menu,
QAndroidPlatformMenu platformMenu 
)
static

Definition at line 183 of file androidjnimenu.cpp.

References addMenuItemMethodID, QString::data(), fillMenuItem(), QGraphicsItem::isEnabled(), QGraphicsItem::isVisible(), item, items, QString::length(), lock, menu, menuNoneValue, platformMenu, and removeAmpersandEscapes().

Referenced by fillContextMenu(), onCreateContextMenu(), and onPrepareOptionsMenu().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ addMenuBar()

void QtAndroidMenu::addMenuBar ( QAndroidPlatformMenuBar menuBar)

Definition at line 130 of file androidjnimenu.cpp.

References lock, menuBar, menuBarMutex, and menuBars.

Referenced by QAndroidPlatformMenuBar::QAndroidPlatformMenuBar().

+ Here is the caller graph for this function:

◆ androidPlatformMenuDestroyed()

void QtAndroidMenu::androidPlatformMenuDestroyed ( QAndroidPlatformMenu menu)

Definition at line 89 of file androidjnimenu.cpp.

References lock, menu, visibleMenu, and visibleMenuMutex.

Referenced by QAndroidPlatformMenu::~QAndroidPlatformMenu().

+ Here is the caller graph for this function:

◆ fillContextMenu()

static void QtAndroidMenu::fillContextMenu ( JNIEnv *  env,
jobject  ,
jobject  menu 
)
static

Definition at line 298 of file androidjnimenu.cpp.

References addAllMenuItemsToMenu(), clearMenuMethodID, lock, menu, visibleMenu, and visibleMenuMutex.

+ Here is the call graph for this function:

◆ fillMenuItem()

static void QtAndroidMenu::fillMenuItem ( JNIEnv *  env,
jobject  menuItem,
bool  checkable,
bool  checked,
bool  enabled,
bool  visible,
const QIcon icon = QIcon() 
)
static

Definition at line 160 of file androidjnimenu.cpp.

References QtAndroid::createBitmap(), QtAndroid::createBitmapDrawable(), QIcon::Disabled, icon, QIcon::isNull(), QIcon::Normal, QIcon::On, QIcon::pixmap(), qEnvironmentVariableIntValue(), qMax(), setCheckableMenuItemMethodID, setCheckedMenuItemMethodID, setEnabledMenuItemMethodID, setIconMenuItemMethodID, and setVisibleMenuItemMethodID.

Referenced by addAllMenuItemsToMenu(), and onPrepareOptionsMenu().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ hideContextMenu()

void QtAndroidMenu::hideContextMenu ( QAndroidPlatformMenu menu)

Definition at line 67 of file androidjnimenu.cpp.

References QtAndroid::applicationClass(), QList< T >::clear(), lock, menu, pendingContextMenus, QList< T >::removeOne(), visibleMenu, and visibleMenuMutex.

+ Here is the call graph for this function:

◆ onContextItemSelected()

static jboolean QtAndroidMenu::onContextItemSelected ( JNIEnv *  env,
jobject  ,
jint  menuId,
jboolean  checked 
)
static

Definition at line 308 of file androidjnimenu.cpp.

References QPlatformMenu::aboutToHide(), QMenu::aboutToHide(), QList< T >::clear(), QWidget::isVisible(), item, lock, menu, QAndroidPlatformMenu::menuItemForId(), pendingContextMenus, showContextMenu(), visibleMenu, and visibleMenuMutex.

+ Here is the call graph for this function:

◆ onContextMenuClosed()

static void QtAndroidMenu::onContextMenuClosed ( JNIEnv *  env,
jobject  ,
jobject   
)
static

Definition at line 331 of file androidjnimenu.cpp.

References QPlatformMenu::aboutToHide(), QList< T >::empty(), lock, pendingContextMenus, showContextMenu(), QList< T >::takeLast(), visibleMenu, and visibleMenuMutex.

+ Here is the call graph for this function:

◆ onCreateContextMenu()

static void QtAndroidMenu::onCreateContextMenu ( JNIEnv *  env,
jobject  ,
jobject  menu 
)
static

Definition at line 283 of file androidjnimenu.cpp.

References addAllMenuItemsToMenu(), clearMenuMethodID, QString::data(), QString::length(), lock, menu, removeAmpersandEscapes(), setHeaderTitleContextMenuMethodID, QAndroidPlatformMenu::text(), visibleMenu, and visibleMenuMutex.

+ Here is the call graph for this function:

◆ onOptionsItemSelected()

static jboolean QtAndroidMenu::onOptionsItemSelected ( JNIEnv *  env,
jobject  ,
jint  menuId,
jboolean  checked 
)
static

Definition at line 252 of file androidjnimenu.cpp.

References QList< T >::front(), item, lock, menu, menuBarMutex, QAndroidPlatformMenuBar::menuForId(), QAndroidPlatformMenu::menuItemForId(), QAndroidPlatformMenuBar::menus(), showContextMenu(), QList< T >::size(), and visibleMenuBar.

+ Here is the call graph for this function:

◆ onOptionsMenuClosed()

static void QtAndroidMenu::onOptionsMenuClosed ( JNIEnv *  ,
jobject  ,
jobject   
)
static

Definition at line 279 of file androidjnimenu.cpp.

◆ onPrepareOptionsMenu()

static jboolean QtAndroidMenu::onPrepareOptionsMenu ( JNIEnv *  env,
jobject  ,
jobject  menu 
)
static

◆ openOptionsMenu()

void QtAndroidMenu::openOptionsMenu ( )

Definition at line 52 of file androidjnimenu.cpp.

References QtAndroid::applicationClass().

Referenced by QAndroidPlatformTheme::showPlatformMenuBar().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ registerNatives()

bool QtAndroidMenu::registerNatives ( JNIEnv *  env)

Definition at line 381 of file androidjnimenu.cpp.

References addMenuItemMethodID, QtAndroid::applicationClass(), clearMenuMethodID, FIND_AND_CHECK_CLASS, GET_AND_CHECK_METHOD, GET_AND_CHECK_STATIC_FIELD, GET_AND_CHECK_STATIC_METHOD, menuNoneValue, methods, openContextMenuMethodID, setCheckableMenuItemMethodID, setCheckedMenuItemMethodID, setEnabledMenuItemMethodID, setHeaderTitleContextMenuMethodID, setIconMenuItemMethodID, and setVisibleMenuItemMethodID.

Referenced by JNI_OnLoad().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ removeAmpersandEscapes()

static QString QtAndroidMenu::removeAmpersandEscapes ( QString  s)
static

Definition at line 146 of file androidjnimenu.cpp.

References i.

Referenced by addAllMenuItemsToMenu(), onCreateContextMenu(), and onPrepareOptionsMenu().

+ Here is the caller graph for this function:

◆ removeMenuBar()

void QtAndroidMenu::removeMenuBar ( QAndroidPlatformMenuBar menuBar)

Definition at line 136 of file androidjnimenu.cpp.

References lock, menuBar, menuBarMutex, menuBars, resetMenuBar(), and visibleMenuBar.

Referenced by QAndroidPlatformMenuBar::~QAndroidPlatformMenuBar().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ resetMenuBar()

void QtAndroidMenu::resetMenuBar ( )

Definition at line 47 of file androidjnimenu.cpp.

References QtAndroid::applicationClass().

Referenced by removeMenuBar(), setActiveTopLevelWindow(), and setMenuBar().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setActiveTopLevelWindow()

void QtAndroidMenu::setActiveTopLevelWindow ( QWindow window)

Definition at line 104 of file androidjnimenu.cpp.

References activeTopLevelWindow, Qt::Desktop, Qt::Dialog, lock, menuBar, menuBarMutex, menuBars, Qt::Popup, resetMenuBar(), Qt::Sheet, visibleMenuBar, Qt::Window, and window().

Referenced by QAndroidPlatformScreen::topWindowChanged().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setMenuBar()

void QtAndroidMenu::setMenuBar ( QAndroidPlatformMenuBar menuBar,
QWindow window 
)

Definition at line 96 of file androidjnimenu.cpp.

References activeTopLevelWindow, menuBar, resetMenuBar(), visibleMenuBar, and window().

Referenced by QAndroidPlatformMenuBar::handleReparent().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ showContextMenu()

void QtAndroidMenu::showContextMenu ( QAndroidPlatformMenu menu,
const QRect anchorRect,
JNIEnv *  env 
)

Definition at line 57 of file androidjnimenu.cpp.

References QMenu::aboutToShow(), QList< T >::append(), QtAndroid::applicationClass(), QRect::height(), lock, menu, openContextMenuMethodID, pendingContextMenus, visibleMenu, visibleMenuMutex, QRect::width(), QRect::x(), and QRect::y().

Referenced by onContextItemSelected(), onContextMenuClosed(), onOptionsItemSelected(), and QAndroidPlatformMenu::showPopup().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ syncMenu()

void QtAndroidMenu::syncMenu ( QAndroidPlatformMenu )

Definition at line 79 of file androidjnimenu.cpp.

Referenced by QAndroidPlatformMenuBar::syncMenu(), and QAndroidPlatformMenu::syncMenuItem().

+ Here is the caller graph for this function:

Variable Documentation

◆ activeTopLevelWindow

QWindow* QtAndroidMenu::activeTopLevelWindow = nullptr
static

Definition at line 31 of file androidjnimenu.cpp.

Referenced by setActiveTopLevelWindow(), and setMenuBar().

◆ addMenuItemMethodID

jmethodID QtAndroidMenu::addMenuItemMethodID = 0
static

Definition at line 37 of file androidjnimenu.cpp.

Referenced by addAllMenuItemsToMenu(), onPrepareOptionsMenu(), and registerNatives().

◆ clearMenuMethodID

jmethodID QtAndroidMenu::clearMenuMethodID = 0
static

◆ menuBarMutex

Q_CONSTINIT QRecursiveMutex QtAndroidMenu::menuBarMutex
static

◆ menuBars

QSet<QAndroidPlatformMenuBar *> QtAndroidMenu::menuBars
static

Definition at line 29 of file androidjnimenu.cpp.

Referenced by addMenuBar(), removeMenuBar(), and setActiveTopLevelWindow().

◆ menuNoneValue

int QtAndroidMenu::menuNoneValue = 0
static

Definition at line 38 of file androidjnimenu.cpp.

Referenced by addAllMenuItemsToMenu(), onPrepareOptionsMenu(), and registerNatives().

◆ methods

JNINativeMethod QtAndroidMenu::methods[]
static
Initial value:
= {
{"onPrepareOptionsMenu", "(Landroid/view/Menu;)Z", (void *)onPrepareOptionsMenu},
{"onOptionsItemSelected", "(IZ)Z", (void *)onOptionsItemSelected},
{"onOptionsMenuClosed", "(Landroid/view/Menu;)V", (void*)onOptionsMenuClosed},
{"onCreateContextMenu", "(Landroid/view/ContextMenu;)V", (void *)onCreateContextMenu},
{"fillContextMenu", "(Landroid/view/Menu;)V", (void *)fillContextMenu},
{"onContextItemSelected", "(IZ)Z", (void *)onContextItemSelected},
{"onContextMenuClosed", "(Landroid/view/Menu;)V", (void*)onContextMenuClosed},
}

Definition at line 343 of file androidjnimenu.cpp.

Referenced by registerNatives().

◆ openContextMenuMethodID

jmethodID QtAndroidMenu::openContextMenuMethodID = 0
static

Definition at line 34 of file androidjnimenu.cpp.

Referenced by registerNatives(), and showContextMenu().

◆ pendingContextMenus

QList<QAndroidPlatformMenu *> QtAndroidMenu::pendingContextMenus
static

◆ setCheckableMenuItemMethodID

jmethodID QtAndroidMenu::setCheckableMenuItemMethodID = 0
static

Definition at line 41 of file androidjnimenu.cpp.

Referenced by fillMenuItem(), and registerNatives().

◆ setCheckedMenuItemMethodID

jmethodID QtAndroidMenu::setCheckedMenuItemMethodID = 0
static

Definition at line 42 of file androidjnimenu.cpp.

Referenced by fillMenuItem(), and registerNatives().

◆ setEnabledMenuItemMethodID

jmethodID QtAndroidMenu::setEnabledMenuItemMethodID = 0
static

Definition at line 43 of file androidjnimenu.cpp.

Referenced by fillMenuItem(), and registerNatives().

◆ setHeaderTitleContextMenuMethodID

jmethodID QtAndroidMenu::setHeaderTitleContextMenuMethodID = 0
static

Definition at line 39 of file androidjnimenu.cpp.

Referenced by onCreateContextMenu(), and registerNatives().

◆ setIconMenuItemMethodID

jmethodID QtAndroidMenu::setIconMenuItemMethodID = 0
static

Definition at line 44 of file androidjnimenu.cpp.

Referenced by fillMenuItem(), and registerNatives().

◆ setVisibleMenuItemMethodID

jmethodID QtAndroidMenu::setVisibleMenuItemMethodID = 0
static

Definition at line 45 of file androidjnimenu.cpp.

Referenced by fillMenuItem(), and registerNatives().

◆ visibleMenu

◆ visibleMenuBar

QAndroidPlatformMenuBar* QtAndroidMenu::visibleMenuBar = nullptr
static

◆ visibleMenuMutex