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.
This commit is contained in:
David Turner 2023-10-17 15:35:44 +01:00
parent 1b44ab73e7
commit 981c14e8a0

View file

@ -626,6 +626,11 @@ ApplicationWindow {
} }
Keys.onEnterPressed: Keys.onSpacePressed(event) Keys.onEnterPressed: Keys.onSpacePressed(event)
Keys.onReturnPressed: 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.onEnterPressed: Keys.onSpacePressed(event)
Keys.onReturnPressed: 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() 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) function selectOSitem(d, selectFirstSubitem)
{ {
if (typeof(d.subitems_json) == "string" && d.subitems_json !== "") { if (typeof(d.subitems_json) == "string" && d.subitems_json !== "") {