16#include <QtCore/private/qjnihelpers_p.h>
17#include <QtCore/QJniObject>
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);
224 if (menus.
size() == 1) {
229 jstring jtext = env->NewString(
reinterpret_cast<const jchar *
>(itemText.
data()),
232 jobject menuItem = env->CallObjectMethod(
menu,
238 env->DeleteLocalRef(jtext);
249 return order ? JNI_TRUE : JNI_FALSE;
259 if (menus.
size() == 1) {
265 if (
item->isCheckable())
266 item->setChecked(checked);
291 jstring jtext = env->NewString(
reinterpret_cast<const jchar*
>(menuText.
data()),
294 env->DeleteLocalRef(jtext);
316 if (
item->isCheckable())
317 item->setChecked(checked);
348 {
"fillContextMenu",
"(Landroid/view/Menu;)V", (
void *)
fillContextMenu},
353#define FIND_AND_CHECK_CLASS(CLASS_NAME) \
354 clazz = env->FindClass(CLASS_NAME); \
356 __android_log_print(ANDROID_LOG_FATAL, qtTagText(), classErrorMsgFmt(), CLASS_NAME); \
360#define GET_AND_CHECK_METHOD(VAR, CLASS, METHOD_NAME, METHOD_SIGNATURE) \
361 VAR = env->GetMethodID(CLASS, METHOD_NAME, METHOD_SIGNATURE); \
363 __android_log_print(ANDROID_LOG_FATAL, qtTagText(), methodErrorMsgFmt(), METHOD_NAME, METHOD_SIGNATURE); \
367#define GET_AND_CHECK_STATIC_METHOD(VAR, CLASS, METHOD_NAME, METHOD_SIGNATURE) \
368 VAR = env->GetStaticMethodID(CLASS, METHOD_NAME, METHOD_SIGNATURE); \
370 __android_log_print(ANDROID_LOG_FATAL, qtTagText(), methodErrorMsgFmt(), METHOD_NAME, METHOD_SIGNATURE); \
374#define GET_AND_CHECK_STATIC_FIELD(VAR, CLASS, FIELD_NAME, FIELD_SIGNATURE) \
375 VAR = env->GetStaticFieldID(CLASS, FIELD_NAME, FIELD_SIGNATURE); \
377 __android_log_print(ANDROID_LOG_FATAL, qtTagText(), methodErrorMsgFmt(), FIELD_NAME, FIELD_SIGNATURE); \
386 __android_log_print(ANDROID_LOG_FATAL,
"Qt",
"RegisterNatives failed");
396 jfieldID menuNoneFiledId;
398 menuNoneValue = env->GetStaticIntField(clazz, menuNoneFiledId);
#define GET_AND_CHECK_STATIC_METHOD(VAR, CLASS, METHOD_NAME, METHOD_SIGNATURE)
#define FIND_AND_CHECK_CLASS(CLASS_NAME)
#define GET_AND_CHECK_STATIC_FIELD(VAR, CLASS, FIELD_NAME, FIELD_SIGNATURE)
#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
bool empty() const noexcept
bool removeOne(const AT &t)
void append(parameter_type t)
\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
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 jboolean onContextItemSelected(JNIEnv *env, jobject, jint menuId, jboolean checked)
static jmethodID setVisibleMenuItemMethodID
static Q_CONSTINIT QRecursiveMutex menuBarMutex
static QAndroidPlatformMenu * visibleMenu
static QString removeAmpersandEscapes(QString s)
static void onCreateContextMenu(JNIEnv *env, jobject, jobject menu)
static jmethodID setHeaderTitleContextMenuMethodID
static Q_CONSTINIT QRecursiveMutex visibleMenuMutex
void setActiveTopLevelWindow(QWindow *window)
void removeMenuBar(QAndroidPlatformMenuBar *menuBar)
static QWindow * activeTopLevelWindow
void syncMenu(QAndroidPlatformMenu *)
void androidPlatformMenuDestroyed(QAndroidPlatformMenu *menu)
static void fillContextMenu(JNIEnv *env, jobject, jobject menu)
static void onOptionsMenuClosed(JNIEnv *, jobject, jobject)
static jmethodID setEnabledMenuItemMethodID
static jmethodID clearMenuMethodID
static JNINativeMethod methods[]
void addMenuBar(QAndroidPlatformMenuBar *menuBar)
static QList< QAndroidPlatformMenu * > pendingContextMenus
static jboolean onPrepareOptionsMenu(JNIEnv *env, jobject, jobject menu)
static jmethodID openContextMenuMethodID
static void onContextMenuClosed(JNIEnv *env, jobject, jobject)
void showContextMenu(QAndroidPlatformMenu *menu, const QRect &anchorRect, JNIEnv *env)
static jmethodID setCheckedMenuItemMethodID
static QSet< QAndroidPlatformMenuBar * > menuBars
static jboolean onOptionsItemSelected(JNIEnv *env, jobject, jint menuId, jboolean checked)
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
jobject createBitmap(QImage img, JNIEnv *env)
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