mirror of
https://invent.kde.org/marcoa/shift-shell.git
synced 2026-08-03 02:04:45 +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
|
highlightFollowsCurrentItem: true
|
||||||
highlight: highlightComponent
|
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: {
|
onActiveFocusChanged: {
|
||||||
if (!activeFocus) {
|
if (!activeFocus) {
|
||||||
currentIndex = -1;
|
currentIndex = -1;
|
||||||
|
|
|
||||||
|
|
@ -34,6 +34,7 @@ Item {
|
||||||
property bool folderShown: false
|
property bool folderShown: false
|
||||||
|
|
||||||
signal openConfigureRequested()
|
signal openConfigureRequested()
|
||||||
|
signal pageForwardRequested();
|
||||||
|
|
||||||
Connections {
|
Connections {
|
||||||
target: parent
|
target: parent
|
||||||
|
|
@ -87,6 +88,10 @@ Item {
|
||||||
transform: Translate { x: favoritesGrid.translateX }
|
transform: Translate { x: favoritesGrid.translateX }
|
||||||
opacity: 1 - openFolderProgress
|
opacity: 1 - openFolderProgress
|
||||||
visible: opacity !== 0
|
visible: opacity !== 0
|
||||||
|
|
||||||
|
rightEdgeCallback: () => {
|
||||||
|
pageForwardRequested();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
FolderGrid {
|
FolderGrid {
|
||||||
|
|
|
||||||
|
|
@ -93,6 +93,12 @@ Item {
|
||||||
searchWidget: root.searchWidget
|
searchWidget: root.searchWidget
|
||||||
interactive: root.interactive
|
interactive: root.interactive
|
||||||
onOpenConfigureRequested: root.openConfigure()
|
onOpenConfigureRequested: root.openConfigure()
|
||||||
|
|
||||||
|
onPageForwardRequested: {
|
||||||
|
swipeView.setCurrentIndex(1);
|
||||||
|
swipeView.focusChild();
|
||||||
|
resetHighlight();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -111,6 +117,12 @@ Item {
|
||||||
interactive: root.interactive
|
interactive: root.interactive
|
||||||
leftMargin: horizontalMargin
|
leftMargin: horizontalMargin
|
||||||
rightMargin: horizontalMargin
|
rightMargin: horizontalMargin
|
||||||
|
|
||||||
|
leftEdgeCallback: () => {
|
||||||
|
swipeView.setCurrentIndex(0);
|
||||||
|
swipeView.focusChild();
|
||||||
|
currentIndex = -1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue