16#include <QtCore/private/qjnihelpers_p.h>
17#include <QtCore/QJniObject>
29 static QSet<QAndroidPlatformMenuBar *>
menuBars;
63 anchorRect.
x(), anchorRect.
y(),
111 if (isNonRegularWindow)
149 while (
i <
s.size()) {
151 if (
s.at(
i - 1) != u
'&')
153 if (
i <
s.size() &&
s.at(
i) == u
'&')
174 env->DeleteLocalRef(env->CallObjectMethod(menuItem,
188 if (
item->isSeparator())
191 jstring jtext = env->NewString(
reinterpret_cast<const jchar *
>(itemText.
data()),
194 jobject menuItem = env->CallObjectMethod(
menu,
200 env->DeleteLocalRef(jtext);
208 env->DeleteLocalRef(menuItem);
226 if (menus.
size() == 1) {
231 jstring jtext = env->NewString(
reinterpret_cast<const jchar *
>(itemText.
data()),
234 jobject menuItem = env->CallObjectMethod(
menu,
240 env->DeleteLocalRef(jtext);
251 return order ? JNI_TRUE : JNI_FALSE;
264 if (menus.
size() == 1) {
270 if (
item->isCheckable())
271 item->setChecked(checked);
301 jstring jtext = env->NewString(
reinterpret_cast<const jchar*
>(menuText.data()),
304 env->DeleteLocalRef(jtext);
330 if (
item->isCheckable())
331 item->setChecked(checked);
366 {
"fillContextMenu",
"(Landroid/view/Menu;)V", (
void *)
fillContextMenu},
371#define FIND_AND_CHECK_CLASS(CLASS_NAME) \
372 clazz = env->FindClass(CLASS_NAME); \
374 __android_log_print(ANDROID_LOG_FATAL, qtTagText(), classErrorMsgFmt(), CLASS_NAME); \
378#define GET_AND_CHECK_METHOD(VAR, CLASS, METHOD_NAME, METHOD_SIGNATURE) \
379 VAR = env->GetMethodID(CLASS, METHOD_NAME, METHOD_SIGNATURE); \
381 __android_log_print(ANDROID_LOG_FATAL, qtTagText(), methodErrorMsgFmt(), METHOD_NAME, METHOD_SIGNATURE); \
385#define GET_AND_CHECK_STATIC_METHOD(VAR, CLASS, METHOD_NAME, METHOD_SIGNATURE) \
386 VAR = env->GetStaticMethodID(CLASS, METHOD_NAME, METHOD_SIGNATURE); \
388 __android_log_print(ANDROID_LOG_FATAL, qtTagText(), methodErrorMsgFmt(), METHOD_NAME, METHOD_SIGNATURE); \
392#define GET_AND_CHECK_STATIC_FIELD(VAR, CLASS, FIELD_NAME, FIELD_SIGNATURE) \
393 VAR = env->GetStaticFieldID(CLASS, FIELD_NAME, FIELD_SIGNATURE); \
395 __android_log_print(ANDROID_LOG_FATAL, qtTagText(), methodErrorMsgFmt(), FIELD_NAME, FIELD_SIGNATURE); \
404 __android_log_print(ANDROID_LOG_FATAL,
"Qt",
"RegisterNatives failed");
412 jfieldID menuNoneFiledId;
414 menuNoneValue = env->GetStaticIntField(clazz, menuNoneFiledId);
#define GET_AND_CHECK_STATIC_FIELD(VAR, CLASS, FIELD_NAME, FIELD_SIGNATURE)
#define FIND_AND_CHECK_CLASS(CLASS_NAME)
#define GET_AND_CHECK_METHOD(VAR, CLASS, METHOD_NAME, METHOD_SIGNATURE)
bool isEnabled() const
Returns true if the item is enabled; otherwise, false is returned.
bool isVisible() const
Returns true if the item is visible; otherwise, false is returned.
The QIcon class provides scalable icons in different modes and states.
bool isNull() const
Returns true if the icon is empty; otherwise returns false.
QPixmap pixmap(const QSize &size, Mode mode=Normal, State state=Off) const
Returns a pixmap with the requested size, mode, and state, generating one if necessary.
qsizetype size() const noexcept
\inmodule QtCore\reentrant
constexpr int height() const noexcept
Returns the height of the rectangle.
constexpr int x() const noexcept
Returns the x-coordinate of the rectangle's left edge.
constexpr int width() const noexcept
Returns the width of the rectangle.
constexpr int y() const noexcept
Returns the y-coordinate of the rectangle's top edge.
\macro QT_RESTRICTED_CAST_FROM_ASCII
QChar * data()
Returns a pointer to the data stored in the QString.
qsizetype length() const noexcept
Returns the number of characters in this string.
static bool registerNatives()
Combined button and popup list for selecting options.
static jmethodID setCheckableMenuItemMethodID
static int addAllMenuItemsToMenu(JNIEnv *env, jobject menu, QAndroidPlatformMenu *platformMenu)
void hideContextMenu(QAndroidPlatformMenu *menu)
static jmethodID addMenuItemMethodID
static jmethodID setVisibleMenuItemMethodID
static Q_CONSTINIT QRecursiveMutex menuBarMutex
static jboolean onContextItemSelected(JNIEnv *env, jobject thiz, jint menuId, jboolean checked)
static QAndroidPlatformMenu * visibleMenu
static QString removeAmpersandEscapes(QString s)
static jmethodID setHeaderTitleContextMenuMethodID
static Q_CONSTINIT QRecursiveMutex visibleMenuMutex
void setActiveTopLevelWindow(QWindow *window)
void removeMenuBar(QAndroidPlatformMenuBar *menuBar)
static QWindow * activeTopLevelWindow
void syncMenu(QAndroidPlatformMenu *)
static void onCreateContextMenu(JNIEnv *env, jobject thiz, jobject menu)
void androidPlatformMenuDestroyed(QAndroidPlatformMenu *menu)
static jmethodID setEnabledMenuItemMethodID
static jmethodID clearMenuMethodID
static JNINativeMethod methods[]
void addMenuBar(QAndroidPlatformMenuBar *menuBar)
static QList< QAndroidPlatformMenu * > pendingContextMenus
static void onContextMenuClosed(JNIEnv *env, jobject thiz, jobject menu)
static void onOptionsMenuClosed(JNIEnv *env, jobject thiz, jobject menu)
static jmethodID setCheckedMenuItemMethodID
static QSet< QAndroidPlatformMenuBar * > menuBars
void showContextMenu(QAndroidPlatformMenu *menu, const QRect &anchorRect)
static jboolean onPrepareOptionsMenu(JNIEnv *env, jobject thiz, jobject menu)
static void fillMenuItem(JNIEnv *env, jobject menuItem, bool checkable, bool checked, bool enabled, bool visible, const QIcon &icon=QIcon())
static jmethodID setIconMenuItemMethodID
void setMenuBar(QAndroidPlatformMenuBar *menuBar, QWindow *window)
static QAndroidPlatformMenuBar * visibleMenuBar
static void fillContextMenu(JNIEnv *env, jobject thiz, jobject menu)
static jboolean onOptionsItemSelected(JNIEnv *env, jobject thiz, jint menuId, jboolean checked)
jobject createBitmap(QImage img, JNIEnv *env)
QtJniTypes::QtActivityDelegateBase qtActivityDelegate()
jclass applicationClass()
jobject createBitmapDrawable(jobject bitmap, JNIEnv *env)
constexpr const T & qMax(const T &a, const T &b)
GLenum GLenum GLsizei const GLuint GLboolean enabled
GLfixed GLfixed GLint GLint order
Q_CORE_EXPORT int qEnvironmentVariableIntValue(const char *varName, bool *ok=nullptr) noexcept