mirror of https://github.com/KDE/kasts.git
Add capability to define custom gpodder server
FEATURE: 454674
This commit is contained in:
parent
cda9b450ea
commit
c4f12227a2
|
@ -20,7 +20,7 @@ Kirigami.ScrollablePage {
|
|||
|
||||
Controls.Label {
|
||||
Kirigami.FormData.label: i18n("Current Status:")
|
||||
text: Sync.syncEnabled ? i18n("Logged into account \"%1\" on server \"%2\"", Sync.username, Sync.provider == SyncUtils.GPodderNet ? "gpodder.net" : Sync.hostname) : i18n("Syncing Disabled")
|
||||
text: Sync.syncEnabled ? i18n("Logged into account \"%1\" on server \"%2\"", Sync.username, (Sync.provider == SyncUtils.GPodderNet && Sync.hostname == "") ? "gpodder.net" : Sync.hostname) : i18n("Syncing Disabled")
|
||||
wrapMode: Text.WordWrap
|
||||
}
|
||||
|
||||
|
@ -100,8 +100,10 @@ Kirigami.ScrollablePage {
|
|||
title: i18n("Sync Login Credentials")
|
||||
|
||||
onAccepted: {
|
||||
if (Sync.provider === Sync.GPodderNextcloud) {
|
||||
if (Sync.provider === Sync.GPodderNextcloud || customServerCheckBox.checked) {
|
||||
Sync.hostname = hostnameField.text;
|
||||
} else {
|
||||
Sync.hostname = ""
|
||||
}
|
||||
Sync.login(usernameField.text, passwordField.text);
|
||||
syncLoginOverlay.close();
|
||||
|
@ -166,16 +168,24 @@ Kirigami.ScrollablePage {
|
|||
text: Sync.password
|
||||
Keys.onReturnPressed: syncLoginOverlay.accepted();
|
||||
}
|
||||
Controls.CheckBox {
|
||||
id: customServerCheckBox
|
||||
Layout.row: 2
|
||||
Layout.column: 1
|
||||
visible: Sync.provider === Sync.GPodderNet
|
||||
checked: false
|
||||
text: i18n("Use custom server")
|
||||
}
|
||||
Controls.Label {
|
||||
visible: Sync.provider === Sync.GPodderNextcloud
|
||||
visible: Sync.provider === Sync.GPodderNextcloud || customServerCheckBox.checked
|
||||
Layout.alignment: Qt.AlignRight
|
||||
text: i18n("Hostname:")
|
||||
}
|
||||
Controls.TextField {
|
||||
visible: Sync.provider === Sync.GPodderNextcloud
|
||||
visible: Sync.provider === Sync.GPodderNextcloud || customServerCheckBox.checked
|
||||
id: hostnameField
|
||||
Layout.fillWidth: true
|
||||
placeholderText: "https://nextcloud.mydomain.org"
|
||||
placeholderText: Sync.provider === Sync.GPodderNet ? "https://gpodder.net" : "https://nextcloud.mydomain.org"
|
||||
text: Sync.hostname
|
||||
Keys.onReturnPressed: syncLoginOverlay.accepted();
|
||||
}
|
||||
|
|
|
@ -71,17 +71,20 @@ void Sync::retrieveCredentialsFromConfig()
|
|||
if (!password.isEmpty()) {
|
||||
m_syncEnabled = SettingsManager::self()->syncEnabled();
|
||||
m_password = password;
|
||||
m_hostname = SettingsManager::self()->syncHostname();
|
||||
|
||||
if (m_provider == Provider::GPodderNet) {
|
||||
m_device = SettingsManager::self()->syncDevice();
|
||||
m_deviceName = SettingsManager::self()->syncDeviceName();
|
||||
|
||||
if (m_syncEnabled && !m_username.isEmpty() && !m_password.isEmpty() && !m_device.isEmpty()) {
|
||||
m_gpodder = new GPodder(m_username, m_password, this);
|
||||
if (m_hostname.isEmpty()) { // use default official server
|
||||
m_gpodder = new GPodder(m_username, m_password, this);
|
||||
} else { // i.e. custom gpodder host
|
||||
m_gpodder = new GPodder(m_username, m_password, m_hostname, m_provider, this);
|
||||
}
|
||||
}
|
||||
} else if (m_provider == Provider::GPodderNextcloud) {
|
||||
m_hostname = SettingsManager::self()->syncHostname();
|
||||
|
||||
if (m_syncEnabled && !m_username.isEmpty() && !m_password.isEmpty() && !m_hostname.isEmpty()) {
|
||||
m_gpodder = new GPodder(m_username, m_password, m_hostname, m_provider, this);
|
||||
}
|
||||
|
@ -239,19 +242,24 @@ void Sync::setDeviceName(const QString &deviceName)
|
|||
|
||||
void Sync::setHostname(const QString &hostname)
|
||||
{
|
||||
QString cleanedHostname = hostname;
|
||||
QUrl hostUrl = QUrl(hostname);
|
||||
if (hostname.isEmpty()) {
|
||||
m_hostname.clear();
|
||||
} else {
|
||||
QString cleanedHostname = hostname;
|
||||
QUrl hostUrl = QUrl(hostname);
|
||||
|
||||
if (hostUrl.scheme().isEmpty()) {
|
||||
hostUrl.setScheme(QStringLiteral("https"));
|
||||
if (hostUrl.authority().isEmpty() && !hostUrl.path().isEmpty()) {
|
||||
hostUrl.setAuthority(hostUrl.path());
|
||||
hostUrl.setPath(QStringLiteral(""));
|
||||
if (hostUrl.scheme().isEmpty()) {
|
||||
hostUrl.setScheme(QStringLiteral("https"));
|
||||
if (hostUrl.authority().isEmpty() && !hostUrl.path().isEmpty()) {
|
||||
hostUrl.setAuthority(hostUrl.path());
|
||||
hostUrl.setPath(QStringLiteral(""));
|
||||
}
|
||||
cleanedHostname = hostUrl.toString();
|
||||
}
|
||||
cleanedHostname = hostUrl.toString();
|
||||
|
||||
m_hostname = cleanedHostname;
|
||||
}
|
||||
|
||||
m_hostname = cleanedHostname;
|
||||
SettingsManager::self()->setSyncHostname(m_hostname);
|
||||
SettingsManager::self()->save();
|
||||
Q_EMIT hostnameChanged();
|
||||
|
@ -309,8 +317,12 @@ void Sync::login(const QString &username, const QString &password)
|
|||
}
|
||||
subRequest->deleteLater();
|
||||
});
|
||||
} else { // official gpodder.net server
|
||||
m_gpodder = new GPodder(username, password, this);
|
||||
} else {
|
||||
if (m_hostname.isEmpty()) { // official gpodder.net server
|
||||
m_gpodder = new GPodder(username, password, this);
|
||||
} else { // custom server
|
||||
m_gpodder = new GPodder(username, password, m_hostname, Provider::GPodderNet, this);
|
||||
}
|
||||
|
||||
DeviceRequest *deviceRequest = m_gpodder->getDevices();
|
||||
connect(deviceRequest, &DeviceRequest::finished, this, [=]() {
|
||||
|
@ -422,6 +434,7 @@ void Sync::clearSettings()
|
|||
SettingsManager::self()->save();
|
||||
|
||||
Q_EMIT credentialsChanged();
|
||||
Q_EMIT hostnameChanged();
|
||||
Q_EMIT syncProgressChanged();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue