From 6b24b0688bfe01bfff7896035de52f46d3f9710e Mon Sep 17 00:00:00 2001 From: Rainer Walke Date: Wed, 4 Dec 2024 15:45:36 +0100 Subject: [PATCH] improve proposeLocalDir feature --- src/gui/owncloudsetupwizard.cpp | 15 +++++++++++++-- src/libsync/configfile.cpp | 13 +++++++++++++ src/libsync/configfile.h | 3 +++ 3 files changed, 29 insertions(+), 2 deletions(-) diff --git a/src/gui/owncloudsetupwizard.cpp b/src/gui/owncloudsetupwizard.cpp index 9928dac02b329..a67f78f9324bc 100644 --- a/src/gui/owncloudsetupwizard.cpp +++ b/src/gui/owncloudsetupwizard.cpp @@ -120,9 +120,20 @@ void OwncloudSetupWizard::startWizard() if (!QDir(localFolder).isAbsolute()) { localFolder = QDir::homePath() + QLatin1Char('/') + localFolder; } - - localFolder = "Please select folder"; + _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);