From 9101e0a7f828a7d7780cc29d4402cad7e7694e4a Mon Sep 17 00:00:00 2001 From: Camila Date: Wed, 1 Feb 2023 19:58:45 +0100 Subject: [PATCH 1/4] Only accept folder setup page if overrideLocalDir is set. Fix for #5383. Signed-off-by: Camila --- src/gui/wizard/owncloudadvancedsetuppage.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/gui/wizard/owncloudadvancedsetuppage.cpp b/src/gui/wizard/owncloudadvancedsetuppage.cpp index 7e49980ed24a9..2dbf427ec906b 100644 --- a/src/gui/wizard/owncloudadvancedsetuppage.cpp +++ b/src/gui/wizard/owncloudadvancedsetuppage.cpp @@ -195,12 +195,14 @@ void OwncloudAdvancedSetupPage::initializePage() } if (Theme::instance()->forceOverrideServerUrl()) { QTimer::singleShot(0, this, [this]() { - connect(_ocWizard, &QDialog::accepted, []() { - ConfigFile cfg; + ConfigFile cfg; + connect(_ocWizard, &QDialog::accepted, [&]() { cfg.setOverrideServerUrl({}); cfg.setOverrideLocalDir({}); }); - _ocWizard->accept(); + if (!cfg.overrideLocalDir().isEmpty()) { + _ocWizard->accept(); + } }); } } From 35965621019a5ad53251e98185aea04618c02c2d Mon Sep 17 00:00:00 2001 From: Camila Date: Wed, 1 Feb 2023 20:25:49 +0100 Subject: [PATCH 2/4] Do not exit application when overrideserverurl param is a valid url. Signed-off-by: Camila --- src/gui/application.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/application.cpp b/src/gui/application.cpp index acdd45e542b97..ed7b15c375ff6 100644 --- a/src/gui/application.cpp +++ b/src/gui/application.cpp @@ -711,9 +711,9 @@ void Application::parseOptions(const QStringList &options) && QUrl::fromUserInput(overrideUrl).isValid(); if (!isUrlValid) { showHint("Invalid URL passed to --overrideserverurl"); + shouldExit = true; } else { ConfigFile().setOverrideServerUrl(overrideUrl); - shouldExit = true; } } else { showHint("Invalid URL passed to --overrideserverurl"); From e0c1c673066fd07a792f72f1b4c6d80e6f043a68 Mon Sep 17 00:00:00 2001 From: Camila Date: Wed, 1 Feb 2023 20:56:34 +0100 Subject: [PATCH 3/4] Fix: if the config did not exist, overrideserverurl had no effect. When the client runs for the first time, setting the value was done before the config file was created. It had no effect. Signed-off-by: Camila --- src/gui/application.cpp | 17 +++++++++++++++-- src/gui/application.h | 3 +++ 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/src/gui/application.cpp b/src/gui/application.cpp index ed7b15c375ff6..9f8d522f5343b 100644 --- a/src/gui/application.cpp +++ b/src/gui/application.cpp @@ -337,6 +337,19 @@ Application::Application(int &argc, char **argv) } ConfigFile cfg; + + { + // these config values will always be empty after the first client run + if (!_overrideServerUrl.isEmpty()) { + cfg.setOverrideServerUrl(_overrideServerUrl); + } + + if (!_overrideLocalDir.isEmpty()) { + cfg.setOverrideLocalDir(_overrideLocalDir); + } + } + + // The timeout is initialized with an environment variable, if not, override with the value from the config if (!AbstractNetworkJob::httpTimeout) AbstractNetworkJob::httpTimeout = cfg.timeout(); @@ -713,14 +726,14 @@ void Application::parseOptions(const QStringList &options) showHint("Invalid URL passed to --overrideserverurl"); shouldExit = true; } else { - ConfigFile().setOverrideServerUrl(overrideUrl); + _overrideServerUrl = overrideUrl; } } else { showHint("Invalid URL passed to --overrideserverurl"); } } else if (option == QStringLiteral("--overridelocaldir")) { if (it.hasNext() && !it.peekNext().startsWith(QLatin1String("--"))) { - ConfigFile().setOverrideLocalDir(it.next()); + _overrideLocalDir = it.next(); } else { showHint("Invalid URL passed to --overridelocaldir"); } diff --git a/src/gui/application.h b/src/gui/application.h index 5bd412077eda4..8ae193264c725 100644 --- a/src/gui/application.h +++ b/src/gui/application.h @@ -145,6 +145,9 @@ protected slots: QNetworkConfigurationManager _networkConfigurationManager; QTimer _checkConnectionTimer; + QString _overrideServerUrl; + QString _overrideLocalDir; + #if defined(WITH_CRASHREPORTER) QScopedPointer _crashHandler; #endif From e533c6047c02cc717e77f1dd2af26217313ac459 Mon Sep 17 00:00:00 2001 From: Camila Date: Wed, 1 Feb 2023 21:58:25 +0100 Subject: [PATCH 4/4] Update code style. Signed-off-by: Camila --- src/gui/application.cpp | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/src/gui/application.cpp b/src/gui/application.cpp index 9f8d522f5343b..45a806230592b 100644 --- a/src/gui/application.cpp +++ b/src/gui/application.cpp @@ -306,16 +306,18 @@ Application::Application(int &argc, char **argv) parseOptions(arguments()); //no need to waste time; - if (_helpOnly || _versionOnly) + if (_helpOnly || _versionOnly) { return; + } if (_quitInstance) { QTimer::singleShot(0, qApp, &QApplication::quit); return; } - if (isRunning()) + if (isRunning()) { return; + } #if defined(WITH_CRASHREPORTER) if (ConfigFile().crashReporter()) { @@ -358,10 +360,12 @@ Application::Application(int &argc, char **argv) if (Theme::instance()->showVirtualFilesOption() && bestAvailableVfsMode() == Vfs::Off) { qCWarning(lcApplication) << "Theme wants to show vfs mode, but no vfs plugins are available"; } - if (isVfsPluginAvailable(Vfs::WindowsCfApi)) + if (isVfsPluginAvailable(Vfs::WindowsCfApi)) { qCInfo(lcApplication) << "VFS windows plugin is available"; - if (isVfsPluginAvailable(Vfs::WithSuffix)) + } + if (isVfsPluginAvailable(Vfs::WithSuffix)) { qCInfo(lcApplication) << "VFS suffix plugin is available"; + } _folderManager.reset(new FolderMan); #ifdef Q_OS_WIN @@ -652,8 +656,9 @@ void Application::parseOptions(const QStringList &options) { QStringListIterator it(options); // skip file name; - if (it.hasNext()) + if (it.hasNext()) { it.next(); + } bool shouldExit = false; @@ -846,11 +851,13 @@ QString substLang(const QString &lang) // transifex translation conventions. // Simplified Chinese - if (lang == QLatin1String("zh_Hans")) + if (lang == QLatin1String("zh_Hans")) { return QLatin1String("zh_CN"); + } // Traditional Chinese - if (lang == QLatin1String("zh_Hant")) + if (lang == QLatin1String("zh_Hant")) { return QLatin1String("zh_TW"); + } return lang; } @@ -866,8 +873,9 @@ void Application::setupTranslations() #endif QString enforcedLocale = Theme::instance()->enforcedLocale(); - if (!enforcedLocale.isEmpty()) + if (!enforcedLocale.isEmpty()) { uiLanguages.prepend(enforcedLocale); + } auto *translator = new QTranslator(this); auto *qtTranslator = new QTranslator(this); @@ -908,8 +916,9 @@ void Application::setupTranslations() installTranslator(qtkeychainTranslator); break; } - if (property("ui_lang").isNull()) + if (property("ui_lang").isNull()) { setProperty("ui_lang", "C"); + } } }