diff --git a/src/gui/application.cpp b/src/gui/application.cpp index c5c0f7cb684cb..8d1426d5c2b19 100644 --- a/src/gui/application.cpp +++ b/src/gui/application.cpp @@ -95,6 +95,7 @@ namespace { " --background : launch the application in the background.\n" " --overrideserverurl : specify a server URL to use for the force override to be used in the account setup wizard.\n" " --overridelocaldir : specify a local dir to be used in the account setup wizard.\n" + " --proposelocaldir : specify 'false' to enforce an active local directory decision.\n" " --userid : userId (username as on the server) to pass when creating an account via command-line.\n" " --apppassword : appPassword to pass when creating an account via command-line.\n" " --localdirpath : (optional) path where to create a local sync folder when creating an account via command-line.\n" @@ -337,6 +338,11 @@ Application::Application(int &argc, char **argv) shouldExit = true; } + if (!_proposeLocalDir.isEmpty()) { + cfg.setProposeLocalDir(_proposeLocalDir); + shouldExit = true; + } + if (AccountSetupCommandLineManager::instance()) { cfg.setVfsEnabled(AccountSetupCommandLineManager::instance()->isVfsEnabled()); } @@ -856,6 +862,12 @@ void Application::parseOptions(const QStringList &options) } else { showHint("Invalid URL passed to --overridelocaldir"); } + } else if (option == QStringLiteral("--proposelocaldir")) { + if (it.hasNext() && !it.peekNext().startsWith(QLatin1String("--"))) { + _proposeLocalDir = it.next(); + } else { + showHint("Invalid value passed to --proposelocaldir"); + } } else if (option == QStringLiteral("--forcelegacyconfigimport")) { AccountManager::instance()->setForceLegacyImport(true); } else { diff --git a/src/gui/application.h b/src/gui/application.h index c3936da43a45e..7c1d8ad11f054 100644 --- a/src/gui/application.h +++ b/src/gui/application.h @@ -150,6 +150,7 @@ protected slots: QString _overrideServerUrl; QString _overrideLocalDir; + QString _proposeLocalDir; #if defined(WITH_CRASHREPORTER) QScopedPointer _crashHandler; diff --git a/src/gui/owncloudsetupwizard.cpp b/src/gui/owncloudsetupwizard.cpp index 58a6d613f0475..a67f78f9324bc 100644 --- a/src/gui/owncloudsetupwizard.cpp +++ b/src/gui/owncloudsetupwizard.cpp @@ -120,8 +120,20 @@ void OwncloudSetupWizard::startWizard() if (!QDir(localFolder).isAbsolute()) { localFolder = QDir::homePath() + QLatin1Char('/') + localFolder; } - + _ocWizard->setProperty("localFolder", localFolder); + + { + ConfigFile cfg; + if (!cfg.proposeLocalDir().isEmpty()) { + qCInfo(lcWizard) << "cfg.proposeLocalDir() " << cfg.proposeLocalDir(); + if (cfg.proposeLocalDir() == "false") { + localFolder = "Please select folder"; + } + _ocWizard->setProperty("localFolder", localFolder); + } + } + { ConfigFile cfg; if (!cfg.overrideLocalDir().isEmpty()) { diff --git a/src/libsync/configfile.cpp b/src/libsync/configfile.cpp index 2b1cda432e597..3fd2e7933a989 100644 --- a/src/libsync/configfile.cpp +++ b/src/libsync/configfile.cpp @@ -67,6 +67,7 @@ static constexpr char updateSegmentC[] = "updateSegment"; static constexpr char updateChannelC[] = "updateChannel"; static constexpr char overrideServerUrlC[] = "overrideServerUrl"; static constexpr char overrideLocalDirC[] = "overrideLocalDir"; +static constexpr char proposeLocalDirC[] = "proposeLocalDir"; static constexpr char isVfsEnabledC[] = "isVfsEnabled"; static constexpr char geometryC[] = "geometry"; static constexpr char timeoutC[] = "timeout"; @@ -779,6 +780,18 @@ void ConfigFile::setOverrideLocalDir(const QString &localDir) settings.setValue(QLatin1String(overrideLocalDirC), localDir); } +[[nodiscard]] QString ConfigFile::proposeLocalDir() const +{ + QSettings settings(configFile(), QSettings::IniFormat); + return settings.value(QLatin1String(proposeLocalDirC), {}).toString(); +} + +void ConfigFile::setProposeLocalDir(const QString &localDir) +{ + QSettings settings(configFile(), QSettings::IniFormat); + settings.setValue(QLatin1String(proposeLocalDirC), localDir); +} + bool ConfigFile::isVfsEnabled() const { QSettings settings(configFile(), QSettings::IniFormat); diff --git a/src/libsync/configfile.h b/src/libsync/configfile.h index 844036336a6f9..45915f91ba426 100644 --- a/src/libsync/configfile.h +++ b/src/libsync/configfile.h @@ -212,6 +212,9 @@ class OWNCLOUDSYNC_EXPORT ConfigFile [[nodiscard]] QString overrideLocalDir() const; void setOverrideLocalDir(const QString &localDir); + [[nodiscard]] QString proposeLocalDir() const; + void setProposeLocalDir(const QString &localDir); + [[nodiscard]] bool isVfsEnabled() const; void setVfsEnabled(bool enabled);