Fixes incorrect behaviour when using SevenTasks while it is configured to sort tasks manually.

Expected behaviour:

1. Dragging pinned tasks around should update their position correctly and keep that position permanently
2. Dragging items that are NOT tasks should focus the task that is being hovered over for easier drag and drop functionality

Actual behaviour:

1. Dragging pinned tasks around seemingly works, until the task manager is updated in any kind of way, at which point the positions are reverted back to the original state.
2. Dragging items that aren't tasks will only focus the hovered task if previous dragging actions didn't occur between two or more tasks. After that, trying to drag items onto the taskbar will cause the task that was dragged last time to move around according to the mouse's position.
This commit is contained in:
wackyideas 2022-09-12 20:37:06 +02:00
parent 513ec11c42
commit 165fa81da4
7 changed files with 38 additions and 14 deletions

View file

@ -18,6 +18,7 @@ Item {
property Item target property Item target
property Item ignoredItem property Item ignoredItem
property bool moved: false property bool moved: false
property bool isGroupDialog: false
property alias hoveredItem: dropHandler.hoveredItem property alias hoveredItem: dropHandler.hoveredItem
property alias handleWheelEvents: wheelHandler.active property alias handleWheelEvents: wheelHandler.active
@ -65,12 +66,17 @@ Item {
return; return;
} }
var above = target.childAt(event.x, event.y); //var above = target.childAt(event.x, event.y);
let above;
if (isGroupDialog) {
above = target.itemAt(event.x, event.y);
} else {
above = target.childAt(event.x, event.y);
}
if (!above) { if (!above) {
hoveredItem = null; hoveredItem = null;
activationTimer.stop(); activationTimer.stop();
return; return;
} }
@ -101,9 +107,9 @@ Item {
var insertAt = TaskTools.insertIndexAt(above, event.x, event.y); var insertAt = TaskTools.insertIndexAt(above, event.x, event.y);
if (tasks.dragSource !== above && tasks.dragSource.itemIndex !== insertAt) { if (tasks.dragSource !== above && tasks.dragSource.itemIndex !== insertAt) {
if (groupDialog.visible && groupDialog.visualParent) { if (!!tasks.groupDialog) {
tasksModel.move(tasks.dragSource.itemIndex, insertAt, tasksModel.move(tasks.dragSource.itemIndex, insertAt,
tasksModel.makeModelIndex(groupDialog.visualParent.itemIndex)); tasksModel.makeModelIndex(tasks.groupDialog.visualParent.itemIndex));
} else { } else {
tasksModel.move(tasks.dragSource.itemIndex, insertAt); tasksModel.move(tasks.dragSource.itemIndex, insertAt);
} }
@ -115,6 +121,7 @@ Item {
hoveredItem = above; hoveredItem = above;
activationTimer.restart(); activationTimer.restart();
} }
tasksModel.syncLaunchers();
} }
onDragLeave: { onDragLeave: {

View file

@ -151,9 +151,10 @@ MouseArea {
} }
} else { } else {
pressed = false; pressed = false;
//if(!ma.pressed) tasks.dragSource = null;
} }
hoverEnabled = true; hoverEnabled = true;
} }
onPressed: { onPressed: {
@ -216,13 +217,14 @@ MouseArea {
pressX = -1; pressX = -1;
pressY = -1; pressY = -1;
hoverEnabled = true; hoverEnabled = true;
} }
onPressAndHold: { onPressAndHold: {
} }
onPositionChanged: { //hoverEnabled: true, but this event still doesn't fire at all onPositionChanged: { //hoverEnabled: true, but this event still doesn't fire at all
//unless i am pressing the left mouse button for a short period of time //unless i am pressing the left mouse button for a short period of time
if (pressX != -1 && mouse.buttons == Qt.LeftButton && dragHelper.isDrag(pressX, pressY, mouse.x, mouse.y)) { if (pressX != -1 && mouse.buttons == Qt.LeftButton && dragHelper.isDrag(pressX, pressY, mouse.x, mouse.y)) {
tasks.dragSource = task; tasks.dragSource = task;
dragHelper.startDrag(task, model.MimeType, model.MimeData, dragHelper.startDrag(task, model.MimeType, model.MimeData,
@ -231,6 +233,10 @@ MouseArea {
pressY = -1; pressY = -1;
return; return;
} }
else
{
tasks.dragSource = null;
}
//code for dragging the task around //code for dragging the task around

View file

@ -23,8 +23,6 @@
/usr/share/plasma/plasmoids/org.kde.plasma.seventasks/contents/ui/ToolTipInstance.qml /usr/share/plasma/plasmoids/org.kde.plasma.seventasks/contents/ui/ToolTipInstance.qml
/usr/share/plasma/plasmoids/org.kde.plasma.seventasks/contents/ui/ToolTipWindowMouseArea.qml /usr/share/plasma/plasmoids/org.kde.plasma.seventasks/contents/ui/ToolTipWindowMouseArea.qml
/usr/share/plasma/plasmoids/org.kde.plasma.seventasks/contents/ui/main.qml /usr/share/plasma/plasmoids/org.kde.plasma.seventasks/contents/ui/main.qml
/usr/share/plasma/plasmoids/org.kde.plasma.seventasks/contents/ui/MenuBackend.qml
/usr/share/plasma/plasmoids/org.kde.plasma.seventasks/contents/ui/ContextMenuBackend.qml
/usr/share/plasma/plasmoids/org.kde.plasma.seventasks/metadata.desktop /usr/share/plasma/plasmoids/org.kde.plasma.seventasks/metadata.desktop
/usr/share/plasma/plasmoids/org.kde.plasma.seventasks/metadata.json /usr/share/plasma/plasmoids/org.kde.plasma.seventasks/metadata.json
/usr/share/metainfo/org.kde.plasma.seventasks.appdata.xml /usr/share/metainfo/org.kde.plasma.seventasks.appdata.xml

View file

@ -18,6 +18,7 @@ Item {
property Item target property Item target
property Item ignoredItem property Item ignoredItem
property bool moved: false property bool moved: false
property bool isGroupDialog: false
property alias hoveredItem: dropHandler.hoveredItem property alias hoveredItem: dropHandler.hoveredItem
property alias handleWheelEvents: wheelHandler.active property alias handleWheelEvents: wheelHandler.active
@ -65,12 +66,17 @@ Item {
return; return;
} }
var above = target.childAt(event.x, event.y); //var above = target.childAt(event.x, event.y);
let above;
if (isGroupDialog) {
above = target.itemAt(event.x, event.y);
} else {
above = target.childAt(event.x, event.y);
}
if (!above) { if (!above) {
hoveredItem = null; hoveredItem = null;
activationTimer.stop(); activationTimer.stop();
return; return;
} }
@ -101,9 +107,9 @@ Item {
var insertAt = TaskTools.insertIndexAt(above, event.x, event.y); var insertAt = TaskTools.insertIndexAt(above, event.x, event.y);
if (tasks.dragSource !== above && tasks.dragSource.itemIndex !== insertAt) { if (tasks.dragSource !== above && tasks.dragSource.itemIndex !== insertAt) {
if (groupDialog.visible && groupDialog.visualParent) { if (!!tasks.groupDialog) {
tasksModel.move(tasks.dragSource.itemIndex, insertAt, tasksModel.move(tasks.dragSource.itemIndex, insertAt,
tasksModel.makeModelIndex(groupDialog.visualParent.itemIndex)); tasksModel.makeModelIndex(tasks.groupDialog.visualParent.itemIndex));
} else { } else {
tasksModel.move(tasks.dragSource.itemIndex, insertAt); tasksModel.move(tasks.dragSource.itemIndex, insertAt);
} }
@ -115,6 +121,7 @@ Item {
hoveredItem = above; hoveredItem = above;
activationTimer.restart(); activationTimer.restart();
} }
tasksModel.syncLaunchers();
} }
onDragLeave: { onDragLeave: {

View file

@ -151,9 +151,10 @@ MouseArea {
} }
} else { } else {
pressed = false; pressed = false;
//if(!ma.pressed) tasks.dragSource = null;
} }
hoverEnabled = true; hoverEnabled = true;
} }
onPressed: { onPressed: {
@ -216,13 +217,14 @@ MouseArea {
pressX = -1; pressX = -1;
pressY = -1; pressY = -1;
hoverEnabled = true; hoverEnabled = true;
} }
onPressAndHold: { onPressAndHold: {
} }
onPositionChanged: { //hoverEnabled: true, but this event still doesn't fire at all onPositionChanged: { //hoverEnabled: true, but this event still doesn't fire at all
//unless i am pressing the left mouse button for a short period of time //unless i am pressing the left mouse button for a short period of time
if (pressX != -1 && mouse.buttons == Qt.LeftButton && dragHelper.isDrag(pressX, pressY, mouse.x, mouse.y)) { if (pressX != -1 && mouse.buttons == Qt.LeftButton && dragHelper.isDrag(pressX, pressY, mouse.x, mouse.y)) {
tasks.dragSource = task; tasks.dragSource = task;
dragHelper.startDrag(task, model.MimeType, model.MimeData, dragHelper.startDrag(task, model.MimeType, model.MimeData,
@ -231,6 +233,10 @@ MouseArea {
pressY = -1; pressY = -1;
return; return;
} }
else
{
tasks.dragSource = null;
}
//code for dragging the task around //code for dragging the task around