mirror of
https://github.com/nextcloud/desktop.git
synced 2024-11-25 22:46:04 +03:00
Wizards: Add placeholder option and warning to account wizard
Also add the warning dialog to the option in the folder wizard.
This commit is contained in:
parent
7dc65b060d
commit
aee8b9f3c5
8 changed files with 130 additions and 7 deletions
|
@ -493,7 +493,8 @@ FolderWizardSelectiveSync::FolderWizardSelectiveSync(const AccountPtr &account)
|
|||
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);
|
||||
}
|
||||
|
||||
|
@ -534,6 +535,18 @@ void FolderWizardSelectiveSync::cleanupPage()
|
|||
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);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ====================================================================================
|
||||
|
||||
|
|
|
@ -130,6 +130,9 @@ public:
|
|||
void initializePage() override;
|
||||
void cleanupPage() override;
|
||||
|
||||
private slots:
|
||||
void placeholderCheckboxClicked();
|
||||
|
||||
private:
|
||||
SelectiveSyncWidget *_selectiveSync;
|
||||
QCheckBox *_placeholderCheckBox;
|
||||
|
|
|
@ -633,6 +633,7 @@ void OwncloudSetupWizard::slotAssistantFinished(int result)
|
|||
folderDefinition.localPath = localFolder;
|
||||
folderDefinition.targetPath = FolderDefinition::prepareTargetPath(_remoteFolder);
|
||||
folderDefinition.ignoreHiddenFiles = folderMan->ignoreHiddenFiles();
|
||||
folderDefinition.usePlaceholders = _ocWizard->usePlaceholderSync();
|
||||
if (folderMan->navigationPaneHelper().showInExplorerNavigationPane())
|
||||
folderDefinition.navigationPaneClsid = QUuid::createUuid();
|
||||
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
#include <QUrl>
|
||||
#include <QTimer>
|
||||
#include <QStorageInfo>
|
||||
#include <QMessageBox>
|
||||
|
||||
#include "QProgressIndicator.h"
|
||||
|
||||
|
@ -55,6 +56,7 @@ OwncloudAdvancedSetupPage::OwncloudAdvancedSetupPage()
|
|||
|
||||
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();
|
||||
|
@ -231,6 +233,11 @@ QStringList OwncloudAdvancedSetupPage::selectiveSyncBlacklist() const
|
|||
return _selectiveSyncBlacklist;
|
||||
}
|
||||
|
||||
bool OwncloudAdvancedSetupPage::usePlaceholderSync() const
|
||||
{
|
||||
return _ui.rPlaceholderSync->isChecked();
|
||||
}
|
||||
|
||||
bool OwncloudAdvancedSetupPage::isConfirmBigFolderChecked() const
|
||||
{
|
||||
return _ui.rSyncEverything->isChecked() && _ui.confCheckBoxSize->isChecked();
|
||||
|
@ -305,9 +312,6 @@ void OwncloudAdvancedSetupPage::slotSelectFolder()
|
|||
|
||||
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);
|
||||
|
||||
|
@ -330,7 +334,7 @@ void OwncloudAdvancedSetupPage::slotSelectiveSyncClicked()
|
|||
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) {
|
||||
|
@ -344,17 +348,29 @@ void OwncloudAdvancedSetupPage::slotSelectiveSyncClicked()
|
|||
_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);
|
||||
|
@ -395,4 +411,18 @@ void OwncloudAdvancedSetupPage::customizeStyle()
|
|||
_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
|
||||
|
|
|
@ -41,6 +41,7 @@ public:
|
|||
bool validatePage() override;
|
||||
QString localFolder() const;
|
||||
QStringList selectiveSyncBlacklist() const;
|
||||
bool usePlaceholderSync() const;
|
||||
bool isConfirmBigFolderChecked() const;
|
||||
void setRemoteFolder(const QString &remoteFolder);
|
||||
void setMultipleFoldersExist(bool exist);
|
||||
|
@ -57,9 +58,12 @@ private slots:
|
|||
void slotSelectFolder();
|
||||
void slotSyncEverythingClicked();
|
||||
void slotSelectiveSyncClicked();
|
||||
void slotPlaceholderSyncClicked();
|
||||
void slotQuotaRetrieved(const QVariantMap &result);
|
||||
|
||||
private:
|
||||
void setRadioChecked(QRadioButton *radio);
|
||||
|
||||
void setupCustomization();
|
||||
void updateStatus();
|
||||
bool dataChanged();
|
||||
|
|
|
@ -190,6 +190,9 @@
|
|||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
|
@ -224,6 +227,39 @@
|
|||
</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>
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
*/
|
||||
|
||||
#include "account.h"
|
||||
#include "config.h"
|
||||
#include "configfile.h"
|
||||
#include "theme.h"
|
||||
#include "owncloudgui.h"
|
||||
|
@ -34,6 +35,7 @@
|
|||
|
||||
#include <QtCore>
|
||||
#include <QtGui>
|
||||
#include <QMessageBox>
|
||||
|
||||
#include <cstdlib>
|
||||
|
||||
|
@ -131,6 +133,11 @@ QStringList OwncloudWizard::selectiveSyncBlacklist() const
|
|||
return _advancedSetupPage->selectiveSyncBlacklist();
|
||||
}
|
||||
|
||||
bool OwncloudWizard::usePlaceholderSync() const
|
||||
{
|
||||
return _advancedSetupPage->usePlaceholderSync();
|
||||
}
|
||||
|
||||
bool OwncloudWizard::isConfirmBigFolderChecked() const
|
||||
{
|
||||
return _advancedSetupPage->isConfirmBigFolderChecked();
|
||||
|
@ -319,4 +326,25 @@ void OwncloudWizard::bringToTop()
|
|||
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
|
||||
|
|
|
@ -67,6 +67,7 @@ public:
|
|||
QString ocUrl() const;
|
||||
QString localFolder() const;
|
||||
QStringList selectiveSyncBlacklist() const;
|
||||
bool usePlaceholderSync() const;
|
||||
bool isConfirmBigFolderChecked() const;
|
||||
|
||||
void enableFinishOnResultWidget(bool enable);
|
||||
|
@ -76,6 +77,13 @@ public:
|
|||
|
||||
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;
|
||||
|
|
Loading…
Reference in a new issue