Skip to content

Commit

Permalink
Merge pull request #5532 from nextcloud/bugfix/stopAfterCreatingConfi…
Browse files Browse the repository at this point in the history
…gFile

Bugfix/stop after creating config file
  • Loading branch information
mgallien authored Mar 22, 2023
2 parents 54a11e8 + d2cd4ef commit 04a32cb
Show file tree
Hide file tree
Showing 9 changed files with 132 additions and 73 deletions.
5 changes: 5 additions & 0 deletions src/gui/accountsetupcommandlinemanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,11 @@ bool AccountSetupCommandLineManager::isCommandLineParsed() const
return !_appPassword.isEmpty() && !_userId.isEmpty() && _serverUrl.isValid();
}

bool AccountSetupCommandLineManager::isVfsEnabled() const
{
return _isVfsEnabled;
}

void AccountSetupCommandLineManager::setupAccountFromCommandLine()
{
if (isCommandLineParsed()) {
Expand Down
2 changes: 2 additions & 0 deletions src/gui/accountsetupcommandlinemanager.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ class AccountSetupCommandLineManager : public QObject

[[nodiscard]] bool isCommandLineParsed() const;

[[nodiscard]] bool isVfsEnabled() const;

public slots:
void setupAccountFromCommandLine();

Expand Down
14 changes: 13 additions & 1 deletion src/gui/application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -332,13 +332,25 @@ Application::Application(int &argc, char **argv)
ConfigFile cfg;

{
auto shouldExit = false;

// these config values will always be empty after the first client run
if (!_overrideServerUrl.isEmpty()) {
cfg.setOverrideServerUrl(_overrideServerUrl);
cfg.setOverrideServerUrl(_overrideServerUrl);
shouldExit = true;
}

if (!_overrideLocalDir.isEmpty()) {
cfg.setOverrideLocalDir(_overrideLocalDir);
shouldExit = true;
}

if (AccountSetupCommandLineManager::instance()) {
cfg.setVfsEnabled(AccountSetupCommandLineManager::instance()->isVfsEnabled());
}

if (shouldExit) {
std::exit(0);
}
}

Expand Down
2 changes: 2 additions & 0 deletions src/gui/owncloudsetupwizard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ void OwncloudSetupWizard::runWizard(QObject *obj, const char *amember, QWidget *
if (!cfg.overrideServerUrl().isEmpty()) {
Theme::instance()->setOverrideServerUrl(cfg.overrideServerUrl());
Theme::instance()->setForceOverrideServerUrl(true);
Theme::instance()->setVfsEnabled(cfg.isVfsEnabled());

Theme::instance()->setStartLoginFlowAutomatically(true);
}
if (!wiz.isNull()) {
Expand Down
13 changes: 13 additions & 0 deletions src/libsync/configfile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ static constexpr char updateSegmentC[] = "updateSegment";
static constexpr char updateChannelC[] = "updateChannel";
static constexpr char overrideServerUrlC[] = "overrideServerUrl";
static constexpr char overrideLocalDirC[] = "overrideLocalDir";
static constexpr char isVfsEnabledC[] = "isVfsEnabled";
static constexpr char geometryC[] = "geometry";
static constexpr char timeoutC[] = "timeout";
static constexpr char chunkSizeC[] = "chunkSize";
Expand Down Expand Up @@ -724,6 +725,18 @@ void ConfigFile::setOverrideLocalDir(const QString &localDir)
settings.setValue(QLatin1String(overrideLocalDirC), localDir);
}

bool ConfigFile::isVfsEnabled() const
{
QSettings settings(configFile(), QSettings::IniFormat);
return settings.value({isVfsEnabledC}, {}).toBool();
}

void ConfigFile::setVfsEnabled(bool enabled)
{
QSettings settings(configFile(), QSettings::IniFormat);
settings.setValue({isVfsEnabledC}, enabled);
}

void ConfigFile::setProxyType(int proxyType,
const QString &host,
int port, bool needsAuth,
Expand Down
3 changes: 3 additions & 0 deletions src/libsync/configfile.h
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,9 @@ class OWNCLOUDSYNC_EXPORT ConfigFile
[[nodiscard]] QString overrideLocalDir() const;
void setOverrideLocalDir(const QString &localDir);

[[nodiscard]] bool isVfsEnabled() const;
void setVfsEnabled(bool enabled);

void saveGeometryHeader(QHeaderView *header);
void restoreGeometryHeader(QHeaderView *header);

Expand Down
2 changes: 1 addition & 1 deletion src/libsync/nextcloudtheme.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class NextcloudTheme : public Theme
public:
NextcloudTheme();

QString wizardUrlHint() const override;
[[nodiscard]] QString wizardUrlHint() const override;
};
}
#endif // NEXTCLOUD_THEME_H
13 changes: 13 additions & 0 deletions src/libsync/theme.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -426,6 +426,11 @@ bool Theme::forceOverrideServerUrl() const
return _forceOverrideServerUrl;
}

bool Theme::isVfsEnabled() const
{
return _isVfsEnabled;
}

bool Theme::startLoginFlowAutomatically() const
{
return _startLoginFlowAutomatically;
Expand Down Expand Up @@ -971,6 +976,14 @@ void Theme::setForceOverrideServerUrl(bool forceOverride)
}
}

void Theme::setVfsEnabled(bool enabled)
{
if (_isVfsEnabled != enabled) {
_isVfsEnabled = enabled;
emit vfsEnabledChanged();
}
}

void Theme::setStartLoginFlowAutomatically(bool startLoginFlowAuto)
{
if (_startLoginFlowAutomatically != startLoginFlowAuto) {
Expand Down
Loading

0 comments on commit 04a32cb

Please sign in to comment.