KDeclarative: kill own drag and drop handling
Open, Needs TriagePublic

Description

We have our own DropArea and DragArea which we should remove in favor of Qt upstream DropArea and Drag attached property. The Drag attached property is somewhat awkward as it needs to be used in conjunction with MouseArea drag capability. Maybe this is something that can be improved upstream.

Also, there's a DragHandler C++ class for starting a QDrag in Folder View, Kickoff, Kicker, etc which should be analyzed to see what features are needed upstream in Qt so it can be removed as well.

In that also consider touch usecase when you have conflicting interaction, like scroll, context menu, drag. We probably want touch flick to scroll but then you need something like long-press for drag and drop, etc.

broulik created this task.Nov 15 2019, 1:21 PM
broulik updated the task description. (Show Details)Nov 15 2019, 1:26 PM

++++

(we should make a tag for all things that require Qt changes so we can prioritise them)

dfaure renamed this task from Kill own drag and drop handling to KDeclarative: kill own drag and drop handling.Nov 24 2019, 4:01 PM

What exactly would be needed as an upstream change in Qt? Note that you can use Drag together with DragHandler, which I think isn't too bad. If you really want a one-stop shop convenience element, providing something like

// DragArea
import QtQuick
Item {
   id: dragArea
    signal dragFinished(dropAction: int)
    Drag.onDragFinished: (dropAction) => dragArea.dragFinished(dropAction)
    // repeat with dragStarted

    property QtObject target: parent
    // more properties to pass to Drag: mimeData
    DragHandler { id: handler; target: dragArea.target }
    Drag.target: dragArea.target
    Drag.active: handler.active

}

as as an additional element in KDeclarative which is compatible with what Quick provides should work without too imposing much a huge maintenance burden.

What exactly would be needed as an upstream change in Qt?

I believe we need stronger control over the mime data. QtQuick only really exposes things as text, we need to pass through all sorts of native types.

But mostly this repo exists because it was made before QtQuick had D&D support. In fact the original code is based on QDeclarativeItem from Qt4.
I don't know why we carried on using it in so many places.

I think our best bet is to port everything now and see what specific things come up

./plasma-sdk/lookandfeelexplorer/package/contents/ui/main.qml:import org.kde.draganddrop 2.0 as DragAndDrop
./plasma-pa/applet/contents/ui/ListItemBase.qml:import org.kde.draganddrop 2.0 as DragAndDrop
./kdeplasma-addons/applets/mediaframe/package/contents/ui/main.qml:import org.kde.draganddrop 2.0 as DragDrop
./kdeplasma-addons/applets/colorpicker/package/contents/ui/main.qml:import org.kde.draganddrop 2.0
./kdeplasma-addons/applets/notes/package/contents/ui/main.qml:import org.kde.draganddrop 2.0 as DragDrop
./kdeplasma-addons/applets/grouping/package/contents/ui/main.qml:import org.kde.draganddrop 2.0 as DnD
./kdeplasma-addons/applets/quicklaunch/package/contents/ui/IconItem.qml:import org.kde.draganddrop 2.0 as DragAndDrop
./kdeplasma-addons/applets/quicklaunch/package/contents/ui/main.qml:import org.kde.draganddrop 2.0 as DragAndDrop
./kdeplasma-addons/applets/quicklaunch/package/contents/ui/Popup.qml:import org.kde.draganddrop 2.0 as DragAndDrop
./plasma-workspace/applets/systemtray/package/contents/ui/main.qml:import org.kde.draganddrop 2.0 as DnD
./plasma-workspace/applets/icon/package/contents/ui/main.qml:import org.kde.draganddrop 2.0 as DragDrop
./plasma-workspace/wallpapers/image/imagepackage/contents/ui/config.qml:import org.kde.draganddrop 2.0 as DragDrop
./plasma-phone-components/containments/homescreen/package/contents/ui/main.qml:import org.kde.draganddrop 2.0 as DragDrop
./plasma-phone-components/components/mobilehomescreencomponents/qml/HomeScreenContents.qml:import org.kde.draganddrop 2.0 as DragDrop
./plasma-phone-components/components/mobilehomescreencomponents/qml/MobileAppletContainer.qml:import org.kde.draganddrop 2.0 as DragDrop
./plasma-phone-components/components/mobilehomescreencomponents/qml/private/OpenDrawerButton.qml:import org.kde.draganddrop 2.0 as DragDrop
./plasma-phone-components/components/mobilehomescreencomponents/qml/FlickablePages.qml:import org.kde.draganddrop 2.0 as DragDrop
./plasma-desktop/applets/taskmanager/package/contents/ui/Task.qml:import org.kde.draganddrop 2.0
./plasma-desktop/applets/taskmanager/package/contents/ui/MouseHandler.qml:import org.kde.draganddrop 2.0
./plasma-desktop/applets/taskmanager/package/contents/ui/GroupDialog.qml:import org.kde.draganddrop 2.0
./plasma-desktop/applets/showActivityManager/package/contents/ui/main.qml:import org.kde.draganddrop 2.0 as DND
./plasma-desktop/applets/kicker/package/contents/ui/ConfigGeneral.qml:import org.kde.draganddrop 2.0 as DragDrop
./plasma-desktop/applets/kicker/package/contents/ui/SideBarSection.qml:import org.kde.draganddrop 2.0
./plasma-desktop/applets/kicker/package/contents/ui/ItemGridView.qml:import org.kde.draganddrop 2.0
./plasma-desktop/applets/pager/package/contents/ui/main.qml:import org.kde.draganddrop 2.0
./plasma-desktop/applets/trash/package/contents/ui/main.qml:import org.kde.draganddrop 2.0 as DragDrop
./plasma-desktop/containments/desktop/package/contents/ui/main.qml:import org.kde.draganddrop 2.0 as DragDrop
./plasma-desktop/containments/desktop/package/contents/ui/CompactRepresentation.qml:import org.kde.draganddrop 2.0 as DragDrop
./plasma-desktop/containments/desktop/package/contents/ui/FolderViewDropArea.qml:import org.kde.draganddrop 2.0 as DragDrop
./plasma-desktop/containments/panel/contents/ui/main.qml:import org.kde.draganddrop 2.0 as DragDrop
./plasma-desktop/desktoppackage/contents/activitymanager/TaskDropArea.qml:import org.kde.draganddrop 2.0 as DND
./plasma-desktop/desktoppackage/contents/explorer/AppletDelegate.qml:import org.kde.draganddrop 2.0
./plasma-nano/shell/contents/explorer/AppletDelegate.qml:import org.kde.draganddrop 2.0
./plasma-nano/shell/contents/explorer/AppletDelegate.qml:import org.kde.draganddrop 2.0 as DragDrop

