Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix "Pause sync for all" / "Resume sync for all" state when manipulating folder sync outside of tray #6588

Merged
merged 4 commits into from
Apr 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 19 additions & 8 deletions src/gui/systray.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,14 +127,8 @@
}
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)
Expand Down Expand Up @@ -440,6 +434,22 @@
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();

Check warning on line 450 in src/gui/systray.cpp

View workflow job for this annotation

GitHub Actions / build

src/gui/systray.cpp:450:10 [modernize-use-trailing-return-type]

use a trailing return type for this function
}

void Systray::slotUnpauseAllFolders()
{
setPauseOnAllFoldersHelper(false);
Expand Down Expand Up @@ -572,6 +582,7 @@
} else {
slotUnpauseAllFolders();
}
emit syncIsPausedChanged();

Check warning on line 585 in src/gui/systray.cpp

View workflow job for this annotation

GitHub Actions / build

src/gui/systray.cpp:585:10 [modernize-use-trailing-return-type]

use a trailing return type for this function
}

/********************************************************************************************/
Expand Down
1 change: 1 addition & 0 deletions src/gui/systray.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
#ifndef SYSTRAY_H
#define SYSTRAY_H

#include <QSystemTrayIcon>

Check failure on line 18 in src/gui/systray.h

View workflow job for this annotation

GitHub Actions / build

src/gui/systray.h:18:10 [clang-diagnostic-error]

'QSystemTrayIcon' file not found

#include "accountmanager.h"
#include "tray/usermodel.h"
Expand Down Expand Up @@ -152,6 +152,7 @@
void presentShareViewInTray(const QString &localPath);

private slots:
void slotUpdateSyncPausedState();
void slotUnpauseAllFolders();
void slotPauseAllFolders();

Expand Down
Loading