Wizards: Show placeholder option only if showExperimentalOptions is set
authorChristian Kamm <mail@ckamm.de>
Thu, 5 Apr 2018 11:35:25 +0000 (13:35 +0200)
committerKevin Ottens <kevin.ottens@nextcloud.com>
Tue, 15 Dec 2020 09:57:50 +0000 (10:57 +0100)
This config file option will also control other features in the future.

src/gui/folderwizard.cpp
src/gui/wizard/owncloudadvancedsetuppage.cpp
src/gui/wizard/owncloudadvancedsetuppage.ui
src/libsync/configfile.cpp
src/libsync/configfile.h

index 4abf28afae9263f3e695180970130a78ef87162d..3365899311c639acdcb388edaca6daa9887ec131 100644 (file)
@@ -493,9 +493,12 @@ FolderWizardSelectiveSync::FolderWizardSelectiveSync(const AccountPtr &account)
     auto *layout = new QVBoxLayout(this);
     _selectiveSync = new SelectiveSyncWidget(account, this);
     layout->addWidget(_selectiveSync);
-    _placeholderCheckBox = new QCheckBox(tr("Create placeholders instead of downloading files (experimental)"));
-    connect(_placeholderCheckBox, &QCheckBox::clicked, this, &FolderWizardSelectiveSync::placeholderCheckboxClicked);
-    layout->addWidget(_placeholderCheckBox);
+
+    if (ConfigFile().showExperimentalOptions()) {
+        _placeholderCheckBox = new QCheckBox(tr("Create placeholders instead of downloading files (experimental)"));
+        connect(_placeholderCheckBox, &QCheckBox::clicked, this, &FolderWizardSelectiveSync::placeholderCheckboxClicked);
+        layout->addWidget(_placeholderCheckBox);
+    }
 }
 
 FolderWizardSelectiveSync::~FolderWizardSelectiveSync() = default;
index 794d095bd0ccaed03b0f16160488a69cbc4c47c4..97d0ed2e96164ca0e62d5ab63367ca8ad63f6dfb 100644 (file)
@@ -102,6 +102,14 @@ void OwncloudAdvancedSetupPage::initializePage()
 {
     WizardCommon::initErrorLabel(_ui.errorLabel);
 
+    if (!ConfigFile().showExperimentalOptions()) {
+        // If the layout were wrapped in a widget, the auto-grouping of the
+        // radio buttons no longer works and there are surprising margins.
+        // Just manually hide the button and remove the layout.
+        _ui.rPlaceholderSync->hide();
+        _ui.wSyncStrategy->layout()->removeItem(_ui.lPlaceholderSync);
+    }
+
     _checking = false;
     _ui.lSelectiveSyncSizeLabel->setText(QString());
     _ui.lSyncEverythingSizeLabel->setText(QString());
index 6883094a54aba3973689cd492507bbf92ea92971..303590b34b1d88c9ff4e5e2c3fb60cd5d15869a9 100644 (file)
@@ -74,7 +74,7 @@
       </spacer>
      </item>
      <item row="0" column="1" colspan="2">
-      <widget class="QWidget" name="widget" native="true">
+      <widget class="QWidget" name="wSyncStrategy" native="true">
        <layout class="QVBoxLayout" name="verticalLayout">
         <property name="leftMargin">
          <number>0</number>
          </layout>
         </item>
         <item>
-         <layout class="QHBoxLayout" name="horizontalLayout_4">
+         <layout class="QHBoxLayout" name="lPlaceholderSync">
           <item>
            <widget class="QRadioButton" name="rPlaceholderSync">
             <property name="sizePolicy">
index 057332edaad2f4ffae1255eac6a70841d3b47109..03b72ce95eefdcdff9bd34c114650816eb915cc1 100644 (file)
@@ -80,6 +80,7 @@ static const char logDirC[] = "logDir";
 static const char logDebugC[] = "logDebug";
 static const char logExpireC[] = "logExpire";
 static const char logFlushC[] = "logFlush";
+static const char showExperimentalOptionsC[] = "showExperimentalOptions";
 
 static const char proxyHostC[] = "Proxy/host";
 static const char proxyTypeC[] = "Proxy/type";
@@ -972,6 +973,12 @@ void ConfigFile::setLogFlush(bool enabled)
     settings.setValue(QLatin1String(logFlushC), enabled);
 }
 
+bool ConfigFile::showExperimentalOptions() const
+{
+    QSettings settings(configFile(), QSettings::IniFormat);
+    return settings.value(QLatin1String(showExperimentalOptionsC), false).toBool();
+}
+
 QString ConfigFile::certificatePath() const
 {
     return retrieveData(QString(), QLatin1String(certPath)).toString();
index 9cd3e2dfb6decacc0ade425f51a8cb98c4e13785..307daf29cf389faeb87403a78409c4561271ae7b 100644 (file)
@@ -104,6 +104,9 @@ public:
     bool logFlush() const;
     void setLogFlush(bool enabled);
 
+    // Whether experimental UI options should be shown
+    bool showExperimentalOptions() const;
+
     // proxy settings
     void setProxyType(int proxyType,
         const QString &host = QString(),