83 lines
2.6 KiB
QML
83 lines
2.6 KiB
QML
import QtQuick 2.5
|
|
import "../Components"
|
|
import "../Shared"
|
|
|
|
// Écran 2 : saisie manuelle de l'adresse d'un serveur.
|
|
// Le clavier virtuel de la box n'a ni « : » ni « / » : on saisit l'hôte seul, le port
|
|
// à part (facultatif), et Session détecte le protocole (https/http) et le port.
|
|
Page {
|
|
id: page
|
|
|
|
property bool busy: false
|
|
property string error: ""
|
|
|
|
title: "Ajouter un serveur"
|
|
subtitle: "Saisissez l'adresse IP ou le nom de domaine de votre serveur Jellyfin. Le protocole et le port sont détectés automatiquement."
|
|
initialFocus: addressField
|
|
|
|
function connect() {
|
|
if (busy)
|
|
return;
|
|
error = "";
|
|
busy = true;
|
|
page.session.connectToServer(addressField.text, portField.text, function (err) {
|
|
page.busy = false;
|
|
if (err) {
|
|
page.error = err;
|
|
var port = portField.text.trim();
|
|
(port !== "" && !page.session.isValidPort(port) ? portField : addressField).forceActiveFocus();
|
|
return;
|
|
}
|
|
// Remplace cet écran : Retour depuis la liste des utilisateurs ramène aux serveurs.
|
|
page.navigator.replace("UserSelect");
|
|
});
|
|
}
|
|
|
|
Component.onDestruction: if (page.session) page.session.cancel()
|
|
|
|
Column {
|
|
width: Math.min(parent.width, 560)
|
|
spacing: Theme.spacingL
|
|
|
|
TextField {
|
|
id: addressField
|
|
width: parent.width
|
|
label: "Adresse du serveur"
|
|
placeholder: "192.168.1.20 ou jellyfin.example.com"
|
|
inputMethodHints: Qt.ImhUrlCharactersOnly | Qt.ImhNoAutoUppercase | Qt.ImhNoPredictiveText
|
|
KeyNavigation.down: portField
|
|
onAccepted: portField.forceActiveFocus()
|
|
}
|
|
|
|
TextField {
|
|
id: portField
|
|
width: 200
|
|
label: "Port (facultatif)"
|
|
placeholder: "Auto"
|
|
inputMethodHints: Qt.ImhDigitsOnly
|
|
validator: RegExpValidator { regExp: /\d{0,5}/ }
|
|
maximumLength: 5
|
|
KeyNavigation.up: addressField
|
|
KeyNavigation.down: connectButton
|
|
onAccepted: page.connect()
|
|
}
|
|
|
|
Text {
|
|
width: parent.width
|
|
visible: text !== ""
|
|
text: page.error
|
|
color: Theme.error
|
|
font.pixelSize: Theme.fontBody
|
|
wrapMode: Text.WordWrap
|
|
}
|
|
|
|
FocusButton {
|
|
id: connectButton
|
|
primary: true
|
|
text: page.busy ? "Connexion…" : "Se connecter"
|
|
KeyNavigation.up: portField
|
|
onClicked: page.connect()
|
|
}
|
|
}
|
|
}
|