From 981c14e8a04dd5484f6bece3425d730ca1600106 Mon Sep 17 00:00:00 2001 From: David Turner Date: Tue, 17 Oct 2023 15:35:44 +0100 Subject: [PATCH] Enable arrow keys for OS list navigation Allow use of left and right arrow keys for navigating the OS list. Right arrow won't choose an image, it only enters sub-lists. --- src/main.qml | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/src/main.qml b/src/main.qml index 1a5e670..a3f6cbd 100644 --- a/src/main.qml +++ b/src/main.qml @@ -626,6 +626,11 @@ ApplicationWindow { } Keys.onEnterPressed: Keys.onSpacePressed(event) Keys.onReturnPressed: Keys.onSpacePressed(event) + Keys.onRightPressed: { + // Navigate into sublists but don't select an OS entry + if (currentIndex != -1 && isOSsublist(model.get(currentIndex))) + selectOSitem(model.get(currentIndex), true) + } } } } @@ -675,6 +680,15 @@ ApplicationWindow { } Keys.onEnterPressed: Keys.onSpacePressed(event) Keys.onReturnPressed: Keys.onSpacePressed(event) + Keys.onRightPressed: { + // Navigate into sublists but don't select an OS entry + if (currentIndex != -1 && isOSsublist(model.get(currentIndex))) + selectOSitem(model.get(currentIndex), true) + } + Keys.onLeftPressed: { + osswipeview.decrementCurrentIndex() + ospopup.categorySelected = "" + } } } @@ -1628,6 +1642,23 @@ ApplicationWindow { hwpopup.close() } + /// Is the item a sub-list or sub-sub-list in the OS selection model? + function isOSsublist(d) { + // Top level category + if (typeof(d.subitems_json) == "string" && d.subitems_json !== "") { + return true + } + + // Sub-category + if (typeof(d.subitems_url) == "string" && d.subitems_url !== "" + && d.subitems_url !== "internal://back") + { + return true + } + + return false + } + function selectOSitem(d, selectFirstSubitem) { if (typeof(d.subitems_json) == "string" && d.subitems_json !== "") {