Skip to content

Commit 2171072

Browse files
committed
Add branding parameter to skip the advanced setup page
Fixes: #8665
1 parent 20611da commit 2171072

13 files changed

+132
-114
lines changed

changelog/unreleased/8665

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Change: Add a branding option to skip the advanced setup page
2+
3+
If the option is enabled we will create a sync with the default values.
4+
5+
https://github.com/owncloud/client/issues/8665

src/gui/owncloudsetupwizard.cpp

+26-58
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ namespace OCC {
4242
OwncloudSetupWizard::OwncloudSetupWizard(QWidget *parent)
4343
: QObject(parent)
4444
, _ocWizard(new OwncloudWizard(parent))
45-
, _remoteFolder()
4645
{
4746
connect(_ocWizard, &OwncloudWizard::determineAuthType,
4847
this, &OwncloudSetupWizard::slotCheckServer);
@@ -55,7 +54,7 @@ OwncloudSetupWizard::OwncloudSetupWizard(QWidget *parent)
5554
Therefore Qt::QueuedConnection is required */
5655
connect(_ocWizard, &OwncloudWizard::basicSetupFinished,
5756
this, &OwncloudSetupWizard::slotAssistantFinished, Qt::QueuedConnection);
58-
connect(_ocWizard, &QDialog::finished, this, &QObject::deleteLater);
57+
connect(_ocWizard, &OwncloudWizard::finished, this, &QObject::deleteLater);
5958
}
6059

6160
OwncloudSetupWizard::~OwncloudSetupWizard()
@@ -71,28 +70,6 @@ void OwncloudSetupWizard::startWizard()
7170
_ocWizard->setAccount(account);
7271
_ocWizard->setOCUrl(account->url().toString());
7372

74-
_remoteFolder = Theme::instance()->defaultServerFolder();
75-
// remoteFolder may be empty, which means /
76-
QString localFolder = Theme::instance()->defaultClientFolder();
77-
78-
// if its a relative path, prepend with users home dir, otherwise use as absolute path
79-
80-
if (!QDir(localFolder).isAbsolute()) {
81-
localFolder = QDir::homePath() + QDir::separator() + localFolder;
82-
}
83-
84-
_ocWizard->setProperty("localFolder", localFolder);
85-
86-
// remember the local folder to compare later if it changed, but clean first
87-
QString lf = QDir::fromNativeSeparators(localFolder);
88-
if (!lf.endsWith(QLatin1Char('/'))) {
89-
lf.append(QLatin1Char('/'));
90-
}
91-
92-
_initLocalFolder = lf;
93-
94-
_ocWizard->setRemoteFolder(_remoteFolder);
95-
9673
_ocWizard->setStartId(WizardCommon::Page_ServerSetup);
9774

9875
_ocWizard->restart();
@@ -269,33 +246,33 @@ void OwncloudSetupWizard::testOwnCloudConnect()
269246
job->checkServerAndUpdate();
270247
}
271248

