diff --git a/plugins/system-tray/systemtrayplugin.cpp b/plugins/system-tray/systemtrayplugin.cpp index 1449cbfe7..0aa1eb35d 100644 --- a/plugins/system-tray/systemtrayplugin.cpp +++ b/plugins/system-tray/systemtrayplugin.cpp @@ -24,8 +24,7 @@ void SystemTrayPlugin::init(PluginProxyInterface *proxyInter) { m_proxyInter = proxyInter; - connect(m_trayInter, &DBusTrayManager::Added, this, &SystemTrayPlugin::trayAdded); - connect(m_trayInter, &DBusTrayManager::Removed, this, &SystemTrayPlugin::trayRemoved); + connect(m_trayInter, &DBusTrayManager::TrayIconsChanged, this, &SystemTrayPlugin::trayListChanged); connect(m_trayInter, &DBusTrayManager::Changed, this, &SystemTrayPlugin::trayChanged); m_trayInter->RetryManager(); @@ -72,6 +71,18 @@ void SystemTrayPlugin::updateTipsContent() m_tipsWidget->addWidgets(trayList); } +void SystemTrayPlugin::trayListChanged() +{ + QList trayList = m_trayInter->trayIcons(); + + for (auto tray : m_trayList.keys()) + if (!trayList.contains(tray)) + trayRemoved(tray); + + for (auto tray : trayList) + trayAdded(tray); +} + void SystemTrayPlugin::trayAdded(const quint32 winId) { if (m_trayList.contains(winId)) @@ -128,7 +139,10 @@ void SystemTrayPlugin::switchToMode(const Dock::DisplayMode mode) { for (auto winId : m_trayList.keys()) m_proxyInter->itemRemoved(this, QString::number(winId)); - m_proxyInter->itemAdded(this, FASHION_MODE_ITEM); + if (m_trayList.isEmpty()) + m_proxyInter->itemRemoved(this, FASHION_MODE_ITEM); + else + m_proxyInter->itemAdded(this, FASHION_MODE_ITEM); } else { diff --git a/plugins/system-tray/systemtrayplugin.h b/plugins/system-tray/systemtrayplugin.h index ae6c85ae3..fd77dc2c4 100644 --- a/plugins/system-tray/systemtrayplugin.h +++ b/plugins/system-tray/systemtrayplugin.h @@ -27,6 +27,7 @@ private: void updateTipsContent(); private slots: + void trayListChanged(); void trayAdded(const quint32 winId); void trayRemoved(const quint32 winId); void trayChanged(const quint32 winId);