summaryrefslogtreecommitdiffstats
path: root/src/widgets/util/qsystemtrayicon.cpp
diff options
context:
space:
mode:
authorLaszlo Agocs <laszlo.agocs@theqtcompany.com>2015-02-10 16:57:11 +0000
committerThe Qt Project <gerrit-noreply@qt-project.org>2015-02-10 16:57:11 +0000
commit0866680bd904aff4fe2a643a2b81c460cbb99c77 (patch)
tree242dae052199994a35f5e68578661175241a0a71 /src/widgets/util/qsystemtrayicon.cpp
parent34ea269b3b173498312b0203d6875ef3b4ba0253 (diff)
parentfc35f714340d5361231506dfbead132122f59460 (diff)
Merge "Merge remote-tracking branch 'origin/5.4' into dev" into refs/staging/dev
Diffstat (limited to 'src/widgets/util/qsystemtrayicon.cpp')
-rw-r--r--src/widgets/util/qsystemtrayicon.cpp28
1 files changed, 23 insertions, 5 deletions
diff --git a/src/widgets/util/qsystemtrayicon.cpp b/src/widgets/util/qsystemtrayicon.cpp
index c0f9538c0a..034894aa24 100644
--- a/src/widgets/util/qsystemtrayicon.cpp
+++ b/src/widgets/util/qsystemtrayicon.cpp
@@ -37,6 +37,7 @@
#ifndef QT_NO_SYSTEMTRAYICON
#include "qmenu.h"
+#include "qlist.h"
#include "qevent.h"
#include "qpoint.h"
#include "qlabel.h"
@@ -708,11 +709,7 @@ void QSystemTrayIconPrivate::updateIcon_sys_qpa()
void QSystemTrayIconPrivate::updateMenu_sys_qpa()
{
if (menu) {
- if (!menu->platformMenu()) {
- QPlatformMenu *platformMenu = qpa_sys->createMenu();
- if (platformMenu)
- menu->setPlatformMenu(platformMenu);
- }
+ addPlatformMenu(menu);
qpa_sys->updateMenu(menu->platformMenu());
}
}
@@ -745,6 +742,27 @@ void QSystemTrayIconPrivate::showMessage_sys_qpa(const QString &title,
static_cast<QPlatformSystemTrayIcon::MessageIcon>(icon), msecs);
}
+void QSystemTrayIconPrivate::addPlatformMenu(QMenu *menu) const
+{
+ if (menu->platformMenu())
+ return; // The platform menu already exists.
+
+ // The recursion depth is the same as menu depth, so should not
+ // be higher than 3 levels.
+ QListIterator<QAction *> it(menu->actions());
+ while (it.hasNext()) {
+ QAction *action = it.next();
+ if (action->menu())
+ addPlatformMenu(action->menu());
+ }
+
+ // This menu should be processed *after* its children, otherwise
+ // setMenu() is not called on respective QPlatformMenuItems.
+ QPlatformMenu *platformMenu = qpa_sys->createMenu();
+ if (platformMenu)
+ menu->setPlatformMenu(platformMenu);
+}
+
QT_END_NAMESPACE
#endif // QT_NO_SYSTEMTRAYICON