Provide default implementation of QPlatformMenuBar::createMenu()
Instead of falling back to createPlatformMenu() in client code. Change-Id: Ia257449200f5c71f5e164072adce13d1137b1d87 Reviewed-by: J-P Nurmi <jpnurmi@qt.io>
This commit is contained in:
parent
2ac50ac156
commit
725c2346b1
@ -55,4 +55,9 @@ QPlatformMenu *QPlatformMenu::createSubMenu() const
|
||||
return QGuiApplicationPrivate::platformTheme()->createPlatformMenu();
|
||||
}
|
||||
|
||||
QPlatformMenu *QPlatformMenuBar::createMenu() const
|
||||
{
|
||||
return QGuiApplicationPrivate::platformTheme()->createPlatformMenu();
|
||||
}
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
@ -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
|
||||
|
@ -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);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user