Show or hide multi-server overrides or text field depending on type of override url

Signed-off-by: Claudio Cambra <claudio.cambra@nextcloud.com>
This commit is contained in:
Claudio Cambra 2024-09-19 15:06:59 +08:00 коммит произвёл Matthieu Gallien
Родитель e3979ea52f
Коммит 1decedd56f
1 изменённых файлов: 17 добавлений и 3 удалений

Просмотреть файл

@ -25,6 +25,8 @@
#include <QPropertyAnimation>
#include <QGraphicsPixmapItem>
#include <QBuffer>
#include <QJsonArray>
#include <QJsonDocument>
#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();