From 9067a7f59c54a3dfab914b842b009b8346ae384c Mon Sep 17 00:00:00 2001 From: Dmitry Shachnev Date: Sat, 5 Nov 2016 20:44:36 +0300 Subject: dbustray: Handle StatusNotifierWatcher appearing and disappearing MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Reviewed-by: Shawn Rutledge --- .../themes/genericunix/dbustray/qdbustrayicon.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'src/platformsupport/themes/genericunix/dbustray/qdbustrayicon.cpp') 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(); -- cgit v1.2.3