272-
void OwncloudSetupWizard::slotCreateLocalAndRemoteFolders(const QString &localFolder, const QString &remoteFolder)
249+
void OwncloudSetupWizard::slotCreateLocalAndRemoteFolders()
273250
{
274-
qCInfo(lcWizard) << "Setup local sync folder for new oC connection " << localFolder;
275-
const QDir fi(localFolder);
251+
qCInfo(lcWizard) << "Setup local sync folder for new oC connection " << _ocWizard->localFolder();
252+
const QDir fi(_ocWizard->localFolder());
276253

277254
bool nextStep = true;
278255
if (fi.exists()) {
279-
FileSystem::setFolderMinimumPermissions(localFolder);
280-
Utility::setupFavLink(localFolder);
256+
FileSystem::setFolderMinimumPermissions(_ocWizard->localFolder());
257+
Utility::setupFavLink(_ocWizard->localFolder());
281258
// there is an existing local folder. If its non empty, it can only be synced if the
282259
// ownCloud is newly created.
283-
qCDebug(lcWizard) << "Local sync folder" << localFolder << "already exists, setting it up for sync.";
260+
qCDebug(lcWizard) << "Local sync folder" << _ocWizard->localFolder() << "already exists, setting it up for sync.";
284261
} else {
285262
bool ok = true;
286-
if (fi.mkpath(localFolder)) {
287-
FileSystem::setFolderMinimumPermissions(localFolder);
288-
Utility::setupFavLink(localFolder);
263+
if (fi.mkpath(_ocWizard->localFolder())) {
264+
FileSystem::setFolderMinimumPermissions(_ocWizard->localFolder());
265+
Utility::setupFavLink(_ocWizard->localFolder());
289266
} else {
290267
ok = false;
291268
qCWarning(lcWizard) << "Failed to create " << fi.path();
292-
_ocWizard->displayError(tr("Could not create local folder %1").arg(Utility::escape(localFolder)));
269+
_ocWizard->displayError(tr("Could not create local folder %1").arg(Utility::escape(_ocWizard->localFolder())));
293270
nextStep = false;
294271
}
295-
qCDebug(lcWizard) << "Creating local sync folder" << localFolder << "success:" << ok;
272+
qCDebug(lcWizard) << "Creating local sync folder" << _ocWizard->localFolder() << "success:" << ok;
296273
}
297274
if (nextStep) {
298-
EntityExistsJob *job = new EntityExistsJob(_ocWizard->account(), Utility::concatUrlPath(_ocWizard->account()->davPath(), remoteFolder).path(), this);
275+
EntityExistsJob *job = new EntityExistsJob(_ocWizard->account(), Utility::concatUrlPath(_ocWizard->account()->davPath(), _ocWizard->remoteFolder()).path(), this);
299276
connect(job, &EntityExistsJob::exists, this, &OwncloudSetupWizard::slotRemoteFolderExists);
300277
job->start();
301278
} else {
@@ -314,12 +291,7 @@ void OwncloudSetupWizard::slotRemoteFolderExists(QNetworkReply *reply)
314291
if (errId == QNetworkReply::NoError) {
315292
qCInfo(lcWizard) << "Remote folder found, all cool!";
316293
} else if (errId == QNetworkReply::ContentNotFoundError) {
317-
if (_remoteFolder.isEmpty()) {
318-
error = tr("No remote folder specified!");
319-
ok = false;
320-
} else {
321-
createRemoteFolder();
322-
}
294+
createRemoteFolder();
323295
} else {
324296
error = tr("Error: %1").arg(job->errorString());
325297
ok = false;
@@ -334,12 +306,12 @@ void OwncloudSetupWizard::slotRemoteFolderExists(QNetworkReply *reply)
334306

335307
void OwncloudSetupWizard::createRemoteFolder()
336308
{
337-
qCDebug(lcWizard) << "creating folder on ownCloud:" << _remoteFolder;
309+
qCDebug(lcWizard) << "creating folder on ownCloud:" << _ocWizard->remoteFolder();
338310

339-
MkColJob *job = new MkColJob(_ocWizard->account(), _remoteFolder, this);
311+
MkColJob *job = new MkColJob(_ocWizard->account(), _ocWizard->remoteFolder(), this);
340312
connect(job, &MkColJob::finishedWithError, this, &OwncloudSetupWizard::slotCreateRemoteFolderFinished);
341313
connect(job, &MkColJob::finishedWithoutError, this, [this] {
342-
qCDebug(lcWizard) << "Remote folder" << _remoteFolder << "created successfully.";
314+
qCDebug(lcWizard) << "Remote folder" << _ocWizard->remoteFolder() << "created successfully.";
343315
finalizeSetup(true);
344316
});
345317
job->start();
@@ -349,12 +321,10 @@ void OwncloudSetupWizard::slotCreateRemoteFolderFinished(QNetworkReply *reply)
349321
{
350322
auto error = reply->error();
351323
qCDebug(lcWizard) << "** webdav mkdir request finished " << error;
352-
// disconnect(ownCloudInfo::instance(), SIGNAL(webdavColCreated(QNetworkReply::NetworkError)),
353-
// this, SLOT(slotCreateRemoteFolderFinished(QNetworkReply::NetworkError)));
354324

355325
bool success = true;
356326
if (error == 202) {
357-
qCDebug(lcWizard) << "The remote folder" << _remoteFolder << "already exists. Connecting it for syncing.";
327+
qCDebug(lcWizard) << "The remote folder" << _ocWizard->remoteFolder() << "already exists. Connecting it for syncing.";
358328
} else if (error > 202 && error < 300) {
359329
_ocWizard->displayError(tr("The folder creation resulted in HTTP error code %1").arg((int)error));
360330

@@ -364,12 +334,12 @@ void OwncloudSetupWizard::slotCreateRemoteFolderFinished(QNetworkReply *reply)
364334
"are wrong!"
365335
"<br/>Please go back and check your credentials.</p>"));
366336
qCDebug(lcWizard) << "Remote folder creation failed probably because the provided credentials are wrong. Please go back and check your credentials.";
367-
_remoteFolder.clear();
337+
_ocWizard->resetRemoteFolder();
368338
success = false;
369339
} else {
370-
qCDebug(lcWizard) << "Remote folder" << _remoteFolder << "creation failed with error" << error;
371-
_ocWizard->displayError(tr("Remote folder %1 creation failed with error <tt>%2</tt>.").arg(Utility::escape(_remoteFolder)).arg(error));
372-
_remoteFolder.clear();
340+
qCDebug(lcWizard) << "Remote folder" << _ocWizard->remoteFolder() << "creation failed with error" << error;
341+
_ocWizard->displayError(tr("Remote folder %1 creation failed with error <tt>%2</tt>.").arg(Utility::escape(_ocWizard->remoteFolder())).arg(error));
342+
_ocWizard->resetRemoteFolder();
373343
success = false;
374344
}
375345

@@ -378,11 +348,9 @@ void OwncloudSetupWizard::slotCreateRemoteFolderFinished(QNetworkReply *reply)
378348

379349
void OwncloudSetupWizard::finalizeSetup(bool success)
380350
{
381-
const QString localFolder = _ocWizard->property("localFolder").toString();
351+
const QString localFolder = _ocWizard->localFolder();
382352
if (success) {
383-
if (!(localFolder.isEmpty() || _remoteFolder.isEmpty())) {
384-
qCDebug(lcWizard) << "A sync connection from" << localFolder << "to remote directory" << _remoteFolder << "was set up.";
385-
}
353+
qCDebug(lcWizard) << "A sync connection from" << localFolder << "to remote directory" << _ocWizard->remoteFolder() << "was set up.";
386354
qCDebug(lcWizard) << "Successfully connected";
387355
_ocWizard->successfulStep();
388356
} else {
@@ -426,10 +394,10 @@ void OwncloudSetupWizard::slotAssistantFinished(int result)
426394

427395
bool startFromScratch = _ocWizard->field("OCSyncFromScratch").toBool();
428396
if (!startFromScratch || ensureStartFromScratch(localFolder)) {
429-
qCInfo(lcWizard) << "Adding folder definition for" << localFolder << _remoteFolder;
397+
qCInfo(lcWizard) << "Adding folder definition for" << localFolder << _ocWizard->remoteFolder();
430398
FolderDefinition folderDefinition;
431399
folderDefinition.localPath = localFolder;
432-
folderDefinition.targetPath = FolderDefinition::prepareTargetPath(_remoteFolder);
400+
folderDefinition.targetPath = FolderDefinition::prepareTargetPath(_ocWizard->remoteFolder());
433401
folderDefinition.ignoreHiddenFiles = folderMan->ignoreHiddenFiles();
434402
if (_ocWizard->useVirtualFileSync()) {
435403
folderDefinition.virtualFilesMode = bestAvailableVfsMode();

src/gui/owncloudsetupwizard.h

+1-3
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ private slots:
5858

5959
void slotConnectToOCUrl(const QString &);
6060

61-
void slotCreateLocalAndRemoteFolders(const QString &, const QString &);
61+
void slotCreateLocalAndRemoteFolders();
6262
void slotRemoteFolderExists(QNetworkReply *);
6363
void slotCreateRemoteFolderFinished(QNetworkReply *reply);
6464
void slotAssistantFinished(int);
@@ -74,8 +74,6 @@ private slots:
7474
AccountState *applyAccountChanges();
7575

7676
OwncloudWizard *_ocWizard;
77-
QString _initLocalFolder;
78-
QString _remoteFolder;
7977

8078
friend class ownCloudGui;
8179
};

src/gui/wizard/abstractcredswizardpage.cpp

+5
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,9 @@ void AbstractCredentialsWizardPage::cleanupPage()
3232
account->setCredentials(new DummyCredentials);
3333
}
3434
}
35+
36+
OwncloudWizard *AbstractWizardPage::owncloudWizard() const
37+
{
38+
return qobject_cast<OwncloudWizard *>(wizard());
39+
}
3540
}

src/gui/wizard/abstractcredswizardpage.h

+9-2
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,21 @@
1818
#include <QWizardPage>
1919

2020
namespace OCC {
21-
21+
class OwncloudWizard;
2222
class AbstractCredentials;
2323

2424
/**
2525
* @brief The AbstractCredentialsWizardPage class
2626
* @ingroup gui
2727
*/
28-
class AbstractCredentialsWizardPage : public QWizardPage
28+
29+
class AbstractWizardPage : public QWizardPage
30+
{
31+
public:
32+
OwncloudWizard *owncloudWizard() const;
33+
};
34+
35+
class AbstractCredentialsWizardPage : public AbstractWizardPage
2936
{
3037
public:
3138
void cleanupPage() override;

src/gui/wizard/owncloudadvancedsetuppage.cpp

+14-25
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,12 @@
3737
namespace OCC {
3838

3939
OwncloudAdvancedSetupPage::OwncloudAdvancedSetupPage()
40-
: QWizardPage()
40+
: AbstractWizardPage()
4141
, _ui()
4242
, _checking(false)
4343
, _created(false)
4444
, _localFolderValid(false)
4545
, _progressIndi(new QProgressIndicator(this))
46-
, _remoteFolder()
4746
{
4847
_ui.setupUi(this);
4948

@@ -86,8 +85,8 @@ OwncloudAdvancedSetupPage::OwncloudAdvancedSetupPage()
8685

8786
_ui.rVirtualFileSync->setText(tr("Use &virtual files instead of downloading content immediately%1").arg(bestAvailableVfsMode() == Vfs::WindowsCfApi ? QString() : tr(" (experimental)")));
8887

89-
connect(this, &OwncloudAdvancedSetupPage::completeChanged, this, [this]{
90-
if (wizard() && qobject_cast<OwncloudWizard*>(wizard())->authType() == OCC::DetermineAuthTypeJob::AuthType::OAuth) {
88+
connect(this, &OwncloudAdvancedSetupPage::completeChanged, this, [this] {
89+
if (wizard() && owncloudWizard()->authType() == OCC::DetermineAuthTypeJob::AuthType::OAuth) {
9190
// For OAuth, disable the back button in the Page_AdvancedSetup because we don't want
9291
// to re-open the browser.
9392
// HACK: the wizard will reenable the buttons on completeChanged, so delay it
@@ -129,18 +128,14 @@ void OwncloudAdvancedSetupPage::initializePage()
129128
_ui.lSelectiveSyncSizeLabel->clear();
130129
_ui.lSyncEverythingSizeLabel->clear();
131130

132-
// Update the local folder - this is not guaranteed to find a good one
133-
QString goodLocalFolder = FolderMan::instance()->findGoodPathForNewSyncFolder(localFolder());
134-
wizard()->setProperty("localFolder", goodLocalFolder);
135-
136131
// call to init label
137132
updateStatus();
138133

139134
// ensure "next" gets the focus, not obSelectLocalFolder
140135
QTimer::singleShot(0, wizard()->button(QWizard::FinishButton), SLOT(setFocus()));
141136

142-
auto acc = static_cast<OwncloudWizard *>(wizard())->account();
143-
auto quotaJob = new PropfindJob(acc, _remoteFolder, this);
137+
auto acc = owncloudWizard()->account();
138+
auto quotaJob = new PropfindJob(acc, owncloudWizard()->remoteFolder(), this);
144139
quotaJob->setProperties(QList<QByteArray>() << "http://owncloud.org/ns:size");
145140

146141
connect(quotaJob, &PropfindJob::result, this, &OwncloudAdvancedSetupPage::slotQuotaRetrieved);
@@ -157,15 +152,15 @@ void OwncloudAdvancedSetupPage::initializePage()
157152
// evtl. warnings on the dialog.
158153
void OwncloudAdvancedSetupPage::updateStatus()
159154
{
160-
const QString locFolder = localFolder();
155+
const QString locFolder = owncloudWizard()->localFolder();
161156

162157
// check if the local folder exists. If so, and if its not empty, show a warning.
163158
QString errorStr = FolderMan::instance()->checkPathValidityForNewFolder(locFolder);
164159
_localFolderValid = errorStr.isEmpty();
165160

166161
_ui.pbSelectLocalFolder->setText(QDir::toNativeSeparators(locFolder));
167-
if (!_remoteFolder.isEmpty() && _remoteFolder != QLatin1String("/")) {
168-
_ui.rSyncEverything->setText(tr("Sync the folder '%1'").arg(_remoteFolder));
162+
if (owncloudWizard()->remoteFolder() != QLatin1String("/")) {
163+
_ui.rSyncEverything->setText(tr("Sync the folder '%1'").arg(owncloudWizard()->remoteFolder()));
169164
}
170165

171166
if (!QDir(locFolder).entryList(QDir::AllEntries | QDir::NoDotAndDotDot).isEmpty()) {
@@ -197,12 +192,6 @@ int OwncloudAdvancedSetupPage::nextId() const
197192
return -1;
198193
}
199194

200-
QString OwncloudAdvancedSetupPage::localFolder() const
201-
{
202-
QString folder = wizard()->property("localFolder").toString();
203-
return folder;
204-
}
205-
206195
QStringList OwncloudAdvancedSetupPage::selectiveSyncBlacklist() const
207196
{
208197
return _selectiveSyncBlacklist;
@@ -230,7 +219,7 @@ bool OwncloudAdvancedSetupPage::validatePage()
230219
}
231220

232221
if (useVirtualFileSync()) {
233-
const auto availability = Vfs::checkAvailability(localFolder());
222+
const auto availability = Vfs::checkAvailability(owncloudWizard()->localFolder());
234223
if (!availability) {
235224
auto msg = new QMessageBox(QMessageBox::Warning, tr("Virtual files are not available for the selected folder"), availability.error(), QMessageBox::Ok, this);
236225
msg->setAttribute(Qt::WA_DeleteOnClose);
@@ -252,7 +241,7 @@ bool OwncloudAdvancedSetupPage::validatePage()
252241
cfgFile.setConfirmExternalStorage(_ui.confCheckBoxExternal->isChecked());
253242
}
254243

255-
emit createLocalAndRemoteFolders(localFolder(), _remoteFolder);
244+
emit owncloudWizard()->createLocalAndRemoteFolders();
256245
return false;
257246
} else {
258247
// connecting is running
@@ -285,7 +274,7 @@ void OwncloudAdvancedSetupPage::directoriesCreated()
285274
void OwncloudAdvancedSetupPage::setRemoteFolder(const QString &remoteFolder)
286275
{
287276
if (!remoteFolder.isEmpty()) {
288-
_remoteFolder = remoteFolder;
277+
owncloudWizard()->setRemoteFolder(remoteFolder);
289278
}
290279
}
291280

@@ -294,15 +283,15 @@ void OwncloudAdvancedSetupPage::slotSelectFolder()
294283
QString dir = QFileDialog::getExistingDirectory(nullptr, tr("Local Sync Folder"), QDir::homePath());
295284
if (!dir.isEmpty()) {
296285
_ui.pbSelectLocalFolder->setText(dir);
297-
wizard()->setProperty("localFolder", dir);
286+
owncloudWizard()->setLocalFolder(dir);
298287
updateStatus();
299288
}
300289
}
301290

302291
void OwncloudAdvancedSetupPage::slotSelectiveSyncClicked()
303292
{
304-
AccountPtr acc = static_cast<OwncloudWizard *>(wizard())->account();
305-
SelectiveSyncDialog *dlg = new SelectiveSyncDialog(acc, _remoteFolder, _selectiveSyncBlacklist, this);
293+
AccountPtr acc = owncloudWizard()->account();
294+
SelectiveSyncDialog *dlg = new SelectiveSyncDialog(acc, owncloudWizard()->remoteFolder(), _selectiveSyncBlacklist, this);
306295
dlg->setAttribute(Qt::WA_DeleteOnClose);
307296

308297
connect(dlg, &SelectiveSyncDialog::finished, this, [this, dlg]{

0 commit comments

Comments
 (0)