Files
Jellyfin-Freebox/Views/Login.qml
T
2024-08-13 18:15:38 +02:00

76 lines
2.0 KiB
QML

import QtQuick 2.5
Column {
// Liste des labels et types
property var fields: [
{label: "Server", type: "text"},
{label: "User", type: "text"},
{label: "Password", type: "password"}
]
property int currentIndex: 0
id: columnLogin
//anchors.centerIn: parent
anchors.verticalCenter: parent.verticalCenter
anchors.margins: 20
spacing: 15
width: parent.width * 0.8
function updateSelection() {
for (let i = 0; i < repeater.count; i++) {
repeater.itemAt(i).color = i === columnLogin.currentIndex ? "lightblue" : "transparent";
}
}
// Repeater pour générer les champs basés sur la liste des labels et types
Repeater {
model: fields
Row {
spacing: 10
Text {
width: parent.width / 2 - 5
text: modelData.label + ":"
color: "white"
font.pixelSize: 16
}
// TextInput pour les champs Server et User, et mode Password pour Password
Rectangle {
width: 200
height: 20
color: "white"
//border.color: "black"
//border.width: 3
//radius: 5
TextInput {
font.pixelSize: 16
color: "black"
text: modelData.label
// Détermine le mode de saisie en fonction du type
echoMode: modelData.type === "password" ? TextInput.Password : TextInput.Normal
}
}
}
Keys.onPressed: {
if (event.key === Qt.Key_Up) {
if (currentIndex > 0) {
currentIndex--;
updateSelection();
}
} else if (event.key == Qt.Key_Down) {
if (currentIndex < repeater.children.length - 1) {
currentIndex++;
updateSelection()
}
}
}
}
}