From 237b58d042d4a0a36aa2787584865ac55ec14d7f Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Thu, 19 Sep 2024 15:06:59 +0800 Subject: [PATCH] Show or hide multi-server overrides or text field depending on type of override url Signed-off-by: Claudio Cambra --- src/gui/wizard/owncloudsetuppage.cpp | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/src/gui/wizard/owncloudsetuppage.cpp b/src/gui/wizard/owncloudsetuppage.cpp index a5374eb59..75ba4322a 100644 --- a/src/gui/wizard/owncloudsetuppage.cpp +++ b/src/gui/wizard/owncloudsetuppage.cpp @@ -25,6 +25,8 @@ #include #include #include +#include +#include #include "QProgressIndicator.h" @@ -47,15 +49,27 @@ OwncloudSetupPage::OwncloudSetupPage(QWidget *parent) setupServerAddressDescriptionLabel(); - Theme *theme = Theme::instance(); + const auto theme = Theme::instance(); if (theme->overrideServerUrl().isEmpty()) { + _ui.comboBox->hide(); _ui.leUrl->setPostfix(theme->wizardUrlPostfix()); _ui.leUrl->setPlaceholderText(theme->wizardUrlHint()); - } else if (Theme::instance()->forceOverrideServerUrl()) { + } else if (theme->multipleOverrideServers() && theme->forceOverrideServerUrl()) { + _ui.leUrl->hide(); + const auto overrideJsonUtf8 = theme->overrideServerUrl().toUtf8(); + const auto serversJsonArray = QJsonDocument::fromJson(overrideJsonUtf8).array(); + + for (const auto &serverJson : serversJsonArray) { + const auto serverObject = serverJson.toObject(); + const auto serverName = serverObject.value("name").toString(); + const auto serverUrl = serverObject.value("url").toString(); + _ui.comboBox->addItem(serverName, serverUrl); + } + } else if (theme->forceOverrideServerUrl()) { + _ui.comboBox->hide(); _ui.leUrl->setEnabled(false); } - registerField(QLatin1String("OCUrl*"), _ui.leUrl); auto sizePolicy = _progressIndi->sizePolicy();