From 7a47d6aeafd84c55b329be39a8ed18df7a1bedac Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Wed, 27 Mar 2024 18:09:33 +0800 Subject: [PATCH 1/4] Extract syncIsPaused initialisation into new updater slot Signed-off-by: Claudio Cambra --- src/gui/systray.cpp | 20 ++++++++++++-------- src/gui/systray.h | 1 + 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/src/gui/systray.cpp b/src/gui/systray.cpp index 5529964341b52..b62631be7c9f6 100644 --- a/src/gui/systray.cpp +++ b/src/gui/systray.cpp @@ -122,14 +122,7 @@ 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(); } void Systray::showWindow(WindowPosition position) @@ -435,6 +428,17 @@ void Systray::slotCurrentUserChanged() UserAppsModel::instance()->buildAppList(); } +void Systray::slotUpdateSyncPausedState() +{ + const auto folderMap = FolderMan::instance()->map(); + for (const auto *folder : folderMap) { + if (!folder->syncPaused()) { + _syncIsPaused = false; + break; + } + } +} + void Systray::slotUnpauseAllFolders() { setPauseOnAllFoldersHelper(false); 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(); From 1f8f84b849af5c2f0432c7f81bf279e763b098c6 Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Wed, 27 Mar 2024 19:24:54 +0800 Subject: [PATCH 2/4] Make sure to emit relevant signals and set sync is paused to true if relevant Signed-off-by: Claudio Cambra --- src/gui/systray.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/gui/systray.cpp b/src/gui/systray.cpp index b62631be7c9f6..a8cf868d3a2da 100644 --- a/src/gui/systray.cpp +++ b/src/gui/systray.cpp @@ -431,12 +431,17 @@ void Systray::slotCurrentUserChanged() void Systray::slotUpdateSyncPausedState() { const auto folderMap = FolderMan::instance()->map(); - for (const auto *folder : folderMap) { + for (const auto folder : folderMap) { + connect(folder, &Folder::syncPausedChanged, this, &Systray::slotUpdateSyncPausedState, Qt::UniqueConnection); if (!folder->syncPaused()) { _syncIsPaused = false; - break; + emit syncIsPausedChanged(); + return; } } + + _syncIsPaused = true; + emit syncIsPausedChanged(); } void Systray::slotUnpauseAllFolders() From 22f4494c10b8f43d31394a475d6cf91154a9d495 Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Wed, 27 Mar 2024 19:25:11 +0800 Subject: [PATCH 3/4] Make sure to emit syncIsPausedChanged in syncIsPaused setter Signed-off-by: Claudio Cambra --- src/gui/systray.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/gui/systray.cpp b/src/gui/systray.cpp index a8cf868d3a2da..5cd0dc9f414a7 100644 --- a/src/gui/systray.cpp +++ b/src/gui/systray.cpp @@ -576,6 +576,7 @@ void Systray::setSyncIsPaused(const bool syncIsPaused) } else { slotUnpauseAllFolders(); } + emit syncIsPausedChanged(); } /********************************************************************************************/ From a8fe9cf10c4319d807ec84fcdd40d5418888a358 Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Wed, 27 Mar 2024 19:25:37 +0800 Subject: [PATCH 4/4] Re-run update sync paused state slot when folder list has changed Signed-off-by: Claudio Cambra --- src/gui/systray.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/gui/systray.cpp b/src/gui/systray.cpp index 5cd0dc9f414a7..d4ca0bae94637 100644 --- a/src/gui/systray.cpp +++ b/src/gui/systray.cpp @@ -123,6 +123,7 @@ void Systray::create() hideWindow(); emit activated(QSystemTrayIcon::ActivationReason::Unknown); slotUpdateSyncPausedState(); + connect(FolderMan::instance(), &FolderMan::folderListChanged, this, &Systray::slotUpdateSyncPausedState); } void Systray::showWindow(WindowPosition position)