diff options
author | Shawn Rutledge <shawn.rutledge@digia.com> | 2014-11-28 09:20:19 +0100 |
---|---|---|
committer | Shawn Rutledge <shawn.rutledge@digia.com> | 2015-01-22 12:50:51 +0100 |
commit | 38abd653774aa0b3c5cdfd9a8b78619605230726 (patch) | |
tree | 00dba009a99dfc5c4e85d3f73dd94da1f2120e69 /src/platformsupport/themes/genericunix/qgenericunixthemes.cpp | |
parent | 3c37066062d61a430b8e7f970cccf6effab5a3ef (diff) |
QSystemTrayIcon uses D-Bus StatusNotifier on Linux when possible
Implementing org.kde.StatusNotifier DBus interface
http://www.freedesktop.org/wiki/Specifications/StatusNotifierItem/
as well as org.canonical.dbusmenu for the limited purpose of showing
the tray icon's context menu. If a desktop environment (such as
KDE or Unity) has a StatusNotifierWatcher listening, then tray icon
information is sent to be displayed by the tray implementation
instead of being rendered directly in an XEmbed window. This is
necessary because some modern tray implementations no longer provide
XEmbed "hosting".
[ChangeLog][QPA][Xcb] QSystemTrayIcon uses StatusNotifier D-Bus
protocol when the desktop environment supports it
Task-number: QTBUG-31762
Done-with: Marco Martin <mart@kde.org>
Change-Id: I3b1f744d621eefc7e9c61d1469460ebfcc77fc54
Reviewed-by: Jørgen Lind <jorgen.lind@theqtcompany.com>
Reviewed-by: Dmitry Shachnev <mitya57@gmail.com>
Diffstat (limited to 'src/platformsupport/themes/genericunix/qgenericunixthemes.cpp')
-rw-r--r-- | src/platformsupport/themes/genericunix/qgenericunixthemes.cpp | 38 |
1 files changed, 37 insertions, 1 deletions
diff --git a/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp b/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp index 1060ff283b..9fa1f19f3c 100644 --- a/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp +++ b/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). +** Copyright (C) 2015 Digia Plc and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/legal ** ** This file is part of the plugins of the Qt Toolkit. @@ -51,6 +51,10 @@ #include <qpa/qplatformintegration.h> #include <qpa/qplatformservices.h> #include <qpa/qplatformdialoghelper.h> +#if !defined(QT_NO_DBUS) && !defined(QT_NO_SYSTEMTRAYICON) +#include "QtPlatformSupport/private/qdbustrayicon_p.h" +#include "QtPlatformSupport/private/qdbusplatformmenu_p.h" +#endif #include <algorithm> @@ -85,6 +89,20 @@ const char *QGenericUnixTheme::name = "generic"; static const char defaultSystemFontNameC[] = "Sans Serif"; enum { defaultSystemFontSize = 9 }; +#if !defined(QT_NO_DBUS) && !defined(QT_NO_SYSTEMTRAYICON) +static bool isDBusTrayAvailable() { + static bool dbusTrayAvailable = false; + static bool dbusTrayAvailableKnown = false; + if (!dbusTrayAvailableKnown) { + QDBusMenuConnection conn; + if (conn.isWatcherRegistered()) + dbusTrayAvailable = true; + dbusTrayAvailableKnown = true; + } + return dbusTrayAvailable; +} +#endif + class QGenericUnixThemePrivate : public QPlatformThemePrivate { public: @@ -509,6 +527,15 @@ QPlatformTheme *QKdeTheme::createKdeTheme() return new QKdeTheme(kdeDirs, kdeVersion); } +#if !defined(QT_NO_DBUS) && !defined(QT_NO_SYSTEMTRAYICON) +QPlatformSystemTrayIcon *QKdeTheme::createPlatformSystemTrayIcon() const +{ + if (isDBusTrayAvailable()) + return new QDBusTrayIcon(); + return Q_NULLPTR; +} +#endif + #endif // QT_NO_SETTINGS /*! @@ -595,6 +622,15 @@ QString QGnomeTheme::gtkFontName() const return QStringLiteral("%1 %2").arg(QLatin1String(defaultSystemFontNameC)).arg(defaultSystemFontSize); } +#if !defined(QT_NO_DBUS) && !defined(QT_NO_SYSTEMTRAYICON) +QPlatformSystemTrayIcon *QGnomeTheme::createPlatformSystemTrayIcon() const +{ + if (isDBusTrayAvailable()) + return new QDBusTrayIcon(); + return Q_NULLPTR; +} +#endif + QString QGnomeTheme::standardButtonText(int button) const { switch (button) { |