From 2e31dce2c0afd7f6993f61a01b60c773423a3f23 Mon Sep 17 00:00:00 2001 From: Mike Mengjie Huang Date: Sun, 13 Jul 2025 23:54:38 +0200 Subject: [PATCH 01/10] feat: Add more prominent quota warnings Signed-off-by: Mike Mengjie Huang --- src/gui/accountmanager.cpp | 1 + src/gui/generalsettings.cpp | 11 +++++++++++ src/gui/generalsettings.h | 1 + src/gui/generalsettings.ui | 7 +++++++ src/gui/tray/usermodel.cpp | 36 ++++++++++++++++++++++++++++++++++++ src/gui/tray/usermodel.h | 7 +++++++ src/libsync/configfile.cpp | 13 +++++++++++++ src/libsync/configfile.h | 4 ++++ 8 files changed, 80 insertions(+) diff --git a/src/gui/accountmanager.cpp b/src/gui/accountmanager.cpp index 76c94eb2a8..e78d760960 100644 --- a/src/gui/accountmanager.cpp +++ b/src/gui/accountmanager.cpp @@ -287,6 +287,7 @@ bool AccountManager::restoreFromLegacySettings() configFile.setPromptDeleteFiles(settings->value(ConfigFile::promptDeleteC, configFile.promptDeleteFiles()).toBool()); configFile.setShowCallNotifications(settings->value(ConfigFile::showCallNotificationsC, configFile.showCallNotifications()).toBool()); configFile.setShowChatNotifications(settings->value(ConfigFile::showChatNotificationsC, configFile.showChatNotifications()).toBool()); + configFile.setShowQuotaWarningNotifications(settings->value(ConfigFile::showQuotaWarningNotificationsC, configFile.showQuotaWarningNotifications()).toBool()); configFile.setShowInExplorerNavigationPane(settings->value(ConfigFile::showInExplorerNavigationPaneC, configFile.showInExplorerNavigationPane()).toBool()); ClientProxy().saveProxyConfigurationFromSettings(*settings); configFile.setUseUploadLimit(settings->value(ConfigFile::useUploadLimitC, configFile.useUploadLimit()).toInt()); diff --git a/src/gui/generalsettings.cpp b/src/gui/generalsettings.cpp index 10271ecc1e..e1656cffd0 100644 --- a/src/gui/generalsettings.cpp +++ b/src/gui/generalsettings.cpp @@ -195,6 +195,9 @@ GeneralSettings::GeneralSettings(QWidget *parent) this, &GeneralSettings::slotToggleCallNotifications); _ui->callNotificationsCheckBox->setToolTip(tr("Show call notification dialogs.")); + connect(_ui->quotaWarningNotificationsCheckBox, &QAbstractButton::toggled, this, &GeneralSettings::slotToggleQuotaWarningNotifications); + _ui->quotaWarningNotificationsCheckBox->setToolTip(tr("Receive notification when storage usage exceeds 80/90/95 percent")); + connect(_ui->showInExplorerNavigationPaneCheckBox, &QAbstractButton::toggled, this, &GeneralSettings::slotShowInExplorerNavigationPane); // Rename 'Explorer' appropriately on non-Windows @@ -298,6 +301,8 @@ void GeneralSettings::loadMiscSettings() _ui->chatNotificationsCheckBox->setChecked(cfgFile.showChatNotifications()); _ui->callNotificationsCheckBox->setEnabled(cfgFile.optionalServerNotifications()); _ui->callNotificationsCheckBox->setChecked(cfgFile.showCallNotifications()); + _ui->quotaWarningNotificationsCheckBox->setEnabled(cfgFile.optionalServerNotifications()); + _ui->quotaWarningNotificationsCheckBox->setChecked(cfgFile.showQuotaWarningNotifications()); _ui->showInExplorerNavigationPaneCheckBox->setChecked(cfgFile.showInExplorerNavigationPane()); _ui->newExternalStorage->setChecked(cfgFile.confirmExternalStorage()); _ui->monoIconsCheckBox->setChecked(cfgFile.monoIcons()); @@ -594,6 +599,12 @@ void GeneralSettings::slotToggleCallNotifications(bool enable) cfgFile.setShowCallNotifications(enable); } +void GeneralSettings::slotToggleQuotaWarningNotifications(bool enable) +{ + ConfigFile cfgFile; + cfgFile.setShowQuotaWarningNotifications(enable); +} + void GeneralSettings::slotShowInExplorerNavigationPane(bool checked) { ConfigFile cfgFile; diff --git a/src/gui/generalsettings.h b/src/gui/generalsettings.h index 2c52ff0080..b62a7b3c07 100644 --- a/src/gui/generalsettings.h +++ b/src/gui/generalsettings.h @@ -49,6 +49,7 @@ private slots: void slotToggleOptionalServerNotifications(bool); void slotToggleChatNotifications(bool); void slotToggleCallNotifications(bool); + void slotToggleQuotaWarningNotifications(bool); void slotShowInExplorerNavigationPane(bool); void slotIgnoreFilesEditor(); void slotCreateDebugArchive(); diff --git a/src/gui/generalsettings.ui b/src/gui/generalsettings.ui index 0a20f0b68c..b26f433ed2 100644 --- a/src/gui/generalsettings.ui +++ b/src/gui/generalsettings.ui @@ -58,6 +58,13 @@ + + + + Show &Quota Warning Notifications + + + diff --git a/src/gui/tray/usermodel.cpp b/src/gui/tray/usermodel.cpp index a2929b5339..7a15404bdf 100644 --- a/src/gui/tray/usermodel.cpp +++ b/src/gui/tray/usermodel.cpp @@ -24,12 +24,14 @@ #include "tray/talkreply.h" #include "userstatusconnector.h" +#include #include #include #include #include #include #include +#include // time span in milliseconds which has to be between two // refreshes of the notifications @@ -61,6 +63,7 @@ User::User(AccountStatePtr &account, const bool &isCurrent, QObject *parent) , _isCurrentUser(isCurrent) , _activityModel(new ActivityListModel(_account.data(), this)) , _unifiedSearchResultsModel(new UnifiedSearchResultsListModel(_account.data(), this)) + , _userInfo(account.data(), false, true) { connect(ProgressDispatcher::instance(), &ProgressDispatcher::progressInfo, this, &User::slotProgressInfo); @@ -118,6 +121,9 @@ User::User(AccountStatePtr &account, const bool &isCurrent, QObject *parent) showDesktopNotification(certificateNeedMigration); } }); + + _userInfo.setActive(true); + connect(&_userInfo, &UserInfo::quotaUpdated, this, &User::slotUpdateQuota); } void User::checkNotifiedNotifications() @@ -1192,6 +1198,36 @@ void User::slotFetchGroupFolders() connect(groupFolderListJob, &SimpleNetworkJob::finishedSignal, this, &User::slotGroupFoldersFetched); } +void User::slotUpdateQuota(qint64 total, qint64 used) +{ + if (total <= 0 || !ConfigFile().showQuotaWarningNotifications()) { + return; + } + + const auto percent = (double)used / (double)total * 100.0; + const auto percentInt = qMin(qRound(percent), 100); + qCDebug(lcActivity) << tr("Quota is updated; %1 percent of the total space is used.").arg(QString::number(percentInt)); + + int threshold_passed = 0; + if (_lastQuotaPercent < 80 && percentInt >= 80) threshold_passed = 80; + if (_lastQuotaPercent < 90 && percentInt >= 90) threshold_passed = 90; + if (_lastQuotaPercent < 95 && percentInt >= 95) threshold_passed = 95; + + if (threshold_passed > 0) { + _activityModel->removeActivityFromActivityList(_lastQuotaActivity); + + const auto localFolderName = getFolder(); + _lastQuotaActivity._type = Activity::OpenSettingsNotificationType; + _lastQuotaActivity._dateTime = QDateTime::fromString(QDateTime::currentDateTime().toString(), Qt::ISODate); + _lastQuotaActivity._subject = tr("Quota Warning - %1 percent or more storage in use").arg(QString::number(threshold_passed)); + _lastQuotaActivity._accName = account()->displayName(); + _lastQuotaActivity._id = qHash(QDateTime::currentMSecsSinceEpoch()); + showDesktopNotification(_lastQuotaActivity); + _activityModel->addNotificationToActivityList(_lastQuotaActivity); + } + _lastQuotaPercent = percentInt; +} + void User::slotGroupFoldersFetched(QNetworkReply *reply) { Q_ASSERT(reply); diff --git a/src/gui/tray/usermodel.h b/src/gui/tray/usermodel.h index e8ca2a153b..2b963772d5 100644 --- a/src/gui/tray/usermodel.h +++ b/src/gui/tray/usermodel.h @@ -18,6 +18,7 @@ #include "activitydata.h" #include "activitylistmodel.h" #include "folderman.h" +#include "userinfo.h" #include "userstatusconnector.h" #include "userstatusselectormodel.h" #include @@ -153,6 +154,7 @@ public slots: void forceSyncNow() const; void slotAccountCapabilitiesChangedRefreshGroupFolders(); void slotFetchGroupFolders(); + void slotUpdateQuota(qint64 total, qint64 used); private slots: void slotPushNotificationsReady(); @@ -188,6 +190,7 @@ private: ActivityListModel *_activityModel; UnifiedSearchResultsListModel *_unifiedSearchResultsModel; ActivityList _blacklistedNotifications; + UserInfo _userInfo; QVariantList _trayFolderInfos; @@ -206,6 +209,10 @@ private: int _lastTalkNotificationsReceivedCount = 0; bool _isNotificationFetchRunning = false; + + // used for quota warnings + int _lastQuotaPercent = 0; + Activity _lastQuotaActivity; }; class UserModel : public QAbstractListModel diff --git a/src/libsync/configfile.cpp b/src/libsync/configfile.cpp index d512fba3af..71ac126d46 100644 --- a/src/libsync/configfile.cpp +++ b/src/libsync/configfile.cpp @@ -216,6 +216,19 @@ void ConfigFile::setShowCallNotifications(bool show) settings.sync(); } +bool ConfigFile::showQuotaWarningNotifications() const +{ + const QSettings settings(configFile(), QSettings::IniFormat); + return settings.value(showQuotaWarningNotificationsC, true).toBool() && optionalServerNotifications(); +} + +void ConfigFile::setShowQuotaWarningNotifications(bool show) +{ + QSettings settings(configFile(), QSettings::IniFormat); + settings.setValue(showQuotaWarningNotificationsC, show); + settings.sync(); +} + bool ConfigFile::showInExplorerNavigationPane() const { const bool defaultValue = diff --git a/src/libsync/configfile.h b/src/libsync/configfile.h index c2b22f0c6e..92f960a5c5 100644 --- a/src/libsync/configfile.h +++ b/src/libsync/configfile.h @@ -165,6 +165,9 @@ public: [[nodiscard]] bool showCallNotifications() const; void setShowCallNotifications(bool show); + [[nodiscard]] bool showQuotaWarningNotifications() const; + void setShowQuotaWarningNotifications(bool show); + [[nodiscard]] bool showInExplorerNavigationPane() const; void setShowInExplorerNavigationPane(bool show); @@ -257,6 +260,7 @@ public: static constexpr char optionalServerNotificationsC[] = "optionalServerNotifications"; static constexpr char promptDeleteC[] = "promptDeleteAllFiles"; static constexpr char showCallNotificationsC[] = "showCallNotifications"; + static constexpr char showQuotaWarningNotificationsC[] = "showQuotaWarningNotifications"; static constexpr char showChatNotificationsC[] = "showChatNotifications"; static constexpr char showInExplorerNavigationPaneC[] = "showInExplorerNavigationPane"; From d62c9ebdb6d7c39dd6377e31091b2d113fbfabf3 Mon Sep 17 00:00:00 2001 From: Mike Mengjie Huang Date: Mon, 14 Jul 2025 22:43:09 +0200 Subject: [PATCH 02/10] fix: Change code formatting and description string Signed-off-by: Mike Mengjie Huang --- src/gui/generalsettings.cpp | 2 +- src/gui/tray/usermodel.cpp | 14 +++++++++++--- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/gui/generalsettings.cpp b/src/gui/generalsettings.cpp index e1656cffd0..a78760767e 100644 --- a/src/gui/generalsettings.cpp +++ b/src/gui/generalsettings.cpp @@ -196,7 +196,7 @@ GeneralSettings::GeneralSettings(QWidget *parent) _ui->callNotificationsCheckBox->setToolTip(tr("Show call notification dialogs.")); connect(_ui->quotaWarningNotificationsCheckBox, &QAbstractButton::toggled, this, &GeneralSettings::slotToggleQuotaWarningNotifications); - _ui->quotaWarningNotificationsCheckBox->setToolTip(tr("Receive notification when storage usage exceeds 80/90/95 percent")); + _ui->quotaWarningNotificationsCheckBox->setToolTip(tr("Show notification when quota usage exceeds 80%")); connect(_ui->showInExplorerNavigationPaneCheckBox, &QAbstractButton::toggled, this, &GeneralSettings::slotShowInExplorerNavigationPane); diff --git a/src/gui/tray/usermodel.cpp b/src/gui/tray/usermodel.cpp index 7a15404bdf..bbfbc2c4e1 100644 --- a/src/gui/tray/usermodel.cpp +++ b/src/gui/tray/usermodel.cpp @@ -1209,9 +1209,17 @@ void User::slotUpdateQuota(qint64 total, qint64 used) qCDebug(lcActivity) << tr("Quota is updated; %1 percent of the total space is used.").arg(QString::number(percentInt)); int threshold_passed = 0; - if (_lastQuotaPercent < 80 && percentInt >= 80) threshold_passed = 80; - if (_lastQuotaPercent < 90 && percentInt >= 90) threshold_passed = 90; - if (_lastQuotaPercent < 95 && percentInt >= 95) threshold_passed = 95; + if (_lastQuotaPercent < 80 && percentInt >= 80) { + threshold_passed = 80; + } + + if (_lastQuotaPercent < 90 && percentInt >= 90) { + threshold_passed = 90; + } + + if (_lastQuotaPercent < 95 && percentInt >= 95) { + threshold_passed = 95; + } if (threshold_passed > 0) { _activityModel->removeActivityFromActivityList(_lastQuotaActivity); From b61a87074d9f8a23694ea7a6258d431608e0ba1f Mon Sep 17 00:00:00 2001 From: Mike Mengjie Huang Date: Sun, 13 Jul 2025 23:54:38 +0200 Subject: [PATCH 03/10] feat: Add more prominent quota warnings Signed-off-by: Mike Mengjie Huang --- src/gui/generalsettings.cpp | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/gui/generalsettings.cpp b/src/gui/generalsettings.cpp index a78760767e..6a0f4c684d 100644 --- a/src/gui/generalsettings.cpp +++ b/src/gui/generalsettings.cpp @@ -195,9 +195,6 @@ GeneralSettings::GeneralSettings(QWidget *parent) this, &GeneralSettings::slotToggleCallNotifications); _ui->callNotificationsCheckBox->setToolTip(tr("Show call notification dialogs.")); - connect(_ui->quotaWarningNotificationsCheckBox, &QAbstractButton::toggled, this, &GeneralSettings::slotToggleQuotaWarningNotifications); - _ui->quotaWarningNotificationsCheckBox->setToolTip(tr("Show notification when quota usage exceeds 80%")); - connect(_ui->showInExplorerNavigationPaneCheckBox, &QAbstractButton::toggled, this, &GeneralSettings::slotShowInExplorerNavigationPane); // Rename 'Explorer' appropriately on non-Windows From 6ccc795c372d23a7c3eb00740ea4ad3355a3a001 Mon Sep 17 00:00:00 2001 From: Mike Mengjie Huang Date: Mon, 14 Jul 2025 22:43:09 +0200 Subject: [PATCH 04/10] fix: Change code formatting and description string Signed-off-by: Mike Mengjie Huang --- src/gui/generalsettings.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/gui/generalsettings.cpp b/src/gui/generalsettings.cpp index 6a0f4c684d..a78760767e 100644 --- a/src/gui/generalsettings.cpp +++ b/src/gui/generalsettings.cpp @@ -195,6 +195,9 @@ GeneralSettings::GeneralSettings(QWidget *parent) this, &GeneralSettings::slotToggleCallNotifications); _ui->callNotificationsCheckBox->setToolTip(tr("Show call notification dialogs.")); + connect(_ui->quotaWarningNotificationsCheckBox, &QAbstractButton::toggled, this, &GeneralSettings::slotToggleQuotaWarningNotifications); + _ui->quotaWarningNotificationsCheckBox->setToolTip(tr("Show notification when quota usage exceeds 80%")); + connect(_ui->showInExplorerNavigationPaneCheckBox, &QAbstractButton::toggled, this, &GeneralSettings::slotShowInExplorerNavigationPane); // Rename 'Explorer' appropriately on non-Windows From e63458121c3b966e381bea0861ae6704ee6345bf Mon Sep 17 00:00:00 2001 From: Mike Mengjie Huang Date: Sat, 9 Aug 2025 17:28:15 +0200 Subject: [PATCH 05/10] perf: Use existing quota info instead of polling Signed-off-by: Mike Mengjie Huang --- src/gui/tray/usermodel.cpp | 11 ++++------- src/gui/tray/usermodel.h | 3 +-- src/libsync/account.h | 1 + src/libsync/discovery.cpp | 4 ++++ src/libsync/discovery.h | 1 + src/libsync/syncengine.cpp | 1 + 6 files changed, 12 insertions(+), 9 deletions(-) diff --git a/src/gui/tray/usermodel.cpp b/src/gui/tray/usermodel.cpp index bbfbc2c4e1..d86c4ec260 100644 --- a/src/gui/tray/usermodel.cpp +++ b/src/gui/tray/usermodel.cpp @@ -63,7 +63,6 @@ User::User(AccountStatePtr &account, const bool &isCurrent, QObject *parent) , _isCurrentUser(isCurrent) , _activityModel(new ActivityListModel(_account.data(), this)) , _unifiedSearchResultsModel(new UnifiedSearchResultsListModel(_account.data(), this)) - , _userInfo(account.data(), false, true) { connect(ProgressDispatcher::instance(), &ProgressDispatcher::progressInfo, this, &User::slotProgressInfo); @@ -86,6 +85,7 @@ User::User(AccountStatePtr &account, const bool &isCurrent, QObject *parent) connect(_account.data(), &AccountState::hasFetchedNavigationApps, this, &User::slotRebuildNavigationAppList); connect(_account->account().data(), &Account::accountChangedDisplayName, this, &User::nameChanged); + connect(_account->account().data(), &Account::rootFolderQuotaChanged, this, &User::slotQuotaChanged); connect(FolderMan::instance(), &FolderMan::folderListChanged, this, &User::hasLocalFolderChanged); @@ -121,9 +121,6 @@ User::User(AccountStatePtr &account, const bool &isCurrent, QObject *parent) showDesktopNotification(certificateNeedMigration); } }); - - _userInfo.setActive(true); - connect(&_userInfo, &UserInfo::quotaUpdated, this, &User::slotUpdateQuota); } void User::checkNotifiedNotifications() @@ -1198,13 +1195,14 @@ void User::slotFetchGroupFolders() connect(groupFolderListJob, &SimpleNetworkJob::finishedSignal, this, &User::slotGroupFoldersFetched); } -void User::slotUpdateQuota(qint64 total, qint64 used) +void User::slotQuotaChanged(const int64_t &usedBytes, const int64_t &availableBytes) { + int64_t total = usedBytes + availableBytes; if (total <= 0 || !ConfigFile().showQuotaWarningNotifications()) { return; } - const auto percent = (double)used / (double)total * 100.0; + const auto percent = (double)usedBytes / (double)total * 100.0; const auto percentInt = qMin(qRound(percent), 100); qCDebug(lcActivity) << tr("Quota is updated; %1 percent of the total space is used.").arg(QString::number(percentInt)); @@ -1224,7 +1222,6 @@ void User::slotUpdateQuota(qint64 total, qint64 used) if (threshold_passed > 0) { _activityModel->removeActivityFromActivityList(_lastQuotaActivity); - const auto localFolderName = getFolder(); _lastQuotaActivity._type = Activity::OpenSettingsNotificationType; _lastQuotaActivity._dateTime = QDateTime::fromString(QDateTime::currentDateTime().toString(), Qt::ISODate); _lastQuotaActivity._subject = tr("Quota Warning - %1 percent or more storage in use").arg(QString::number(threshold_passed)); diff --git a/src/gui/tray/usermodel.h b/src/gui/tray/usermodel.h index 2b963772d5..0f7fd54834 100644 --- a/src/gui/tray/usermodel.h +++ b/src/gui/tray/usermodel.h @@ -154,7 +154,6 @@ public slots: void forceSyncNow() const; void slotAccountCapabilitiesChangedRefreshGroupFolders(); void slotFetchGroupFolders(); - void slotUpdateQuota(qint64 total, qint64 used); private slots: void slotPushNotificationsReady(); @@ -163,6 +162,7 @@ private slots: void slotReceivedPushActivity(OCC::Account *account); void slotCheckExpiredActivities(); void slotGroupFoldersFetched(QNetworkReply *reply); + void slotQuotaChanged(const int64_t &usedBytes, const int64_t &availableBytes); void checkNotifiedNotifications(); void showDesktopNotification(const QString &title, const QString &message, const long notificationId); void showDesktopNotification(const OCC::Activity &activity); @@ -190,7 +190,6 @@ private: ActivityListModel *_activityModel; UnifiedSearchResultsListModel *_unifiedSearchResultsModel; ActivityList _blacklistedNotifications; - UserInfo _userInfo; QVariantList _trayFolderInfos; diff --git a/src/libsync/account.h b/src/libsync/account.h index 5434904ec5..bbb198762d 100644 --- a/src/libsync/account.h +++ b/src/libsync/account.h @@ -470,6 +470,7 @@ signals: void encryptionCertificateFingerprintChanged(); void userCertificateNeedsMigrationChanged(); + void rootFolderQuotaChanged(const int64_t &usedBytes, const int64_t &availableBytes); protected Q_SLOTS: void slotCredentialsFetched(); void slotCredentialsAsked(); diff --git a/src/libsync/discovery.cpp b/src/libsync/discovery.cpp index 1b314040d6..c3070b66bf 100644 --- a/src/libsync/discovery.cpp +++ b/src/libsync/discovery.cpp @@ -2299,6 +2299,10 @@ void ProcessDirectoryJob::setFolderQuota(const FolderQuota &folderQuota) { _folderQuota.bytesUsed = folderQuota.bytesUsed; _folderQuota.bytesAvailable = folderQuota.bytesAvailable; + + if (_currentFolder._original == "") { + emit updatedRootFolderQuota(_folderQuota.bytesUsed, _folderQuota.bytesAvailable); + } } void ProcessDirectoryJob::startAsyncLocalQuery() diff --git a/src/libsync/discovery.h b/src/libsync/discovery.h index 164de5662c..123d1153b5 100644 --- a/src/libsync/discovery.h +++ b/src/libsync/discovery.h @@ -305,6 +305,7 @@ signals: void finished(); // The root etag of this directory was fetched void etag(const QByteArray &, const QDateTime &time); + void updatedRootFolderQuota(const int64_t &bytesUSed, const int64_t &bytesAvailable); private slots: void setFolderQuota(const FolderQuota &folderQuota); diff --git a/src/libsync/syncengine.cpp b/src/libsync/syncengine.cpp index 7b4b69f4f9..a9ca164038 100644 --- a/src/libsync/syncengine.cpp +++ b/src/libsync/syncengine.cpp @@ -760,6 +760,7 @@ void SyncEngine::startSync() _discoveryPhase->startJob(discoveryJob); connect(discoveryJob, &ProcessDirectoryJob::etag, this, &SyncEngine::slotRootEtagReceived); + connect(discoveryJob, &ProcessDirectoryJob::updatedRootFolderQuota, account().data(), &Account::rootFolderQuotaChanged); connect(_discoveryPhase.get(), &DiscoveryPhase::addErrorToGui, this, &SyncEngine::addErrorToGui); } From 60fe1dbc3f812354b151dcdc3e24e0cc90b43308 Mon Sep 17 00:00:00 2001 From: mike0609king <57289368+mike0609king@users.noreply.github.com> Date: Sat, 13 Sep 2025 15:48:20 +0200 Subject: [PATCH 06/10] style: Apply suggestions from code review Co-authored-by: Camila Ayres Signed-off-by: mike0609king <57289368+mike0609king@users.noreply.github.com> --- src/gui/tray/usermodel.cpp | 2 +- src/libsync/discovery.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gui/tray/usermodel.cpp b/src/gui/tray/usermodel.cpp index d86c4ec260..d52d132340 100644 --- a/src/gui/tray/usermodel.cpp +++ b/src/gui/tray/usermodel.cpp @@ -1206,7 +1206,7 @@ void User::slotQuotaChanged(const int64_t &usedBytes, const int64_t &availableBy const auto percentInt = qMin(qRound(percent), 100); qCDebug(lcActivity) << tr("Quota is updated; %1 percent of the total space is used.").arg(QString::number(percentInt)); - int threshold_passed = 0; + int thresholdPassed = 0; if (_lastQuotaPercent < 80 && percentInt >= 80) { threshold_passed = 80; } diff --git a/src/libsync/discovery.cpp b/src/libsync/discovery.cpp index c3070b66bf..a5e53ce32b 100644 --- a/src/libsync/discovery.cpp +++ b/src/libsync/discovery.cpp @@ -2300,7 +2300,7 @@ void ProcessDirectoryJob::setFolderQuota(const FolderQuota &folderQuota) _folderQuota.bytesUsed = folderQuota.bytesUsed; _folderQuota.bytesAvailable = folderQuota.bytesAvailable; - if (_currentFolder._original == "") { + if (_currentFolder._original.isEmpty()) { emit updatedRootFolderQuota(_folderQuota.bytesUsed, _folderQuota.bytesAvailable); } } From 2d9ad0227e0c97322b7773119abf7af6670fde6c Mon Sep 17 00:00:00 2001 From: Mike Mengjie Huang Date: Sat, 13 Sep 2025 16:29:15 +0200 Subject: [PATCH 07/10] fix: Apply suggested change and modify quota warning tool tip Signed-off-by: Mike Mengjie Huang --- src/gui/generalsettings.cpp | 2 +- src/gui/tray/usermodel.cpp | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/gui/generalsettings.cpp b/src/gui/generalsettings.cpp index a78760767e..a9b3c6c818 100644 --- a/src/gui/generalsettings.cpp +++ b/src/gui/generalsettings.cpp @@ -196,7 +196,7 @@ GeneralSettings::GeneralSettings(QWidget *parent) _ui->callNotificationsCheckBox->setToolTip(tr("Show call notification dialogs.")); connect(_ui->quotaWarningNotificationsCheckBox, &QAbstractButton::toggled, this, &GeneralSettings::slotToggleQuotaWarningNotifications); - _ui->quotaWarningNotificationsCheckBox->setToolTip(tr("Show notification when quota usage exceeds 80%")); + _ui->quotaWarningNotificationsCheckBox->setToolTip(tr("Show notification when quota usage exceeds 80%.")); connect(_ui->showInExplorerNavigationPaneCheckBox, &QAbstractButton::toggled, this, &GeneralSettings::slotShowInExplorerNavigationPane); diff --git a/src/gui/tray/usermodel.cpp b/src/gui/tray/usermodel.cpp index d52d132340..f5a7946071 100644 --- a/src/gui/tray/usermodel.cpp +++ b/src/gui/tray/usermodel.cpp @@ -1208,23 +1208,23 @@ void User::slotQuotaChanged(const int64_t &usedBytes, const int64_t &availableBy int thresholdPassed = 0; if (_lastQuotaPercent < 80 && percentInt >= 80) { - threshold_passed = 80; + thresholdPassed = 80; } if (_lastQuotaPercent < 90 && percentInt >= 90) { - threshold_passed = 90; + thresholdPassed = 90; } if (_lastQuotaPercent < 95 && percentInt >= 95) { - threshold_passed = 95; + thresholdPassed = 95; } - if (threshold_passed > 0) { + if (thresholdPassed > 0) { _activityModel->removeActivityFromActivityList(_lastQuotaActivity); _lastQuotaActivity._type = Activity::OpenSettingsNotificationType; _lastQuotaActivity._dateTime = QDateTime::fromString(QDateTime::currentDateTime().toString(), Qt::ISODate); - _lastQuotaActivity._subject = tr("Quota Warning - %1 percent or more storage in use").arg(QString::number(threshold_passed)); + _lastQuotaActivity._subject = tr("Quota Warning - %1 percent or more storage in use").arg(QString::number(thresholdPassed)); _lastQuotaActivity._accName = account()->displayName(); _lastQuotaActivity._id = qHash(QDateTime::currentMSecsSinceEpoch()); showDesktopNotification(_lastQuotaActivity); From 7dd7dad140a35ebe48a7355712508dc35f521844 Mon Sep 17 00:00:00 2001 From: Mike Mengjie Huang Date: Sun, 13 Jul 2025 23:54:38 +0200 Subject: [PATCH 08/10] feat: Add more prominent quota warnings Signed-off-by: Mike Mengjie Huang --- src/gui/tray/usermodel.cpp | 4 ++++ src/gui/tray/usermodel.h | 2 ++ 2 files changed, 6 insertions(+) diff --git a/src/gui/tray/usermodel.cpp b/src/gui/tray/usermodel.cpp index f5a7946071..3d60115290 100644 --- a/src/gui/tray/usermodel.cpp +++ b/src/gui/tray/usermodel.cpp @@ -63,6 +63,7 @@ User::User(AccountStatePtr &account, const bool &isCurrent, QObject *parent) , _isCurrentUser(isCurrent) , _activityModel(new ActivityListModel(_account.data(), this)) , _unifiedSearchResultsModel(new UnifiedSearchResultsListModel(_account.data(), this)) + , _userInfo(account.data(), false, true) { connect(ProgressDispatcher::instance(), &ProgressDispatcher::progressInfo, this, &User::slotProgressInfo); @@ -121,6 +122,9 @@ User::User(AccountStatePtr &account, const bool &isCurrent, QObject *parent) showDesktopNotification(certificateNeedMigration); } }); + + _userInfo.setActive(true); + connect(&_userInfo, &UserInfo::quotaUpdated, this, &User::slotUpdateQuota); } void User::checkNotifiedNotifications() diff --git a/src/gui/tray/usermodel.h b/src/gui/tray/usermodel.h index 0f7fd54834..cf8e792452 100644 --- a/src/gui/tray/usermodel.h +++ b/src/gui/tray/usermodel.h @@ -154,6 +154,7 @@ public slots: void forceSyncNow() const; void slotAccountCapabilitiesChangedRefreshGroupFolders(); void slotFetchGroupFolders(); + void slotUpdateQuota(qint64 total, qint64 used); private slots: void slotPushNotificationsReady(); @@ -190,6 +191,7 @@ private: ActivityListModel *_activityModel; UnifiedSearchResultsListModel *_unifiedSearchResultsModel; ActivityList _blacklistedNotifications; + UserInfo _userInfo; QVariantList _trayFolderInfos; From 3608c49f9ee631faa85582b844c61b5f4d1efbf0 Mon Sep 17 00:00:00 2001 From: Mike Mengjie Huang Date: Sat, 9 Aug 2025 17:28:15 +0200 Subject: [PATCH 09/10] perf: Use existing quota info instead of polling Signed-off-by: Mike Mengjie Huang --- src/gui/tray/usermodel.cpp | 4 ---- src/gui/tray/usermodel.h | 2 -- 2 files changed, 6 deletions(-) diff --git a/src/gui/tray/usermodel.cpp b/src/gui/tray/usermodel.cpp index 3d60115290..f5a7946071 100644 --- a/src/gui/tray/usermodel.cpp +++ b/src/gui/tray/usermodel.cpp @@ -63,7 +63,6 @@ User::User(AccountStatePtr &account, const bool &isCurrent, QObject *parent) , _isCurrentUser(isCurrent) , _activityModel(new ActivityListModel(_account.data(), this)) , _unifiedSearchResultsModel(new UnifiedSearchResultsListModel(_account.data(), this)) - , _userInfo(account.data(), false, true) { connect(ProgressDispatcher::instance(), &ProgressDispatcher::progressInfo, this, &User::slotProgressInfo); @@ -122,9 +121,6 @@ User::User(AccountStatePtr &account, const bool &isCurrent, QObject *parent) showDesktopNotification(certificateNeedMigration); } }); - - _userInfo.setActive(true); - connect(&_userInfo, &UserInfo::quotaUpdated, this, &User::slotUpdateQuota); } void User::checkNotifiedNotifications() diff --git a/src/gui/tray/usermodel.h b/src/gui/tray/usermodel.h index cf8e792452..0f7fd54834 100644 --- a/src/gui/tray/usermodel.h +++ b/src/gui/tray/usermodel.h @@ -154,7 +154,6 @@ public slots: void forceSyncNow() const; void slotAccountCapabilitiesChangedRefreshGroupFolders(); void slotFetchGroupFolders(); - void slotUpdateQuota(qint64 total, qint64 used); private slots: void slotPushNotificationsReady(); @@ -191,7 +190,6 @@ private: ActivityListModel *_activityModel; UnifiedSearchResultsListModel *_unifiedSearchResultsModel; ActivityList _blacklistedNotifications; - UserInfo _userInfo; QVariantList _trayFolderInfos; From 2f1c5f2c0cbe2c0b3721bb1b06852508d1056897 Mon Sep 17 00:00:00 2001 From: Mike Mengjie Huang Date: Sat, 13 Sep 2025 18:42:03 +0200 Subject: [PATCH 10/10] fix: Typo in function parameter Signed-off-by: Mike Mengjie Huang --- src/libsync/discovery.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libsync/discovery.h b/src/libsync/discovery.h index 123d1153b5..1dc2de2350 100644 --- a/src/libsync/discovery.h +++ b/src/libsync/discovery.h @@ -305,7 +305,7 @@ signals: void finished(); // The root etag of this directory was fetched void etag(const QByteArray &, const QDateTime &time); - void updatedRootFolderQuota(const int64_t &bytesUSed, const int64_t &bytesAvailable); + void updatedRootFolderQuota(const int64_t &bytesUsed, const int64_t &bytesAvailable); private slots: void setFolderQuota(const FolderQuota &folderQuota);