Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfix/stop after creating config file #5532

Merged
merged 3 commits into from
Mar 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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