Merge pull request #676 from cillian64/oslist-arrows

Enable arrow keys for OS list navigation
This commit is contained in:
Tom Dewey 2023-10-17 16:25:41 +01:00 committed by GitHub
commit f675c48e35
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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 !== "") {