summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/gui/kernel/qplatformmenu.h1
-rw-r--r--src/platformsupport/dbusmenu/qdbusmenubar.cpp5
-rw-r--r--src/platformsupport/dbusmenu/qdbusmenubar_p.h1
-rw-r--r--src/platformsupport/themes/genericunix/qgenericunixthemes.cpp21
-rw-r--r--src/platformsupport/themes/genericunix/qgenericunixthemes_p.h3
-rw-r--r--src/widgets/widgets/qmenubar.cpp21
-rw-r--r--src/widgets/widgets/qmenubar_p.h1
7 files changed, 22 insertions, 31 deletions
diff --git a/src/gui/kernel/qplatformmenu.h b/src/gui/kernel/qplatformmenu.h
index 22848fcff6..bd4f4d9beb 100644
--- a/src/gui/kernel/qplatformmenu.h
+++ b/src/gui/kernel/qplatformmenu.h
@@ -148,6 +148,7 @@ public:
virtual void handleReparent(QWindow *newParentWindow) = 0;
virtual QPlatformMenu *menuForTag(quintptr tag) const = 0;
+ virtual QPlatformMenu *createMenu() const { return nullptr; }
};
QT_END_NAMESPACE
diff --git a/src/platformsupport/dbusmenu/qdbusmenubar.cpp b/src/platformsupport/dbusmenu/qdbusmenubar.cpp
index 7d53de6db4..76d658f51a 100644
--- a/src/platformsupport/dbusmenu/qdbusmenubar.cpp
+++ b/src/platformsupport/dbusmenu/qdbusmenubar.cpp
@@ -133,6 +133,11 @@ QPlatformMenu *QDBusMenuBar::menuForTag(quintptr tag) const
return nullptr;
}
+QPlatformMenu *QDBusMenuBar::createMenu() const
+{
+ return new QDBusPlatformMenu;
+}
+
void QDBusMenuBar::registerMenuBar()
{
static uint menuBarId = 0;
diff --git a/src/platformsupport/dbusmenu/qdbusmenubar_p.h b/src/platformsupport/dbusmenu/qdbusmenubar_p.h
index 157befe9e3..8266a395f5 100644
--- a/src/platformsupport/dbusmenu/qdbusmenubar_p.h
+++ b/src/platformsupport/dbusmenu/qdbusmenubar_p.h
@@ -72,6 +72,7 @@ public:
void syncMenu(QPlatformMenu *menu) Q_DECL_OVERRIDE;
void handleReparent(QWindow *newParentWindow) Q_DECL_OVERRIDE;
QPlatformMenu *menuForTag(quintptr tag) const Q_DECL_OVERRIDE;
+ QPlatformMenu *createMenu() const Q_DECL_OVERRIDE;
private:
QDBusPlatformMenu *m_menu;
diff --git a/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp b/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp
index aee12eed76..720b032ea5 100644
--- a/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp
+++ b/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp
@@ -191,13 +191,6 @@ QStringList QGenericUnixTheme::xdgIconThemePaths()
}
#ifndef QT_NO_DBUS
-QPlatformMenu *QGenericUnixTheme::createPlatformMenu() const
-{
- if (isDBusGlobalMenuAvailable())
- return new QDBusPlatformMenu();
- return nullptr;
-}
-
QPlatformMenuBar *QGenericUnixTheme::createPlatformMenuBar() const
{
if (isDBusGlobalMenuAvailable())
@@ -594,13 +587,6 @@ QPlatformTheme *QKdeTheme::createKdeTheme()
}
#ifndef QT_NO_DBUS
-QPlatformMenu *QKdeTheme::createPlatformMenu() const
-{
- if (isDBusGlobalMenuAvailable())
- return new QDBusPlatformMenu();
- return nullptr;
-}
-
QPlatformMenuBar *QKdeTheme::createPlatformMenuBar() const
{
if (isDBusGlobalMenuAvailable())
@@ -706,13 +692,6 @@ QString QGnomeTheme::gtkFontName() const
}
#ifndef QT_NO_DBUS
-QPlatformMenu *QGnomeTheme::createPlatformMenu() const
-{
- if (isDBusGlobalMenuAvailable())
- return new QDBusPlatformMenu();
- return nullptr;
-}
-
QPlatformMenuBar *QGnomeTheme::createPlatformMenuBar() const
{
if (isDBusGlobalMenuAvailable())
diff --git a/src/platformsupport/themes/genericunix/qgenericunixthemes_p.h b/src/platformsupport/themes/genericunix/qgenericunixthemes_p.h
index b7e0d53d6f..952658e130 100644
--- a/src/platformsupport/themes/genericunix/qgenericunixthemes_p.h
+++ b/src/platformsupport/themes/genericunix/qgenericunixthemes_p.h
@@ -86,7 +86,6 @@ public:
static QStringList xdgIconThemePaths();
#ifndef QT_NO_DBUS
- QPlatformMenu *createPlatformMenu() const Q_DECL_OVERRIDE;
QPlatformMenuBar *createPlatformMenuBar() const Q_DECL_OVERRIDE;
#endif
#if !defined(QT_NO_DBUS) && !defined(QT_NO_SYSTEMTRAYICON)
@@ -112,7 +111,6 @@ public:
const QFont *font(Font type) const Q_DECL_OVERRIDE;
#ifndef QT_NO_DBUS
- QPlatformMenu *createPlatformMenu() const Q_DECL_OVERRIDE;
QPlatformMenuBar *createPlatformMenuBar() const Q_DECL_OVERRIDE;
#endif
#if !defined(QT_NO_DBUS) && !defined(QT_NO_SYSTEMTRAYICON)
@@ -136,7 +134,6 @@ public:
virtual QString gtkFontName() const;
#ifndef QT_NO_DBUS
- QPlatformMenu *createPlatformMenu() const Q_DECL_OVERRIDE;
QPlatformMenuBar *createPlatformMenuBar() const Q_DECL_OVERRIDE;
#endif
#if !defined(QT_NO_DBUS) && !defined(QT_NO_SYSTEMTRAYICON)
diff --git a/src/widgets/widgets/qmenubar.cpp b/src/widgets/widgets/qmenubar.cpp
index 8fb02aaa72..85d0c54357 100644
--- a/src/widgets/widgets/qmenubar.cpp
+++ b/src/widgets/widgets/qmenubar.cpp
@@ -1210,12 +1210,19 @@ void QMenuBar::leaveEvent(QEvent *)
d->setCurrentAction(0);
}
-QPlatformMenu *getPlatformMenu(QAction *action)
+QPlatformMenu *QMenuBarPrivate::getPlatformMenu(QAction *action)
{
if (!action || !action->menu())
return 0;
- return action->menu()->platformMenu();
+ QPlatformMenu *platformMenu = action->menu()->platformMenu();
+ if (!platformMenu && platformMenuBar) {
+ platformMenu = platformMenuBar->createMenu();
+ if (platformMenu)
+ action->menu()->setPlatformMenu(platformMenu);
+ }
+
+ return platformMenu;
}
/*!
@@ -1236,14 +1243,14 @@ void QMenuBar::actionEvent(QActionEvent *e)
return;
if (e->type() == QEvent::ActionAdded) {
- QPlatformMenu *menu = getPlatformMenu(e->action());
+ QPlatformMenu *menu = d->getPlatformMenu(e->action());
if (menu) {
QPlatformMenu* beforeMenu = NULL;
for (int beforeIndex = d->indexOf(e->action()) + 1;
!beforeMenu && (beforeIndex < actions().size());
++beforeIndex)
{
- beforeMenu = getPlatformMenu(actions().at(beforeIndex));
+ beforeMenu = d->getPlatformMenu(actions().at(beforeIndex));
}
menu->setTag(reinterpret_cast<quintptr>(e->action()));
@@ -1251,12 +1258,12 @@ void QMenuBar::actionEvent(QActionEvent *e)
d->platformMenuBar->insertMenu(menu, beforeMenu);
}
} else if (e->type() == QEvent::ActionRemoved) {
- QPlatformMenu *menu = getPlatformMenu(e->action());
+ QPlatformMenu *menu = d->getPlatformMenu(e->action());
if (menu)
d->platformMenuBar->removeMenu(menu);
} else if (e->type() == QEvent::ActionChanged) {
QPlatformMenu* cur = d->platformMenuBar->menuForTag(reinterpret_cast<quintptr>(e->action()));
- QPlatformMenu *menu = getPlatformMenu(e->action());
+ QPlatformMenu *menu = d->getPlatformMenu(e->action());
// the menu associated with the action can change, need to
// remove and/or insert the new platform menu
@@ -1271,7 +1278,7 @@ void QMenuBar::actionEvent(QActionEvent *e)
!beforeMenu && (beforeIndex < actions().size());
++beforeIndex)
{
- beforeMenu = getPlatformMenu(actions().at(beforeIndex));
+ beforeMenu = d->getPlatformMenu(actions().at(beforeIndex));
}
d->platformMenuBar->insertMenu(menu, beforeMenu);
}
diff --git a/src/widgets/widgets/qmenubar_p.h b/src/widgets/widgets/qmenubar_p.h
index 04f608d22f..05b1878c20 100644
--- a/src/widgets/widgets/qmenubar_p.h
+++ b/src/widgets/widgets/qmenubar_p.h
@@ -143,6 +143,7 @@ public:
QBasicTimer autoReleaseTimer;
QPlatformMenuBar *platformMenuBar;
+ QPlatformMenu *getPlatformMenu(QAction *action);
inline int indexOf(QAction *act) const { return q_func()->actions().indexOf(act); }