mirror of
https://invent.kde.org/marcoa/shift-shell.git
synced 2026-04-26 14:23:09 +00:00
homescreens/halcyon: switch page when trying to move out of the grids
This commit is contained in:
parent
e21354bf63
commit
f87c7c5526
3 changed files with 62 additions and 0 deletions
|
|
@ -13,6 +13,51 @@ GridView {
|
|||
highlightFollowsCurrentItem: true
|
||||
highlight: highlightComponent
|
||||
|
||||
/** These function are called when the user tries to move the highlight outside the allowed surface by using arrow keys.
|
||||
* Useful to override the default behaviour of GridView (Pac-Man effect).
|
||||
*/
|
||||
property var topEdgeCallback: null
|
||||
property var bottomEdgeCallback: null
|
||||
property var leftEdgeCallback: null
|
||||
property var rightEdgeCallback: null
|
||||
|
||||
Keys.onPressed: event => {
|
||||
if (!currentItem) {
|
||||
return;
|
||||
}
|
||||
|
||||
switch(event.key){
|
||||
case Qt.Key_Left: {
|
||||
if (currentItem.x === 0
|
||||
&& leftEdgeCallback) {
|
||||
leftEdgeCallback();
|
||||
}
|
||||
break;
|
||||
}
|
||||
case Qt.Key_Right: {
|
||||
if (indexAt(currentItem.x + cellWidth, currentItem.y) === -1
|
||||
&& rightEdgeCallback) {
|
||||
rightEdgeCallback();
|
||||
}
|
||||
break;
|
||||
}
|
||||
case Qt.Key_Up: {
|
||||
if (currentItem.y === 0
|
||||
&& topEdgeCallback) {
|
||||
topEdgeCallback();
|
||||
}
|
||||
break;
|
||||
}
|
||||
case Qt.Key_Down: {
|
||||
if (indexAt(currentItem.x, currentItem.y + cellHeight) === -1
|
||||
&& bottomEdgeCallback) {
|
||||
bottomEdgeCallback();
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
onActiveFocusChanged: {
|
||||
if (!activeFocus) {
|
||||
currentIndex = -1;
|
||||
|
|
|
|||
|
|
@ -34,6 +34,7 @@ Item {
|
|||
property bool folderShown: false
|
||||
|
||||
signal openConfigureRequested()
|
||||
signal pageForwardRequested();
|
||||
|
||||
Connections {
|
||||
target: parent
|
||||
|
|
@ -87,6 +88,10 @@ Item {
|
|||
transform: Translate { x: favoritesGrid.translateX }
|
||||
opacity: 1 - openFolderProgress
|
||||
visible: opacity !== 0
|
||||
|
||||
rightEdgeCallback: () => {
|
||||
pageForwardRequested();
|
||||
}
|
||||
}
|
||||
|
||||
FolderGrid {
|
||||
|
|
|
|||
|
|
@ -93,6 +93,12 @@ Item {
|
|||
searchWidget: root.searchWidget
|
||||
interactive: root.interactive
|
||||
onOpenConfigureRequested: root.openConfigure()
|
||||
|
||||
onPageForwardRequested: {
|
||||
swipeView.setCurrentIndex(1);
|
||||
swipeView.focusChild();
|
||||
resetHighlight();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -111,6 +117,12 @@ Item {
|
|||
interactive: root.interactive
|
||||
leftMargin: horizontalMargin
|
||||
rightMargin: horizontalMargin
|
||||
|
||||
leftEdgeCallback: () => {
|
||||
swipeView.setCurrentIndex(0);
|
||||
swipeView.focusChild();
|
||||
currentIndex = -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue