summaryrefslogtreecommitdiffstats
path: root/src/gui
diff options
context:
space:
mode:
authorTor Arne Vestbø <tor.arne.vestbo@qt.io>2017-01-05 15:01:02 +0100
committerJani Heikkinen <jani.heikkinen@qt.io>2017-01-06 18:28:07 +0000
commit4a738424aaef7958917b92bd64a08eb6208d9c06 (patch)
tree67d05dcc170e84d522a0d9c14a8556fa0e30a806 /src/gui
parent7e3e5b2dcf2e2576065ca9f9850cd1f2126f397f (diff)
Fall back to platform theme in QPlatformSystemTrayIcon::createMenu()
Commit 824f08046 introduced QPlatformSystemTrayIcon::createMenu() as a way for platforms to provide a system tray menu independently of the menu created by QPlatformTheme::createPlatformMenu(), which would on some platforms be null. Commit 063997f44ffc then made menu creation lazy, which meant that the logic in QSystemTrayIconPrivate::addPlatformMenu() to create the menu turned from "create menu via QPSTI::createMenu() if QPT::createPlatformMenu() returned null", to "create menu via QPSTI::createMenu() if menu was not created yet". The latter logic relied on each platform having implementations of QPlatformSystemTrayIcon::createMenu() which they didn't, resulting in missing menus for system trays on e.g. macOS. With the new lazy logic, the reasonable approach is for the default implementation of createMenu() to use createPlatformMenu(), which will ensure system tray menus on platforms that implement createPlatformMenu(), while still allowing platforms that don't to override createMenu() for special-casing system tray menus. Task-number: QTBUG-57365 Change-Id: Id393e802ac0435200fc885a7f4436b744962f27f Reviewed-by: J-P Nurmi <jpnurmi@qt.io>
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/kernel/qplatformsystemtrayicon.cpp14
1 files changed, 8 insertions, 6 deletions
diff --git a/src/gui/kernel/qplatformsystemtrayicon.cpp b/src/gui/kernel/qplatformsystemtrayicon.cpp
index 30db966df7..973b998059 100644
--- a/src/gui/kernel/qplatformsystemtrayicon.cpp
+++ b/src/gui/kernel/qplatformsystemtrayicon.cpp
@@ -40,6 +40,9 @@
#include "qplatformsystemtrayicon.h"
+#include <QtGui/private/qguiapplication_p.h>
+#include <QtGui/qpa/qplatformtheme.h>
+
#ifndef QT_NO_SYSTEMTRAYICON
QT_BEGIN_NAMESPACE
@@ -158,11 +161,10 @@ QPlatformSystemTrayIcon::~QPlatformSystemTrayIcon()
*/
/*!
- This method is called in case there is no QPlatformMenu available when
- updating the menu. This allows the abstraction to provide a menu for the
- system tray icon even if normally a non-native menu is used.
-
- The default implementation returns a null pointer.
+ This method allows platforms to use a different QPlatformMenu for system
+ tray menus than what would normally be used for e.g. menu bars. The default
+ implementation falls back to a platform menu created by the platform theme,
+ which may be null on platforms without native menus.
\sa updateMenu()
\since 5.3
@@ -170,7 +172,7 @@ QPlatformSystemTrayIcon::~QPlatformSystemTrayIcon()
QPlatformMenu *QPlatformSystemTrayIcon::createMenu() const
{
- return Q_NULLPTR;
+ return QGuiApplicationPrivate::platformTheme()->createPlatformMenu();
}
QT_END_NAMESPACE