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

Only accept folder setup page if overrideLocalDir is set #5385

Merged
merged 4 commits into from
Feb 2, 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
46 changes: 34 additions & 12 deletions src/gui/application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
Expand All @@ -337,6 +339,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);
}
}
Comment on lines +343 to +352
Copy link
Collaborator

@claucambra claucambra Feb 2, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No variable declarations here, so I would say it makes sense to remove the block and make it inline with the rest of the method

If the intention here is to make it clear this is a specific procedure relating to override values, I would instead move it into a separate private static method which would make this even more readable



// The timeout is initialized with an environment variable, if not, override with the value from the config
if (!AbstractNetworkJob::httpTimeout)
AbstractNetworkJob::httpTimeout = cfg.timeout();
Expand All @@ -345,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
Expand Down Expand Up @@ -639,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;

Expand Down Expand Up @@ -711,16 +729,16 @@ void Application::parseOptions(const QStringList &options)
&& QUrl::fromUserInput(overrideUrl).isValid();
if (!isUrlValid) {
showHint("Invalid URL passed to --overrideserverurl");
} else {
ConfigFile().setOverrideServerUrl(overrideUrl);
shouldExit = true;
} else {
_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");
}
Expand Down Expand Up @@ -833,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;
}

Expand All @@ -853,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);
Expand Down Expand Up @@ -895,8 +916,9 @@ void Application::setupTranslations()
installTranslator(qtkeychainTranslator);
break;
}
if (property("ui_lang").isNull())
if (property("ui_lang").isNull()) {
setProperty("ui_lang", "C");
}
}
}

Expand Down
3 changes: 3 additions & 0 deletions src/gui/application.h
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,9 @@ protected slots:
QNetworkConfigurationManager _networkConfigurationManager;
QTimer _checkConnectionTimer;

QString _overrideServerUrl;
QString _overrideLocalDir;

#if defined(WITH_CRASHREPORTER)
QScopedPointer<CrashReporter::Handler> _crashHandler;
#endif
Expand Down
8 changes: 5 additions & 3 deletions src/gui/wizard/owncloudadvancedsetuppage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
});
}
}
Expand Down