libqt5-qtbase/QSystemTrayIcon-handle-submenus-correctly.patch
Dominique Leuenberger 7169baff88 Accepting request 286573 from KDE:Qt5
- Added patches from upstream:
  Fix-Meta-shortcuts-on-XCB.patch (qtbug#43572),
  Fix-detection-of-GCC5.patch,
  Fix-physical-DPI-and-size-for-rotated-screens-on-X11.patch
  (qtbug#43688), Fix-typo-in-Qt5CoreMacroscmake.patch,
  Make-sure-theres-a-scene-before-using-it.patch (qtbug#44509),
  Multi-screen-DPI-support-for-X11.patch (qtbug#43713),
  QSystemTrayIcon-handle-submenus-correctly.patch,
  Update-mouse-buttons-from-MotionNotify-events.patch
  (qtbug#32609, qtbug#35065, qtbug#43776, qtbug#44166, qtbug#44231),
  X11-devicePixelRatio-screen-mapping-fix.patch (qtbug#43713) and
  xcb-Dont-return-0-from-QXcbKeyboard-possibleKeys.patch
  (qtcreatorbug#9589)

OBS-URL: https://build.opensuse.org/request/show/286573
OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/libqt5-qtbase?expand=0&rev=37
2015-02-20 11:43:00 +00:00

83 lines
2.6 KiB
Diff

From: Dmitry Shachnev <mitya57@gmail.com>
Date: Sun, 11 Jan 2015 09:05:55 +0000
Subject: QSystemTrayIcon: handle submenus correctly
X-Git-Url: http://quickgit.kde.org/?p=qt%2Fqtbase.git&a=commitdiff&h=03dc2b2e82750d1c531cf00a406368cde4a8928b
---
QSystemTrayIcon: handle submenus correctly
This fixes a bug when submenus are shown as simple actions when
a platform system tray icon is used.
To correctly handle submenus, we need to set platform menus on
all submenus, and only then on a parent menu.
Change-Id: If2bfcc703b938dbb14ba4b9aa810039ced07e946
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@theqtcompany.com>
Reviewed-by: Dimitrios Glentadakis <dglent@free.fr>
Reviewed-by: Shawn Rutledge <shawn.rutledge@digia.com>
---
--- 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"
@@ -704,11 +705,7 @@
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());
}
}
@@ -741,6 +738,27 @@
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
--- a/src/widgets/util/qsystemtrayicon_p.h
+++ b/src/widgets/util/qsystemtrayicon_p.h
@@ -99,6 +99,7 @@
void updateMenu_sys_qpa();
QRect geometry_sys_qpa() const;
void showMessage_sys_qpa(const QString &msg, const QString &title, QSystemTrayIcon::MessageIcon icon, int secs);
+ void addPlatformMenu(QMenu *menu) const;
};
class QBalloonTip : public QWidget