diff --git a/src/gui/systray.cpp b/src/gui/systray.cpp index 5529964341b52..d4ca0bae94637 100644 --- a/src/gui/systray.cpp +++ b/src/gui/systray.cpp @@ -122,14 +122,8 @@ void Systray::create() } hideWindow(); emit activated(QSystemTrayIcon::ActivationReason::Unknown); - - const auto folderMap = FolderMan::instance()->map(); - for (const auto *folder : folderMap) { - if (!folder->syncPaused()) { - _syncIsPaused = false; - break; - } - } + slotUpdateSyncPausedState(); + connect(FolderMan::instance(), &FolderMan::folderListChanged, this, &Systray::slotUpdateSyncPausedState); } void Systray::showWindow(WindowPosition position) @@ -435,6 +429,22 @@ void Systray::slotCurrentUserChanged() UserAppsModel::instance()->buildAppList(); } +void Systray::slotUpdateSyncPausedState() +{ + const auto folderMap = FolderMan::instance()->map(); + for (const auto folder : folderMap) { + connect(folder, &Folder::syncPausedChanged, this, &Systray::slotUpdateSyncPausedState, Qt::UniqueConnection); + if (!folder->syncPaused()) { + _syncIsPaused = false; + emit syncIsPausedChanged(); + return; + } + } + + _syncIsPaused = true; + emit syncIsPausedChanged(); +} + void Systray::slotUnpauseAllFolders() { setPauseOnAllFoldersHelper(false); @@ -567,6 +577,7 @@ void Systray::setSyncIsPaused(const bool syncIsPaused) } else { slotUnpauseAllFolders(); } + emit syncIsPausedChanged(); } /********************************************************************************************/ diff --git a/src/gui/systray.h b/src/gui/systray.h index 2056b7175eee7..45eab322ee224 100644 --- a/src/gui/systray.h +++ b/src/gui/systray.h @@ -151,6 +151,7 @@ public slots: void presentShareViewInTray(const QString &localPath); private slots: + void slotUpdateSyncPausedState(); void slotUnpauseAllFolders(); void slotPauseAllFolders();