diff options
author | Shawn Rutledge <shawn.rutledge@digia.com> | 2015-02-04 15:13:25 +0100 |
---|---|---|
committer | Shawn Rutledge <shawn.rutledge@digia.com> | 2015-02-12 13:24:11 +0000 |
commit | 69d46a3e205e3533c8bdcf1a1f4e5ce92604759d (patch) | |
tree | 50cd1f1cb7c71015ede7fa8a2d39d044831816ad /src/platformsupport/themes | |
parent | f8dd268e505cdd0413d112aaaf8e33989a49349e (diff) |
D-Bus tray icons: try to use them with QGenericUnixTheme
Until now, only the Gnome and KDE themes have done this. But
the gtk2 theme is not the same as the gnome theme. Further, Ubuntu sets
the environment variable QT_QPA_PLATFORMTHEME=appmenu-qt5 if that
plugin is installed on the system; and then with a custom build of Qt
which cannot load the module (e.g. a static build), it will again
fall back to QGenericUnixTheme instead of the gnome theme. In both
cases we want to still try to use D-Bus StatusNotifier protocol
instead of XEmbed. In general it should always be safe to check
whether or not that is possible, before falling back to the XEmbed
tray icon implementation.
Change-Id: I86d6c6f6ad410ea31770d39166d0a7e3330365a0
Reviewed-by: Rafael Roquetto <rafael.roquetto@kdab.com>
Diffstat (limited to 'src/platformsupport/themes')
-rw-r--r-- | src/platformsupport/themes/genericunix/qgenericunixthemes.cpp | 13 | ||||
-rw-r--r-- | src/platformsupport/themes/genericunix/qgenericunixthemes_p.h | 3 |
2 files changed, 16 insertions, 0 deletions
diff --git a/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp b/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp index 8db4b85c86..f8ced57553 100644 --- a/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp +++ b/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp @@ -44,6 +44,7 @@ #include <QtCore/QFile> #include <QtCore/QDebug> #include <QtCore/QHash> +#include <QtCore/QLoggingCategory> #include <QtCore/QSettings> #include <QtCore/QVariant> #include <QtCore/QStringList> @@ -60,6 +61,8 @@ QT_BEGIN_NAMESPACE +Q_DECLARE_LOGGING_CATEGORY(qLcTray) + ResourceHelper::ResourceHelper() { std::fill(palettes, palettes + QPlatformTheme::NPalettes, static_cast<QPalette *>(0)); @@ -98,6 +101,7 @@ static bool isDBusTrayAvailable() { if (conn.isWatcherRegistered()) dbusTrayAvailable = true; dbusTrayAvailableKnown = true; + qCDebug(qLcTray) << "D-Bus tray available:" << dbusTrayAvailable; } return dbusTrayAvailable; } @@ -161,6 +165,15 @@ QStringList QGenericUnixTheme::xdgIconThemePaths() return paths; } +#if !defined(QT_NO_DBUS) && !defined(QT_NO_SYSTEMTRAYICON) +QPlatformSystemTrayIcon *QGenericUnixTheme::createPlatformSystemTrayIcon() const +{ + if (isDBusTrayAvailable()) + return new QDBusTrayIcon(); + return Q_NULLPTR; +} +#endif + QVariant QGenericUnixTheme::themeHint(ThemeHint hint) const { switch (hint) { diff --git a/src/platformsupport/themes/genericunix/qgenericunixthemes_p.h b/src/platformsupport/themes/genericunix/qgenericunixthemes_p.h index fd9519ed69..115b9d9f91 100644 --- a/src/platformsupport/themes/genericunix/qgenericunixthemes_p.h +++ b/src/platformsupport/themes/genericunix/qgenericunixthemes_p.h @@ -79,6 +79,9 @@ public: virtual QVariant themeHint(ThemeHint hint) const Q_DECL_OVERRIDE; static QStringList xdgIconThemePaths(); +#if !defined(QT_NO_DBUS) && !defined(QT_NO_SYSTEMTRAYICON) + QPlatformSystemTrayIcon *createPlatformSystemTrayIcon() const Q_DECL_OVERRIDE; +#endif static const char *name; }; |