DragHandler isn't doing anything specific for DnD, which is why you still need to mess with the Drag attached property so far. But that leaves us open for coming up with a better API. Maybe some brainstorming about some really ideal API would be in order, to make it as simple as possible? I.e. the minimal set of declarations that can be added to a DragHandler so that it works with a DropArea or with external applications. I guess we still need to keep the distinction between internal and external DnD? Or do we?

ndavis added a subscriber: ndavis.Oct 3 2021, 9:44 PM

One thing that Qt's Drag attached object will need is a way to set the image via a QIcon, icon name string or we will need a way to convert QIcons/icon name strings into usable URLs for the Drag.imageSource property.

This comment was removed by fusionfuture.

Remaining:

plasma/kdeplasma-addons/applets/grouping/package/contents/ui/main.qml

plasma/kdeplasma-addons/applets/mediaframe/package/contents/ui/main.qml

plasma/kdeplasma-addons/applets/notes/package/contents/ui/main.qml

plasma/kdeplasma-addons/applets/quicklaunch/package/contents/ui/IconItem.qml

plasma/kdeplasma-addons/applets/quicklaunch/package/contents/ui/Popup.qml

plasma/kdeplasma-addons/applets/quicklaunch/package/contents/ui/main.qml

plasma/latte-dock/containment/package/contents/ui/DragDropArea.qml

plasma/latte-dock/plasmoid/package/contents/ui/previews/ToolTipDelegate2.qml

plasma/latte-dock/plasmoid/package/contents/ui/previews/ToolTipInstance.qml

plasma/latte-dock/plasmoid/package/contents/ui/taskslayout/MouseHandler.qml

plasma/latte-dock/shell/package/contents/views/AppletDelegate.qml

plasma/plasma-desktop/applets/kicker/package/contents/ui/ConfigGeneral.qml

plasma/plasma-desktop/applets/kicker/package/contents/ui/SideBarSection.qml

plasma/plasma-desktop/applets/pager/package/contents/ui/main.qml

plasma/plasma-desktop/applets/showActivityManager/package/contents/ui/main.qml

plasma/plasma-desktop/applets/taskmanager/package/contents/ui/GroupDialog.qml

plasma/plasma-desktop/applets/trash/package/contents/ui/main.qml

plasma/plasma-desktop/containments/desktop/package/contents/ui/CompactRepresentation.qml

plasma/plasma-desktop/containments/desktop/package/contents/ui/FolderViewDropArea.qml

plasma/plasma-desktop/containments/panel/contents/ui/main.qml

plasma/plasma-desktop/desktoppackage/contents/activitymanager/TaskDropArea.qml

plasma/plasma-mobile/containments/homescreens/folio/package/contents/ui/HomeScreen.qml

plasma/plasma-mobile/containments/homescreens/folio/package/contents/ui/HomeScreenContents.qml

plasma/plasma-mobile/containments/homescreens/folio/package/contents/ui/HomeScreenPages.qml

plasma/plasma-mobile/containments/homescreens/folio/package/contents/ui/MobileAppletContainer.qml

plasma/plasma-mobile/containments/homescreens/folio/package/contents/ui/private/OpenDrawerButton.qml

plasma/plasma-mobile/containments/homescreens/halcyon/package/contents/ui/FavoritesGrid.qml

plasma/plasma-mobile/containments/homescreens/halcyon/package/contents/ui/FavoritesView.qml

plasma/plasma-mobile/containments/homescreens/halcyon/package/contents/ui/FolderGrid.qml

plasma/plasma-mobile/containments/homescreens/halcyon/package/contents/ui/HomeScreen.qml

plasma/plasma-nano/shell/contents/explorer/AppletDelegate.qml

plasma/plasma-sdk/lookandfeelexplorer/package/contents/ui/main.qml

plasma/plasma-simplemenu/package/contents/ui/ConfigGeneral.qml

plasma/plasma-simplemenu/package/contents/ui/ItemGridView.qml

plasma/plasma-workspace/applets/icon/package/contents/ui/main.qml

plasma/plasma-workspace/applets/systemtray/package/contents/ui/main.qml

All of the usages are in Plasma, so we could move it there to avoid carrying it in Frameworks