diff options
author | Mitch Curtis <mitch.curtis@qt.io> | 2024-02-26 12:46:35 +0800 |
---|---|---|
committer | Mitch Curtis <mitch.curtis@qt.io> | 2024-03-15 13:32:47 +0800 |
commit | f1bb9cfbf65ab56b67b5a52fa736071e0e534261 (patch) | |
tree | de6002be991ccca5d24568b00dc67df47a2371de | |
parent | df24438e6a2adb344d78628e7a79432f88fab5e9 (diff) |
Add AA_DontUseNativeMenuWindows
Also add some categorized logging output to make it easier
to check if native menus are being created.
[ChangeLog][Qt Core] Added AA_DontUseNativeMenuWindows
application attribute. Menu popup windows (e.g. context menus,
combo box menus, and non-native menubar menus) created while this
attribute is set to true will not be represented as native top level
windows, unless required by the implementation.
Task-number: QTBUG-69558
Change-Id: Iba11b89c67d942ce6c5a28a7c57a86e63c020618
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
-rw-r--r-- | src/corelib/global/qnamespace.h | 1 | ||||
-rw-r--r-- | src/corelib/global/qnamespace.qdoc | 6 | ||||
-rw-r--r-- | src/plugins/platforms/android/qandroidplatformtheme.cpp | 15 | ||||
-rw-r--r-- | src/plugins/platforms/android/qandroidplatformtheme.h | 4 | ||||
-rw-r--r-- | src/plugins/platforms/cocoa/qcocoatheme.mm | 12 |
5 files changed, 31 insertions, 7 deletions
diff --git a/src/corelib/global/qnamespace.h b/src/corelib/global/qnamespace.h index 33b2a69709..3b4daa0f8f 100644 --- a/src/corelib/global/qnamespace.h +++ b/src/corelib/global/qnamespace.h @@ -463,6 +463,7 @@ namespace Qt { AA_CompressTabletEvents = 29, // AA_DisableWindowContextHelpButton = 30, AA_DisableSessionManager = 31, + AA_DontUseNativeMenuWindows = 32, // Add new attributes before this line AA_AttributeCount diff --git a/src/corelib/global/qnamespace.qdoc b/src/corelib/global/qnamespace.qdoc index 29f3784329..feac46d567 100644 --- a/src/corelib/global/qnamespace.qdoc +++ b/src/corelib/global/qnamespace.qdoc @@ -273,6 +273,12 @@ Currently supported on the Windows platform only. This value was added in 5.15 + \value AA_DontUseNativeMenuWindows Menu popup windows (e.g. context menus, + combo box menus, and non-native menubar menus) created while this + attribute is set to true will not be represented as native top + level windows, unless required by the implementation. + This value was added in Qt 6.8. + \omitvalue AA_AttributeCount \omitvalue AA_EnableHighDpiScaling \omitvalue AA_UseHighDpiPixmaps diff --git a/src/plugins/platforms/android/qandroidplatformtheme.cpp b/src/plugins/platforms/android/qandroidplatformtheme.cpp index d69dce3550..7b9072df69 100644 --- a/src/plugins/platforms/android/qandroidplatformtheme.cpp +++ b/src/plugins/platforms/android/qandroidplatformtheme.cpp @@ -23,6 +23,8 @@ QT_BEGIN_NAMESPACE +Q_LOGGING_CATEGORY(lcQpaMenus, "qt.qpa.menus") + using namespace Qt::StringLiterals; namespace { @@ -394,21 +396,28 @@ void QAndroidPlatformTheme::updateStyle() QPlatformMenuBar *QAndroidPlatformTheme::createPlatformMenuBar() const { - return new QAndroidPlatformMenuBar; + auto *menuBar = new QAndroidPlatformMenuBar; + qCDebug(lcQpaMenus) << "Created" << menuBar; + return menuBar; } QPlatformMenu *QAndroidPlatformTheme::createPlatformMenu() const { - return new QAndroidPlatformMenu; + auto *menu = new QAndroidPlatformMenu; + qCDebug(lcQpaMenus) << "Created" << menu; + return menu; } QPlatformMenuItem *QAndroidPlatformTheme::createPlatformMenuItem() const { - return new QAndroidPlatformMenuItem; + auto *menuItem = new QAndroidPlatformMenuItem; + qCDebug(lcQpaMenus) << "Created" << menuItem; + return menuItem; } void QAndroidPlatformTheme::showPlatformMenuBar() { + qCDebug(lcQpaMenus) << "Showing platform menu bar"; QtAndroidMenu::openOptionsMenu(); } diff --git a/src/plugins/platforms/android/qandroidplatformtheme.h b/src/plugins/platforms/android/qandroidplatformtheme.h index d494bad05f..ce3d6d5f73 100644 --- a/src/plugins/platforms/android/qandroidplatformtheme.h +++ b/src/plugins/platforms/android/qandroidplatformtheme.h @@ -9,13 +9,15 @@ #include <QtGui/qpalette.h> #include <QtCore/qhash.h> #include <QtCore/qbytearray.h> - +#include <QtCore/qloggingcategory.h> #include <QJsonObject> #include <memory> QT_BEGIN_NAMESPACE +Q_DECLARE_LOGGING_CATEGORY(lcQpaMenus) + struct AndroidStyle { static QJsonObject loadStyleData(); diff --git a/src/plugins/platforms/cocoa/qcocoatheme.mm b/src/plugins/platforms/cocoa/qcocoatheme.mm index 954159ca26..f4fbfadbe4 100644 --- a/src/plugins/platforms/cocoa/qcocoatheme.mm +++ b/src/plugins/platforms/cocoa/qcocoatheme.mm @@ -505,12 +505,16 @@ QKeySequence QCocoaTheme::standardButtonShortcut(int button) const QPlatformMenuItem *QCocoaTheme::createPlatformMenuItem() const { - return new QCocoaMenuItem(); + auto *menuItem = new QCocoaMenuItem(); + qCDebug(lcQpaMenus) << "Created" << menuItem; + return menuItem; } QPlatformMenu *QCocoaTheme::createPlatformMenu() const { - return new QCocoaMenu(); + auto *menu = new QCocoaMenu(); + qCDebug(lcQpaMenus) << "Created" << menu; + return menu; } QPlatformMenuBar *QCocoaTheme::createPlatformMenuBar() const @@ -523,7 +527,9 @@ QPlatformMenuBar *QCocoaTheme::createPlatformMenuBar() const SLOT(onAppFocusWindowChanged(QWindow*))); } - return new QCocoaMenuBar(); + auto *menuBar = new QCocoaMenuBar(); + qCDebug(lcQpaMenus) << "Created" << menuBar; + return menuBar; } #ifndef QT_NO_SHORTCUT |