plasmoid: port away from custom drag handler

BUG: 464528
CCBUG: 402376
work/fuf/bug464528
Fushan Wen 2 years ago
parent 57c6148dc4
commit 218ff83986
No known key found for this signature in database
GPG Key ID: 2E48D1487C91DCAA

@ -598,7 +598,9 @@ Item {
TaskManagerApplet.DragHelper { TaskManagerApplet.DragHelper {
id: dragHelper id: dragHelper
dragIconSize: units.iconSizes.medium Drag.dragType: Drag.Automatic
Drag.supportedActions: Qt.CopyAction | Qt.MoveAction | Qt.LinkAction
Drag.onDragFinished: root.dragSource = null;
} }
TaskManager.VirtualDesktopInfo { TaskManager.VirtualDesktopInfo {
@ -1273,11 +1275,6 @@ Item {
return false; return false;
} }
function resetDragSource() {
dragSource.z = 0;
dragSource = null;
}
///REMOVE ///REMOVE
/*function createContextMenu(task) { /*function createContextMenu(task) {
var menu = root.contextMenuComponent.createObject(task); var menu = root.contextMenuComponent.createObject(task);
@ -1307,7 +1304,6 @@ Item {
} }
root.windowsHovered.connect(backend.windowsHovered); root.windowsHovered.connect(backend.windowsHovered);
dragHelper.dropped.connect(resetDragSource);
updateListViewParent(); updateListViewParent();
} }
@ -1319,7 +1315,6 @@ Item {
} }
root.windowsHovered.disconnect(backend.windowsHovered); root.windowsHovered.disconnect(backend.windowsHovered);
dragHelper.dropped.disconnect(resetDragSource);
} }
//BEGIN states //BEGIN states

@ -328,9 +328,15 @@ AbilityItem.BasicItem {
onIsDraggedChanged: { onIsDraggedChanged: {
if (isDragged){ if (isDragged){
root.dragSource = taskItem; taskItem.contentItem.monochromizedItem.grabToImage((result) => {
dragHelper.startDrag(taskItem, model.MimeType, model.MimeData, root.dragSource = taskItem;
model.LauncherUrlWithoutIcon, model.decoration); dragHelper.Drag.imageSource = result.url;
dragHelper.Drag.mimeData = dragHelper.generateMimeData(model.MimeType, model.MimeData, model.LauncherUrlWithoutIcon);
dragHelper.Drag.active = true;
});
} else {
dragHelper.Drag.active = false;
dragHelper.Drag.imageSource = "";
pressX = -1; pressX = -1;
pressY = -1; pressY = -1;
} }

@ -81,12 +81,15 @@ MouseArea {
// mouse.button is always 0 here, hence checking with mouse.buttons // mouse.button is always 0 here, hence checking with mouse.buttons
if (pressX != -1 && mouse.buttons == Qt.LeftButton if (pressX != -1 && mouse.buttons == Qt.LeftButton
&& isDragged && isDragged
&& dragHelper.isDrag(pressX, pressY, mouse.x, mouse.y) ) { && (Math.abs(pressX - mouse.x) + Math.abs(pressY - mouse.y) >= Qt.styleHints.startDragDistance) ) {
root.dragSource = taskItem; taskItem.contentItem.monochromizedItem.grabToImage((result) => {
dragHelper.startDrag(taskItem, model.MimeType, model.MimeData, pressX = -1;
model.LauncherUrlWithoutIcon, model.decoration); pressY = -1;
pressX = -1; root.dragSource = taskItem;
pressY = -1; dragHelper.Drag.imageSource = result.url;
dragHelper.Drag.mimeData = dragHelper.generateMimeData(model.MimeType, model.MimeData, model.LauncherUrlWithoutIcon);
dragHelper.Drag.active = true;
});
} }
} }
} }

Loading…
Cancel
Save