From 53a822fe16e496695ac1938e13b5fd9a05dc70c4 Mon Sep 17 00:00:00 2001 From: Matthieu Gallien Date: Fri, 13 Sep 2024 12:25:29 +0200 Subject: [PATCH] count the files deletion and warn if threshold is exceeded Signed-off-by: Matthieu Gallien [skip ci] --- src/libsync/configfile.cpp | 15 ++++++++++++++- src/libsync/configfile.h | 3 +++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/libsync/configfile.cpp b/src/libsync/configfile.cpp index 05dcfbbf6e531..e2f4c307103b5 100644 --- a/src/libsync/configfile.cpp +++ b/src/libsync/configfile.cpp @@ -59,6 +59,7 @@ static constexpr char fullLocalDiscoveryIntervalC[] = "fullLocalDiscoveryInterva static constexpr char notificationRefreshIntervalC[] = "notificationRefreshInterval"; static constexpr char monoIconsC[] = "monoIcons"; static constexpr char promptDeleteC[] = "promptDeleteAllFiles"; +static constexpr char deleteFilesThresholdC[] = "deleteFilesThreshold"; static constexpr char crashReporterC[] = "crashReporter"; static constexpr char optionalServerNotificationsC[] = "optionalServerNotifications"; static constexpr char showCallNotificationsC[] = "showCallNotifications"; @@ -1019,7 +1020,7 @@ bool ConfigFile::showMainDialogAsNormalWindow() const { bool ConfigFile::promptDeleteFiles() const { QSettings settings(configFile(), QSettings::IniFormat); - return settings.value(QLatin1String(promptDeleteC), false).toBool(); + return settings.value(QLatin1String(promptDeleteC), true).toBool(); } void ConfigFile::setPromptDeleteFiles(bool promptDeleteFiles) @@ -1028,6 +1029,18 @@ void ConfigFile::setPromptDeleteFiles(bool promptDeleteFiles) settings.setValue(QLatin1String(promptDeleteC), promptDeleteFiles); } +int ConfigFile::deleteFilesThreshold() const +{ + QSettings settings(configFile(), QSettings::IniFormat); + return settings.value(QLatin1String(deleteFilesThresholdC), deleteFilesThresholdDefaultValue).toInt(); +} + +void ConfigFile::setDeleteFilesThreshold(int thresholdValue) +{ + QSettings settings(configFile(), QSettings::IniFormat); + settings.setValue(QLatin1String(deleteFilesThresholdC), thresholdValue); +} + bool ConfigFile::monoIcons() const { QSettings settings(configFile(), QSettings::IniFormat); diff --git a/src/libsync/configfile.h b/src/libsync/configfile.h index 7ae1f98df207b..c3a2ccbf2c3df 100644 --- a/src/libsync/configfile.h +++ b/src/libsync/configfile.h @@ -93,6 +93,9 @@ class OWNCLOUDSYNC_EXPORT ConfigFile [[nodiscard]] bool promptDeleteFiles() const; void setPromptDeleteFiles(bool promptDeleteFiles); + [[nodiscard]] int deleteFilesThreshold() const; + void setDeleteFilesThreshold(int thresholdValue); + [[nodiscard]] bool crashReporter() const; void setCrashReporter(bool enabled);