General Settings: Make sure to reload the settings when an account is added
authorOlivier Goffart <ogoffart@woboq.com>
Thu, 26 Jan 2017 09:00:19 +0000 (10:00 +0100)
committerMarkus Goetz <markus@woboq.com>
Fri, 27 Jan 2017 14:59:59 +0000 (15:59 +0100)
The Size limit, or confirmation checkboxes might have changed.

We need to guard against saving if the control changes while we are loading

Issue: https://github.com/owncloud/client/pull/5340#issuecomment-274878023

src/gui/generalsettings.cpp
src/gui/generalsettings.h

index 25a3c2828457ca12f4ddb16994764045c484a267..c4474b5e21dd810dcee1c447603d8b9bdc79e0b9 100644 (file)
@@ -32,6 +32,7 @@
 
 #include <QNetworkProxy>
 #include <QDir>
+#include <QScopedValueRollback>
 
 namespace OCC {
 
@@ -66,6 +67,7 @@ GeneralSettings::GeneralSettings(QWidget *parent) :
     connect(_ui->crashreporterCheckBox, SIGNAL(toggled(bool)), SLOT(saveMiscSettings()));
     connect(_ui->newFolderLimitCheckBox, SIGNAL(toggled(bool)), SLOT(saveMiscSettings()));
     connect(_ui->newFolderLimitSpinBox, SIGNAL(valueChanged(int)), SLOT(saveMiscSettings()));
+    connect(_ui->newExternalStorage, SIGNAL(toggled(bool)), SLOT(saveMiscSettings()));
 
 #ifndef WITH_CRASHREPORTER
     _ui->crashreporterCheckBox->setVisible(false);
@@ -85,6 +87,9 @@ GeneralSettings::GeneralSettings(QWidget *parent) :
     _ui->monoIconsCheckBox->setVisible(QDir(themeDir).exists());
 
     connect(_ui->ignoredFilesButton, SIGNAL(clicked()), SLOT(slotIgnoreFilesEditor()));
+
+    // accountAdded means the wizard was finished and the wizard might change some options.
+    connect(AccountManager::instance(), SIGNAL(accountAdded(AccountState*)), this, SLOT(loadMiscSettings()));
 }
 
 GeneralSettings::~GeneralSettings()
@@ -99,6 +104,7 @@ QSize GeneralSettings::sizeHint() const {
 
 void GeneralSettings::loadMiscSettings()
 {
+    QScopedValueRollback<bool> scope(_currentlyLoading, true);
     ConfigFile cfgFile;
     _ui->monoIconsCheckBox->setChecked(cfgFile.monoIcons());
     _ui->desktopNotificationsCheckBox->setChecked(cfgFile.optionalDesktopNotifications());
@@ -132,6 +138,8 @@ void GeneralSettings::slotUpdateInfo()
 
 void GeneralSettings::saveMiscSettings()
 {
+    if (_currentlyLoading)
+        return;
     ConfigFile cfgFile;
     bool isChecked = _ui->monoIconsCheckBox->isChecked();
     cfgFile.setMonoIcons(isChecked);
index 1746f3fb554890b7050a8c39e88cfa0944cd208f..740eddd7143901464bc08d5b36441d3fa8d2f803 100644 (file)
@@ -45,13 +45,14 @@ private slots:
     void slotToggleOptionalDesktopNotifications(bool);
     void slotUpdateInfo();
     void slotIgnoreFilesEditor();
+    void loadMiscSettings();
 
 private:
-    void loadMiscSettings();
 
     Ui::GeneralSettings *_ui;
     QPointer<IgnoreListEditor> _ignoreEditor;
     QPointer<SyncLogDialog> _syncLogDialog;
+    bool _currentlyLoading = false;
 };