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>
bb10
Mitch Curtis 2024-02-26 12:46:35 +08:00
parent df24438e6a
commit f1bb9cfbf6
5 changed files with 31 additions and 7 deletions

View File

@ -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

View File

@ -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

View File

@ -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();
}

View File

@ -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();

View File

@ -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