Verified Commit 7b3479a2 authored by Fushan Wen's avatar Fushan Wen 💬
Browse files

applets/kickoff: add `Ctrl+Shift+Arrow` shortcuts to move favorite items

When a launcher item is on the left/right edge, continue pressing
left/right arrow key will not move the item to the previous/next line.
parent b9cd608a
Pipeline #231185 passed with stage
in 5 minutes and 2 seconds
......@@ -28,6 +28,42 @@ DropArea {
}
}
}
function moveRow(targetIndex) {
if (targetIndex < 0 || targetIndex >= targetView.count) {
return;
}
targetView.model.moveRow(targetView.currentIndex, targetIndex);
targetView.currentIndex = targetIndex;
}
Shortcut {
enabled: (targetView instanceof GridView && targetView.currentIndex >= targetView.columns)
|| (targetView instanceof ListView && targetView.currentIndex > 0)
sequence: "Ctrl+Shift+Up"
onActivated: moveRow(targetView.currentIndex - (targetView instanceof GridView ? targetView.columns : 1))
}
Shortcut {
enabled: (targetView instanceof GridView && targetView.currentIndex < targetView.count - targetView.columns)
|| (targetView instanceof ListView && targetView.currentIndex + 1 < targetView.count)
sequence: "Ctrl+Shift+Down"
onActivated: moveRow(targetView.currentIndex + (targetView instanceof GridView ? targetView.columns : 1))
}
Shortcut {
enabled: targetView instanceof GridView && targetView.currentIndex % targetView.columns > 0
sequence: "Ctrl+Shift+Left"
onActivated: moveRow(targetView.currentIndex - 1)
}
Shortcut {
enabled: targetView instanceof GridView && targetView.currentIndex % targetView.columns !== targetView.columns - 1
sequence: "Ctrl+Shift+Right"
onActivated: moveRow(targetView.currentIndex + 1)
}
SmoothedAnimation {
target: root.targetView
property: "contentY"
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment