From b0d43070277a104664fc85f091cc02af96de8a24 Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Thu, 3 Aug 2023 15:25:15 +0800 Subject: [PATCH] Extract folder now big activity generation into separate method Signed-off-by: Claudio Cambra --- src/gui/folder.cpp | 69 +++++++++++++++++++++++++--------------------- src/gui/folder.h | 1 + 2 files changed, 39 insertions(+), 31 deletions(-) diff --git a/src/gui/folder.cpp b/src/gui/folder.cpp index 1123b17a53a82..0511cba81a102 100644 --- a/src/gui/folder.cpp +++ b/src/gui/folder.cpp @@ -1289,37 +1289,7 @@ void Folder::slotExistingFolderNowBig(const QString &folderPath) } postExistingFolderNowBigNotification(folderPath); - - auto whitelistActivityLink = ActivityLink(); - whitelistActivityLink._label = tr("Keep syncing"); - whitelistActivityLink._primary = false; - whitelistActivityLink._verb = ActivityLink::WhitelistFolderVerb; - - QVector activityLinks = {whitelistActivityLink}; - - if (!stopSyncing) { - auto blacklistActivityLink = ActivityLink(); - blacklistActivityLink._label = tr("Stop syncing"); - blacklistActivityLink._primary = true; - blacklistActivityLink._verb = ActivityLink::BlacklistFolderVerb; - - activityLinks.append(blacklistActivityLink); - } - - auto existingFolderNowBigActivity = Activity(); - existingFolderNowBigActivity._type = Activity::NotificationType; - existingFolderNowBigActivity._dateTime = QDateTime::fromString(QDateTime::currentDateTime().toString(), Qt::ISODate); - existingFolderNowBigActivity._subject = - tr("The folder %1 has surpassed the set folder size limit of %2MB.").arg(folderPath, ConfigFile().newBigFolderSizeLimit().second); - existingFolderNowBigActivity._message = tr("Would you like to stop syncing this folder?"); - existingFolderNowBigActivity._accName = _accountState->account()->displayName(); - existingFolderNowBigActivity._folder = alias(); - existingFolderNowBigActivity._file = cleanPath() + '/' + trailSlashFolderPath; - existingFolderNowBigActivity._links = activityLinks; - existingFolderNowBigActivity._id = qHash(existingFolderNowBigActivity._file); - - const auto user = UserModel::instance()->findUserForAccount(_accountState.data()); - user->slotAddNotification(this, existingFolderNowBigActivity); + postExistingFolderNowBigActivity(folderPath); } } @@ -1333,6 +1303,43 @@ void Folder::postExistingFolderNowBigNotification(const QString &folderPath) Logger::instance()->postGuiLog(Theme::instance()->appNameGUI(), message); } +void Folder::postExistingFolderNowBigActivity(const QString &folderPath) const +{ + const auto stopSyncing = ConfigFile().stopSyncingExistingFoldersOverLimit(); + const auto trailSlashFolderPath = Utility::trailingSlashPath(folderPath); + + auto whitelistActivityLink = ActivityLink(); + whitelistActivityLink._label = tr("Keep syncing"); + whitelistActivityLink._primary = false; + whitelistActivityLink._verb = ActivityLink::WhitelistFolderVerb; + + QVector activityLinks = {whitelistActivityLink}; + + if (!stopSyncing) { + auto blacklistActivityLink = ActivityLink(); + blacklistActivityLink._label = tr("Stop syncing"); + blacklistActivityLink._primary = true; + blacklistActivityLink._verb = ActivityLink::BlacklistFolderVerb; + + activityLinks.append(blacklistActivityLink); + } + + auto existingFolderNowBigActivity = Activity(); + existingFolderNowBigActivity._type = Activity::NotificationType; + existingFolderNowBigActivity._dateTime = QDateTime::fromString(QDateTime::currentDateTime().toString(), Qt::ISODate); + existingFolderNowBigActivity._subject = + tr("The folder %1 has surpassed the set folder size limit of %2MB.").arg(folderPath, QString::number(ConfigFile().newBigFolderSizeLimit().second)); + existingFolderNowBigActivity._message = tr("Would you like to stop syncing this folder?"); + existingFolderNowBigActivity._accName = _accountState->account()->displayName(); + existingFolderNowBigActivity._folder = alias(); + existingFolderNowBigActivity._file = cleanPath() + '/' + trailSlashFolderPath; + existingFolderNowBigActivity._links = activityLinks; + existingFolderNowBigActivity._id = qHash(existingFolderNowBigActivity._file); + + const auto user = UserModel::instance()->findUserForAccount(_accountState.data()); + user->slotAddNotification(this, existingFolderNowBigActivity); +} + void Folder::slotLogPropagationStart() { _fileLog->logLap("Propagation starts"); diff --git a/src/gui/folder.h b/src/gui/folder.h index 77550e48903df..13f493102ee91 100644 --- a/src/gui/folder.h +++ b/src/gui/folder.h @@ -475,6 +475,7 @@ private slots: void removePathFromSelectiveSyncList(const QString &path, const SyncJournalDb::SelectiveSyncListType listType); static void postExistingFolderNowBigNotification(const QString &folderPath); + void postExistingFolderNowBigActivity(const QString &folderPath) const; AccountStatePtr _accountState; FolderDefinition _definition;