From a414563c02cc70a260716de2e3605af270a3d01b Mon Sep 17 00:00:00 2001 From: Yari Polla Date: Sun, 12 Mar 2023 20:41:55 +0100 Subject: [PATCH] homescreens/halcyon: implement keyboard arrow navigation --- .../package/contents/ui/FavoritesGrid.qml | 4 +- .../package/contents/ui/FavoritesView.qml | 10 +++++ .../package/contents/ui/GridAppList.qml | 11 +++++ .../package/contents/ui/HomeScreen.qml | 41 +++++++++++++++---- 4 files changed, 58 insertions(+), 8 deletions(-) diff --git a/containments/homescreens/halcyon/package/contents/ui/FavoritesGrid.qml b/containments/homescreens/halcyon/package/contents/ui/FavoritesGrid.qml index b5ed0c8c..a313aa1f 100644 --- a/containments/homescreens/halcyon/package/contents/ui/FavoritesGrid.qml +++ b/containments/homescreens/halcyon/package/contents/ui/FavoritesGrid.qml @@ -75,6 +75,7 @@ MobileShell.GridView { contentItem: Clock {} } + Keys.onReturnPressed: currentItem.appDelegate.launch() model: DelegateModel { id: visualModel model: Halcyon.PinnedModel @@ -82,7 +83,8 @@ MobileShell.GridView { delegate: Item { id: delegateRoot property int visualIndex: DelegateModel.itemsIndex - + property alias appDelegate: appDelegate + width: root.cellWidth height: root.cellHeight diff --git a/containments/homescreens/halcyon/package/contents/ui/FavoritesView.qml b/containments/homescreens/halcyon/package/contents/ui/FavoritesView.qml index 4db58da3..ae5197fe 100644 --- a/containments/homescreens/halcyon/package/contents/ui/FavoritesView.qml +++ b/containments/homescreens/halcyon/package/contents/ui/FavoritesView.qml @@ -18,6 +18,12 @@ Item { id: root layer.enabled: true + onFocusChanged: { + if (focus) { + favoritesGrid.forceActiveFocus(); + } + } + required property bool interactive required property var searchWidget @@ -48,6 +54,10 @@ Item { folderShown = true; openFolderAnim.restart() } + + function resetHighlight() { + favoritesGrid.currentIndex = -1; + } FavoritesGrid { id: favoritesGrid diff --git a/containments/homescreens/halcyon/package/contents/ui/GridAppList.qml b/containments/homescreens/halcyon/package/contents/ui/GridAppList.qml index afdce2ec..cec2ab45 100644 --- a/containments/homescreens/halcyon/package/contents/ui/GridAppList.qml +++ b/containments/homescreens/halcyon/package/contents/ui/GridAppList.qml @@ -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 diff --git a/containments/homescreens/halcyon/package/contents/ui/HomeScreen.qml b/containments/homescreens/halcyon/package/contents/ui/HomeScreen.qml index 185ed5c1..65db4c9f 100644 --- a/containments/homescreens/halcyon/package/contents/ui/HomeScreen.qml +++ b/containments/homescreens/halcyon/package/contents/ui/HomeScreen.qml @@ -30,6 +30,7 @@ Item { function triggerHomescreen() { swipeView.setCurrentIndex(0); + swipeView.focusChild(); favoritesView.closeFolder(); favoritesView.goToBeginning(); gridAppList.goToBeginning(); @@ -41,7 +42,17 @@ Item { plasmoid.editMode = false; } } - + + Connections { + target: MobileShellState.HomeScreenControls + + function onHomeScreenVisibleChanged(){ + if (MobileShellState.HomeScreenControls.homeScreenVisible) { + swipeView.focusChild(); + } + } + } + QQC2.SwipeView { id: swipeView opacity: 1 - searchWidget.openFactor @@ -52,13 +63,28 @@ Item { anchors.bottomMargin: root.bottomMargin 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() } @@ -70,17 +96,18 @@ Item { onOpenConfigureRequested: root.openConfigure() } } - - 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