diff options
author | Dmitry Shachnev <mitya57@gmail.com> | 2016-11-05 20:44:36 +0300 |
---|---|---|
committer | Dmitry Shachnev <mitya57@gmail.com> | 2016-12-02 16:03:48 +0000 |
commit | 9067a7f59c54a3dfab914b842b009b8346ae384c (patch) | |
tree | ec0a307aeb15379fd476f4ec73ff43de3831d345 /src/platformsupport/themes/genericunix/dbustray | |
parent | 5f6800c220d0c0e24e0cd4ac3e4a6bb78d45cb6d (diff) |
dbustray: Handle StatusNotifierWatcher appearing and disappearing
If the StatusNotifierWatcher disappears and then appears again, we need
to register our tray icon again with it.
To do this, split the “register with watcher” part into a separate
method, and call it when m_dbusWatcher emits its serviceRegistered()
signal.
Change-Id: Id5fc8ac81b5038a61b678514dabd3eb9c8f1c106
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Diffstat (limited to 'src/platformsupport/themes/genericunix/dbustray')
-rw-r--r-- | src/platformsupport/themes/genericunix/dbustray/qdbustrayicon.cpp | 11 | ||||
-rw-r--r-- | src/platformsupport/themes/genericunix/dbustray/qdbustrayicon_p.h | 1 |
2 files changed, 12 insertions, 0 deletions
diff --git a/src/platformsupport/themes/genericunix/dbustray/qdbustrayicon.cpp b/src/platformsupport/themes/genericunix/dbustray/qdbustrayicon.cpp index a686a33464..5c4157c206 100644 --- a/src/platformsupport/themes/genericunix/dbustray/qdbustrayicon.cpp +++ b/src/platformsupport/themes/genericunix/dbustray/qdbustrayicon.cpp @@ -116,6 +116,8 @@ void QDBusTrayIcon::init() { qCDebug(qLcTray) << "registering" << m_instanceId; m_registered = dBusConnection()->registerTrayIcon(this); + QObject::connect(dBusConnection()->dbusWatcher(), &QDBusServiceWatcher::serviceRegistered, + this, &QDBusTrayIcon::watcherServiceRegistered); } void QDBusTrayIcon::cleanup() @@ -130,6 +132,15 @@ void QDBusTrayIcon::cleanup() m_registered = false; } +void QDBusTrayIcon::watcherServiceRegistered(const QString &serviceName) +{ + Q_UNUSED(serviceName); + // We have the icon registered, but the watcher has restarted or + // changed, so we need to tell it about our icon again + if (m_registered) + dBusConnection()->registerTrayIconWithWatcher(this); +} + void QDBusTrayIcon::attentionTimerExpired() { m_messageTitle = QString(); diff --git a/src/platformsupport/themes/genericunix/dbustray/qdbustrayicon_p.h b/src/platformsupport/themes/genericunix/dbustray/qdbustrayicon_p.h index 234ff60584..ff1a7ae532 100644 --- a/src/platformsupport/themes/genericunix/dbustray/qdbustrayicon_p.h +++ b/src/platformsupport/themes/genericunix/dbustray/qdbustrayicon_p.h @@ -133,6 +133,7 @@ private Q_SLOTS: void attentionTimerExpired(); void actionInvoked(uint id, const QString &action); void notificationClosed(uint id, uint reason); + void watcherServiceRegistered(const QString &serviceName); private: void setStatus(const QString &status); |