homescreens/halcyon: implement keyboard arrow navigation

This commit is contained in:
Yari Polla 2023-03-12 20:41:55 +01:00
parent 8c31f51ee6
commit a414563c02
4 changed files with 58 additions and 8 deletions

View file

@ -75,6 +75,7 @@ MobileShell.GridView {
contentItem: Clock {}
}
Keys.onReturnPressed: currentItem.appDelegate.launch()
model: DelegateModel {
id: visualModel
model: Halcyon.PinnedModel
@ -82,6 +83,7 @@ MobileShell.GridView {
delegate: Item {
id: delegateRoot
property int visualIndex: DelegateModel.itemsIndex
property alias appDelegate: appDelegate
width: root.cellWidth
height: root.cellHeight

View file

@ -18,6 +18,12 @@ Item {
id: root
layer.enabled: true
onFocusChanged: {
if (focus) {
favoritesGrid.forceActiveFocus();
}
}
required property bool interactive
required property var searchWidget
@ -49,6 +55,10 @@ Item {
openFolderAnim.restart()
}
function resetHighlight() {
favoritesGrid.currentIndex = -1;
}
FavoritesGrid {
id: favoritesGrid

View file

@ -22,6 +22,16 @@ MobileShell.GridView {
cacheBuffer: cellHeight * 20 // 10 rows above and below
reuseItems: true
Controls.ScrollBar.vertical: Controls.ScrollBar {
policy: Controls.ScrollBar.AlwaysOn
}
onFocusChanged: {
if (focus) {
forceActiveFocus();
}
}
// ensure items aren't visible out of bounds
layer.enabled: true
@ -69,6 +79,7 @@ MobileShell.GridView {
font.weight: Font.Bold
}
Keys.onReturnPressed: currentItem.launchApp()
delegate: GridAppDelegate {
id: delegate

View file

@ -30,6 +30,7 @@ Item {
function triggerHomescreen() {
swipeView.setCurrentIndex(0);
swipeView.focusChild();
favoritesView.closeFolder();
favoritesView.goToBeginning();
gridAppList.goToBeginning();
@ -42,6 +43,16 @@ Item {
}
}
Connections {
target: MobileShellState.HomeScreenControls
function onHomeScreenVisibleChanged(){
if (MobileShellState.HomeScreenControls.homeScreenVisible) {
swipeView.focusChild();
}
}
}
QQC2.SwipeView {
id: swipeView
opacity: 1 - searchWidget.openFactor
@ -53,12 +64,27 @@ Item {
anchors.leftMargin: root.leftMargin
anchors.rightMargin: root.rightMargin
function focusChild() {
currentItem.childFocus = true;
}
onCurrentIndexChanged: focusChild()
Item {
height: swipeView.height
width: swipeView.width
property alias childFocus: favoritesView.focus
// open wallpaper menu when held on click
TapHandler {
onPressedChanged: {
if (pressed) {
favoritesView.resetHighlight();
}
}
onLongPressed: root.openConfigure()
}
@ -71,16 +97,17 @@ Item {
}
}
QQC2.ScrollView {
Item {
width: swipeView.width
height: swipeView.height
// disable horizontal scrollbar
QQC2.ScrollBar.horizontal: QQC2.ScrollBar { policy: QQC2.ScrollBar.AlwaysOff }
property alias childFocus: gridAppList.focus
GridAppList {
id: gridAppList
anchors.fill: parent
property int horizontalMargin: Math.round(swipeView.width * 0.05)
interactive: root.interactive
leftMargin: horizontalMargin