Also add the warning dialog to the option in the folder wizard.
auto *layout = new QVBoxLayout(this);
_selectiveSync = new SelectiveSyncWidget(account, this);
layout->addWidget(_selectiveSync);
- _placeholderCheckBox = new QCheckBox(tr("Download placeholders instead of downloading the files (Experimental)"));
+ _placeholderCheckBox = new QCheckBox(tr("Create placeholders instead of downloading files (experimental)"));
+ connect(_placeholderCheckBox, &QCheckBox::clicked, this, &FolderWizardSelectiveSync::placeholderCheckboxClicked);
layout->addWidget(_placeholderCheckBox);
}
QWizardPage::cleanupPage();
}
+void FolderWizardSelectiveSync::placeholderCheckboxClicked()
+{
+ // The click has already had an effect on the box, so if it's
+ // checked it was newly activated.
+ if (_placeholderCheckBox->isChecked()) {
+ OwncloudWizard::askExperimentalPlaceholderFeature([this](bool enable) {
+ if (!enable)
+ _placeholderCheckBox->setChecked(false);
+ });
+ }
+}
+
// ====================================================================================
void initializePage() override;
void cleanupPage() override;
+private slots:
+ void placeholderCheckboxClicked();
+
private:
SelectiveSyncWidget *_selectiveSync;
QCheckBox *_placeholderCheckBox;
folderDefinition.localPath = localFolder;
folderDefinition.targetPath = FolderDefinition::prepareTargetPath(_remoteFolder);
folderDefinition.ignoreHiddenFiles = folderMan->ignoreHiddenFiles();
+ folderDefinition.usePlaceholders = _ocWizard->usePlaceholderSync();
if (folderMan->navigationPaneHelper().showInExplorerNavigationPane())
folderDefinition.navigationPaneClsid = QUuid::createUuid();
#include <QUrl>
#include <QTimer>
#include <QStorageInfo>
+#include <QMessageBox>
#include "QProgressIndicator.h"
connect(_ui.rSyncEverything, &QAbstractButton::clicked, this, &OwncloudAdvancedSetupPage::slotSyncEverythingClicked);
connect(_ui.rSelectiveSync, &QAbstractButton::clicked, this, &OwncloudAdvancedSetupPage::slotSelectiveSyncClicked);
+ connect(_ui.rPlaceholderSync, &QAbstractButton::clicked, this, &OwncloudAdvancedSetupPage::slotPlaceholderSyncClicked);
connect(_ui.bSelectiveSync, &QAbstractButton::clicked, this, &OwncloudAdvancedSetupPage::slotSelectiveSyncClicked);
QIcon appIcon = theme->applicationIcon();
return _selectiveSyncBlacklist;
}
+bool OwncloudAdvancedSetupPage::usePlaceholderSync() const
+{
+ return _ui.rPlaceholderSync->isChecked();
+}
+
bool OwncloudAdvancedSetupPage::isConfirmBigFolderChecked() const
{
return _ui.rSyncEverything->isChecked() && _ui.confCheckBoxSize->isChecked();
void OwncloudAdvancedSetupPage::slotSelectiveSyncClicked()
{
- // Because clicking on it also changes it, restore it to the previous state in case the user cancelled the dialog
- _ui.rSyncEverything->setChecked(_selectiveSyncBlacklist.isEmpty());
-
AccountPtr acc = static_cast<OwncloudWizard *>(wizard())->account();
auto *dlg = new SelectiveSyncDialog(acc, _remoteFolder, _selectiveSyncBlacklist, this);
if (updateBlacklist) {
if (!_selectiveSyncBlacklist.isEmpty()) {
_ui.rSelectiveSync->blockSignals(true);
- _ui.rSelectiveSync->setChecked(true);
+ setRadioChecked(_ui.rSelectiveSync);
_ui.rSelectiveSync->blockSignals(false);
auto s = dlg->estimatedSize();
if (s > 0) {
_ui.lSelectiveSyncSizeLabel->setText(QString());
}
} else {
- _ui.rSyncEverything->setChecked(true);
+ setRadioChecked(_ui.rSyncEverything);
_ui.lSelectiveSyncSizeLabel->setText(QString());
}
wizard()->setProperty("blacklist", _selectiveSyncBlacklist);
}
}
+void OwncloudAdvancedSetupPage::slotPlaceholderSyncClicked()
+{
+ OwncloudWizard::askExperimentalPlaceholderFeature([this](bool enable) {
+ if (!enable)
+ return;
+
+ _ui.lSelectiveSyncSizeLabel->setText(QString());
+ _selectiveSyncBlacklist.clear();
+ setRadioChecked(_ui.rPlaceholderSync);
+ });
+}
+
void OwncloudAdvancedSetupPage::slotSyncEverythingClicked()
{
_ui.lSelectiveSyncSizeLabel->setText(QString());
- _ui.rSyncEverything->setChecked(true);
+ setRadioChecked(_ui.rSyncEverything);
_selectiveSyncBlacklist.clear();
QString errorStr = checkLocalSpace(_rSize);
_progressIndi->setColor(QGuiApplication::palette().color(QPalette::Text));
}
+void OwncloudAdvancedSetupPage::setRadioChecked(QRadioButton *radio)
+{
+ // We don't want clicking the radio buttons to immediately adjust the checked state
+ // for selective sync and placeholder sync, so we keep them uncheckable until
+ // they should be checked.
+ radio->setCheckable(true);
+ radio->setChecked(true);
+
+ if (radio != _ui.rSelectiveSync)
+ _ui.rSelectiveSync->setCheckable(false);
+ if (radio != _ui.rPlaceholderSync)
+ _ui.rPlaceholderSync->setCheckable(false);
+}
+
} // namespace OCC
bool validatePage() override;
QString localFolder() const;
QStringList selectiveSyncBlacklist() const;
+ bool usePlaceholderSync() const;
bool isConfirmBigFolderChecked() const;
void setRemoteFolder(const QString &remoteFolder);
void setMultipleFoldersExist(bool exist);
void slotSelectFolder();
void slotSyncEverythingClicked();
void slotSelectiveSyncClicked();
+ void slotPlaceholderSyncClicked();
void slotQuotaRetrieved(const QVariantMap &result);
private:
+ void setRadioChecked(QRadioButton *radio);
+
void setupCustomization();
void updateStatus();
bool dataChanged();
<property name="text">
<string/>
</property>
+ <property name="checkable">
+ <bool>false</bool>
+ </property>
</widget>
</item>
<item>
</item>
</layout>
</item>
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayout_4">
+ <item>
+ <widget class="QRadioButton" name="rPlaceholderSync">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Minimum" vsizetype="Minimum">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>Create placeholders instead of downloading files (experimental)</string>
+ </property>
+ <property name="checkable">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <spacer name="horizontalSpacer_5">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>40</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ </layout>
+ </item>
</layout>
</widget>
</item>
*/
#include "account.h"
+#include "config.h"
#include "configfile.h"
#include "theme.h"
#include "owncloudgui.h"
#include <QtCore>
#include <QtGui>
+#include <QMessageBox>
#include <cstdlib>
return _advancedSetupPage->selectiveSyncBlacklist();
}
+bool OwncloudWizard::usePlaceholderSync() const
+{
+ return _advancedSetupPage->usePlaceholderSync();
+}
+
bool OwncloudWizard::isConfirmBigFolderChecked() const
{
return _advancedSetupPage->isConfirmBigFolderChecked();
ownCloudGui::raiseDialog(this);
}
+void OwncloudWizard::askExperimentalPlaceholderFeature(const std::function<void(bool enable)> &callback)
+{
+ auto msgBox = new QMessageBox(
+ QMessageBox::Warning,
+ tr("Enable experimental feature?"),
+ tr("When the \"synchronize placeholders\" mode is enabled no files will be downloaded initially. "
+ "Instead, a tiny \"%1\" file will be created for each file on the server. "
+ "The contents can be downloaded by running these files or by using their context menu."
+ "\n\n"
+ "This is a new, experimental mode. If you decide to use it, please report any "
+ "issues that come up.")
+ .arg(APPLICATION_DOTPLACEHOLDER_SUFFIX));
+ msgBox->addButton(tr("Enable experimental mode"), QMessageBox::AcceptRole);
+ msgBox->addButton(tr("Stay safe"), QMessageBox::RejectRole);
+ connect(msgBox, &QMessageBox::finished, msgBox, [callback, msgBox](int result) {
+ callback(result == QMessageBox::AcceptRole);
+ msgBox->deleteLater();
+ });
+ msgBox->open();
+}
+
} // end namespace
QString ocUrl() const;
QString localFolder() const;
QStringList selectiveSyncBlacklist() const;
+ bool usePlaceholderSync() const;
bool isConfirmBigFolderChecked() const;
void enableFinishOnResultWidget(bool enable);
void bringToTop();
+ /**
+ * Shows a dialog explaining the placeholder mode and warning about it
+ * being experimental. Calles the callback with true if enabling was
+ * chosen.
+ */
+ static void askExperimentalPlaceholderFeature(const std::function<void(bool enable)> &callback);
+
// FIXME: Can those be local variables?
// Set from the OwncloudSetupPage, later used from OwncloudHttpCredsPage
QSslKey _clientSslKey;