123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101 |
- From ac9ef2b66d4be08cbf6a1702ee92641b80e50974 Mon Sep 17 00:00:00 2001
- From: Noah Davis <noahadvs@gmail.com>
- Date: Sun, 17 Oct 2021 05:50:26 -0400
- Subject: [PATCH] kickoff: Replace Kicker DragHelper with Qt Quick Drag
- Originally, I thought it wasn't possible to use Qt Quick Drag here, but
- then I found out I could use Item::grabToImage()'s function callback
- parameter to set Drag.imageSource.
- BUG: 443708
- ---
- .../contents/ui/KickoffItemDelegate.qml | 25 +++++++------------
- .../package/contents/ui/KickoffSingleton.qml | 11 --------
- 2 files changed, 9 insertions(+), 27 deletions(-)
- diff --git a/applets/kickoff/package/contents/ui/KickoffItemDelegate.qml b/applets/kickoff/package/contents/ui/KickoffItemDelegate.qml
- index bb2bc1185..c77b07111 100644
- --- a/applets/kickoff/package/contents/ui/KickoffItemDelegate.qml
- +++ b/applets/kickoff/package/contents/ui/KickoffItemDelegate.qml
- @@ -179,6 +179,10 @@ T.ItemDelegate {
- maximumLineCount: 1
- }
-
- + Drag.active: mouseArea.drag.active
- + Drag.dragType: Drag.Automatic
- + Drag.mimeData: { "text/uri-list" : root.url }
- +
- MouseArea {
- id: mouseArea
- parent: root
- @@ -201,16 +205,6 @@ T.ItemDelegate {
- minimumY: 0
- maximumY: root.view ? Math.min(root.view.contentHeight - root.height, root.view.availableHeight - root.height) : root.y
- }
- - Binding {
- - target: KickoffSingleton; when: root.dragActive
- - property: "dragSource"; value: root
- - restoreMode: Binding.RestoreBindingOrValue
- - }
- - Binding {
- - target: KickoffSingleton.dragHelper; when: root.dragActive
- - property: "dragIconSize"; value: root.icon.height
- - restoreMode: Binding.RestoreBindingOrValue
- - }
- // Using onPositionChanged instead of onEntered to prevent changing
- // categories while scrolling with the mouse wheel.
- onPositionChanged: {
- @@ -223,6 +217,11 @@ T.ItemDelegate {
- // built into QQuickListView::setCurrentIndex() already
- root.view.currentIndex = index
- }
- + onPressed: if (root.dragEnabled && root.Drag.imageSource == "") {
- + iconItem.grabToImage((result) => {
- + return root.Drag.imageSource = result.url
- + })
- + }
- onClicked: if (mouse.button === Qt.LeftButton) {
- root.forceActiveFocus(Qt.MouseFocusReason)
- root.action.trigger() // clicked() is emmitted when action is triggered
- @@ -277,15 +276,9 @@ T.ItemDelegate {
- indicator = null
- }
- }
- -
- - // NOTE: Not using Drag attached properties because we're using DragHelper instead.
- - // Drag doesn't support QIcons for the imageSource, only URLs.
- onDragActiveChanged: if (dragActive) {
- dragStartPosition = Qt.point(x,y)
- dragStartIndex = index
- - // Fixes warning: "Passing incompatible arguments to C++ functions from JavaScript is dangerous and deprecated."
- - //const url = root.url ? root.url : ""
- - KickoffSingleton.dragHelper.startDrag(root, url, decoration)
- } else if (dragStartIndex === index) {
- x = dragStartPosition.x
- y = dragStartPosition.y
- diff --git a/applets/kickoff/package/contents/ui/KickoffSingleton.qml b/applets/kickoff/package/contents/ui/KickoffSingleton.qml
- index 3e1ff50db..d77e40bf5 100644
- --- a/applets/kickoff/package/contents/ui/KickoffSingleton.qml
- +++ b/applets/kickoff/package/contents/ui/KickoffSingleton.qml
- @@ -45,17 +45,6 @@ Item {
- }
- //END
-
- - //BEGIN Drag and Drop elements
- - property Item dragSource: null
- - // We have to use DragHelper here because the models use QIcons for the decoration role.
- - // DragHelper supports QIcons and Drag.imageSource only supports urls.
- - readonly property Kicker.DragHelper dragHelper: Kicker.DragHelper {
- - id: dragHelper
- - dragIconSize: PlasmaCore.Units.iconSizes.medium
- - onDropped: dragSource = null
- - }
- - //END
- -
- //BEGIN UI elements
- // Set in FullRepresentation.qml
- property Item header: null
- --
- GitLab
|