From 586d9e854e295bc1565d7a0b54b1ddb161bec96c Mon Sep 17 00:00:00 2001 From: Aurelien Vaillant Date: Tue, 13 Aug 2024 18:15:38 +0200 Subject: [PATCH] WIP to setup the keys event --- Jellyfin.qml | 7 +++++++ Views/Login.qml | 23 +++++++++++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/Jellyfin.qml b/Jellyfin.qml index 8a288a7..8102cbc 100644 --- a/Jellyfin.qml +++ b/Jellyfin.qml @@ -19,7 +19,14 @@ Application { color: "#000B25" + focus: true + View.Login {} } + + Component.onCompleted: { + // Setup the login view to be focus on start + columnLogin.updateSelection(); + } } } diff --git a/Views/Login.qml b/Views/Login.qml index 45efb12..b3e14b1 100644 --- a/Views/Login.qml +++ b/Views/Login.qml @@ -8,12 +8,21 @@ Column { {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 { @@ -48,5 +57,19 @@ Column { } } } + + 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() + } + } + } } }