Commit e685710c authored by Fushan Wen's avatar Fushan Wen 💬
Browse files

applets/taskmanager: add "Ctrl+Shift+Arrow" shortcuts to move task items

In group: Up/Down to move tasks
In taskbar: Left/Right to move tasks
parent a027d2f1
Pipeline #232047 canceled with stage
in 2 minutes and 33 seconds
......@@ -46,7 +46,6 @@ PlasmaCore.Dialog {
}
}
mainItem: MouseHandler {
id: mouseHandler
width: Math.min(groupDialog.preferredWidth, Math.max(groupListView.maxWidth, groupDialog.visualParent.width))
......@@ -58,6 +57,23 @@ PlasmaCore.Dialog {
Keys.onEscapePressed: groupDialog.visible = false
function moveRow(event, insertAt) {
if (!(event.modifiers & Qt.ControlModifier) || !(event.modifiers & Qt.ShiftModifier)) {
event.accepted = false;
return;
} else if (insertAt < 0 || insertAt >= groupListView.count) {
return;
}
const parentModelIndex = tasksModel.makeModelIndex(groupDialog.visualParent.itemIndex);
const status = tasksModel.move(groupListView.currentIndex, insertAt, parentModelIndex);
if (!status) {
return;
}
groupListView.currentIndex = insertAt;
}
PlasmaComponents3.ScrollView {
id: scrollView
anchors.fill: parent
......@@ -119,6 +135,9 @@ PlasmaCore.Dialog {
reuseItems: false
Keys.onUpPressed: mouseHandler.moveRow(event, groupListView.currentIndex - 1);
Keys.onDownPressed: mouseHandler.moveRow(event, groupListView.currentIndex + 1);
onCountChanged: {
if (count > 0) {
backend.cancelHighlightWindows()
......
......@@ -279,6 +279,18 @@ MouseArea {
Keys.onReturnPressed: TaskTools.activateTask(modelIndex(), model, event.modifiers, task)
Keys.onEnterPressed: Keys.onReturnPressed(event);
Keys.onSpacePressed: Keys.onReturnPressed(event);
Keys.onUpPressed: Keys.onLeftPressed(event)
Keys.onDownPressed: Keys.onRightPressed(event)
Keys.onLeftPressed: if (!inPopup && (event.modifiers & Qt.ControlModifier) && (event.modifiers & Qt.ShiftModifier)) {
tasksModel.move(task.itemIndex, task.itemIndex - 1);
} else {
event.accepted = false;
}
Keys.onRightPressed: if (!inPopup && (event.modifiers & Qt.ControlModifier) && (event.modifiers & Qt.ShiftModifier)) {
tasksModel.move(task.itemIndex, task.itemIndex + 1);
} else {
event.accepted = false;
}
function modelIndex() {
return (inPopup ? tasksModel.makeModelIndex(groupDialog.visualParent.itemIndex, index)
......
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