From 725c2346b1789c0cd383af339bcb7fb53e4fe69b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Thu, 5 Jan 2017 14:13:31 +0100 Subject: Provide default implementation of QPlatformMenuBar::createMenu() Instead of falling back to createPlatformMenu() in client code. Change-Id: Ia257449200f5c71f5e164072adce13d1137b1d87 Reviewed-by: J-P Nurmi --- src/gui/kernel/qplatformmenu.cpp | 5 +++++ src/gui/kernel/qplatformmenu.h | 2 +- src/widgets/widgets/qmenubar.cpp | 4 ---- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/gui/kernel/qplatformmenu.cpp b/src/gui/kernel/qplatformmenu.cpp index 2912416309..1eb146dd0f 100644 --- a/src/gui/kernel/qplatformmenu.cpp +++ b/src/gui/kernel/qplatformmenu.cpp @@ -55,4 +55,9 @@ QPlatformMenu *QPlatformMenu::createSubMenu() const return QGuiApplicationPrivate::platformTheme()->createPlatformMenu(); } +QPlatformMenu *QPlatformMenuBar::createMenu() const +{ + return QGuiApplicationPrivate::platformTheme()->createPlatformMenu(); +} + QT_END_NAMESPACE diff --git a/src/gui/kernel/qplatformmenu.h b/src/gui/kernel/qplatformmenu.h index f08f0ef494..f8561445b1 100644 --- a/src/gui/kernel/qplatformmenu.h +++ b/src/gui/kernel/qplatformmenu.h @@ -150,7 +150,7 @@ public: virtual void handleReparent(QWindow *newParentWindow) = 0; virtual QPlatformMenu *menuForTag(quintptr tag) const = 0; - virtual QPlatformMenu *createMenu() const { return nullptr; } + virtual QPlatformMenu *createMenu() const; }; QT_END_NAMESPACE diff --git a/src/widgets/widgets/qmenubar.cpp b/src/widgets/widgets/qmenubar.cpp index 6b0c2fd621..ce43740524 100644 --- a/src/widgets/widgets/qmenubar.cpp +++ b/src/widgets/widgets/qmenubar.cpp @@ -1192,10 +1192,6 @@ QPlatformMenu *QMenuBarPrivate::getPlatformMenu(QAction *action) QPlatformMenu *platformMenu = action->menu()->platformMenu(); if (!platformMenu && platformMenuBar) { platformMenu = platformMenuBar->createMenu(); - // QPlatformMenuBar::createMenu() was introduced in Qt 5.7. Not all third party - // platform themes are using it, so fallback to QPlatformTheme::createPlatformMenu(). - if (!platformMenu) - platformMenu = QGuiApplicationPrivate::platformTheme()->createPlatformMenu(); if (platformMenu) action->menu()->setPlatformMenu(platformMenu); } -- cgit v1.2.3