ac9ef2b6.patch 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. From ac9ef2b66d4be08cbf6a1702ee92641b80e50974 Mon Sep 17 00:00:00 2001
  2. From: Noah Davis <noahadvs@gmail.com>
  3. Date: Sun, 17 Oct 2021 05:50:26 -0400
  4. Subject: [PATCH] kickoff: Replace Kicker DragHelper with Qt Quick Drag
  5. Originally, I thought it wasn't possible to use Qt Quick Drag here, but
  6. then I found out I could use Item::grabToImage()'s function callback
  7. parameter to set Drag.imageSource.
  8. BUG: 443708
  9. ---
  10. .../contents/ui/KickoffItemDelegate.qml | 25 +++++++------------
  11. .../package/contents/ui/KickoffSingleton.qml | 11 --------
  12. 2 files changed, 9 insertions(+), 27 deletions(-)
  13. diff --git a/applets/kickoff/package/contents/ui/KickoffItemDelegate.qml b/applets/kickoff/package/contents/ui/KickoffItemDelegate.qml
  14. index bb2bc1185..c77b07111 100644
  15. --- a/applets/kickoff/package/contents/ui/KickoffItemDelegate.qml
  16. +++ b/applets/kickoff/package/contents/ui/KickoffItemDelegate.qml
  17. @@ -179,6 +179,10 @@ T.ItemDelegate {
  18. maximumLineCount: 1
  19. }
  20. + Drag.active: mouseArea.drag.active
  21. + Drag.dragType: Drag.Automatic
  22. + Drag.mimeData: { "text/uri-list" : root.url }
  23. +
  24. MouseArea {
  25. id: mouseArea
  26. parent: root
  27. @@ -201,16 +205,6 @@ T.ItemDelegate {
  28. minimumY: 0
  29. maximumY: root.view ? Math.min(root.view.contentHeight - root.height, root.view.availableHeight - root.height) : root.y
  30. }
  31. - Binding {
  32. - target: KickoffSingleton; when: root.dragActive
  33. - property: "dragSource"; value: root
  34. - restoreMode: Binding.RestoreBindingOrValue
  35. - }
  36. - Binding {
  37. - target: KickoffSingleton.dragHelper; when: root.dragActive
  38. - property: "dragIconSize"; value: root.icon.height
  39. - restoreMode: Binding.RestoreBindingOrValue
  40. - }
  41. // Using onPositionChanged instead of onEntered to prevent changing
  42. // categories while scrolling with the mouse wheel.
  43. onPositionChanged: {
  44. @@ -223,6 +217,11 @@ T.ItemDelegate {
  45. // built into QQuickListView::setCurrentIndex() already
  46. root.view.currentIndex = index
  47. }
  48. + onPressed: if (root.dragEnabled && root.Drag.imageSource == "") {
  49. + iconItem.grabToImage((result) => {
  50. + return root.Drag.imageSource = result.url
  51. + })
  52. + }
  53. onClicked: if (mouse.button === Qt.LeftButton) {
  54. root.forceActiveFocus(Qt.MouseFocusReason)
  55. root.action.trigger() // clicked() is emmitted when action is triggered
  56. @@ -277,15 +276,9 @@ T.ItemDelegate {
  57. indicator = null
  58. }
  59. }
  60. -
  61. - // NOTE: Not using Drag attached properties because we're using DragHelper instead.
  62. - // Drag doesn't support QIcons for the imageSource, only URLs.
  63. onDragActiveChanged: if (dragActive) {
  64. dragStartPosition = Qt.point(x,y)
  65. dragStartIndex = index
  66. - // Fixes warning: "Passing incompatible arguments to C++ functions from JavaScript is dangerous and deprecated."
  67. - //const url = root.url ? root.url : ""
  68. - KickoffSingleton.dragHelper.startDrag(root, url, decoration)
  69. } else if (dragStartIndex === index) {
  70. x = dragStartPosition.x
  71. y = dragStartPosition.y
  72. diff --git a/applets/kickoff/package/contents/ui/KickoffSingleton.qml b/applets/kickoff/package/contents/ui/KickoffSingleton.qml
  73. index 3e1ff50db..d77e40bf5 100644
  74. --- a/applets/kickoff/package/contents/ui/KickoffSingleton.qml
  75. +++ b/applets/kickoff/package/contents/ui/KickoffSingleton.qml
  76. @@ -45,17 +45,6 @@ Item {
  77. }
  78. //END
  79. - //BEGIN Drag and Drop elements
  80. - property Item dragSource: null
  81. - // We have to use DragHelper here because the models use QIcons for the decoration role.
  82. - // DragHelper supports QIcons and Drag.imageSource only supports urls.
  83. - readonly property Kicker.DragHelper dragHelper: Kicker.DragHelper {
  84. - id: dragHelper
  85. - dragIconSize: PlasmaCore.Units.iconSizes.medium
  86. - onDropped: dragSource = null
  87. - }
  88. - //END
  89. -
  90. //BEGIN UI elements
  91. // Set in FullRepresentation.qml
  92. property Item header: null
  93. --
  94. GitLab