By default do not display warning about backups made of the config file.
authorCamila <hello@camila.codes>
Wed, 1 Feb 2023 16:25:24 +0000 (17:25 +0100)
committerMatthieu Gallien <matthieu_gallien@yahoo.fr>
Thu, 2 Feb 2023 07:44:48 +0000 (08:44 +0100)
Use the setting showConfigBackupWarning to change the default value.

Signed-off-by: Camila <hello@camila.codes>
src/gui/application.cpp
src/libsync/configfile.cpp
src/libsync/configfile.h

index f82604e739bb0752ed8a1727c314d21dea3bfd51..acdd45e542b977baa8665069b933b39ce60b94bf 100644 (file)
@@ -147,15 +147,11 @@ bool Application::configVersionMigration()
     const auto versionChanged = previousVersion != currentVersion;
     const auto downgrading = previousVersion > currentVersion;
 
-    // We want to message the user either for destructive changes,
-    // or if we're ignoring something and the client version changed.
-    const auto showWarning = !deleteKeys.isEmpty() || (!ignoreKeys.isEmpty() && versionChanged);
-
-    if (!versionChanged && !showWarning) {
+    if (!versionChanged && !(!deleteKeys.isEmpty() || (!ignoreKeys.isEmpty() && versionChanged))) {
         return true;
     }
 
-    // back up all old config file
+    // back up all old config files
     QStringList backupFilesList;
     QDir configDir(configFile.configPath());
     const auto anyConfigFileNameList = configDir.entryInfoList({"*.cfg"}, QDir::Files);
@@ -171,7 +167,9 @@ bool Application::configVersionMigration()
         }
     }
 
-    if (showWarning || backupFilesList.count() > 0) {
+    // We want to message the user either for destructive changes,
+    // or if we're ignoring something and the client version changed.
+    if (configFile.showConfigBackupWarning() && backupFilesList.count() > 0) {
         QMessageBox box(
             QMessageBox::Warning,
             APPLICATION_SHORTNAME,
index 529dabf77c9369086366e4b5a26735ea780afe14..c2c2cbca03fde37ef9c396c97dae9c85fcf34344 100644 (file)
@@ -51,6 +51,7 @@
 
 namespace {
 static constexpr char showMainDialogAsNormalWindowC[] = "showMainDialogAsNormalWindow";
+static constexpr char showConfigBackupWarningC[] = "showConfigBackupWarning";
 
 static constexpr char remotePollIntervalC[] = "remotePollInterval";
 static constexpr char forceSyncIntervalC[] = "forceSyncInterval";
@@ -456,6 +457,11 @@ QString ConfigFile::backup(const QString &fileName) const
     return backupFile;
 }
 
+bool ConfigFile::showConfigBackupWarning() const
+{
+    return getValue(showConfigBackupWarningC, QString(), false).toBool();
+}
+
 QString ConfigFile::configFile() const
 {
     return configPath() + Theme::instance()->configFileName();
index a0c7f8b6df0e105a6ba2e12cd8175ff273d9ca42..9284d4ea25132ea81dc643817f71325cb47c9310 100644 (file)
@@ -54,6 +54,10 @@ public:
      * Returns the path of the new backup.
      */
     [[nodiscard]] QString backup(const QString &fileName) const;
+    /**
+     * Display warning with a list of the config files that were backed up
+     */
+    [[nodiscard]] bool showConfigBackupWarning() const;
 
     bool exists();