diff --git a/applets/colorpicker/package/contents/ui/main.qml b/applets/colorpicker/package/contents/ui/main.qml --- a/applets/colorpicker/package/contents/ui/main.qml +++ b/applets/colorpicker/package/contents/ui/main.qml @@ -277,6 +277,19 @@ onTriggered: plasmoid.expanded = false } + // This item serves as a drag pixmap and is captured when a drag starts + Rectangle { + id: dragImageDummy + border { + color: theme.textColor + width: Math.round(units.devicePixelRatio) + } + radius: width + width: units.iconSizes.large + height: units.iconSizes.large + visible: false + } + delegate: MouseArea { id: delegateMouse @@ -302,6 +315,16 @@ } } + onPressed: { + // grab pixmap only once + if (Drag.imageSource.toString() === "") { // cannot just do !Drage.imageSource on QUrl + dragImageDummy.color = currentColor; + dragImageDummy.grabToImage(function (result) { + Drag.imageSource = result.url; + }); + } + } + onClicked: { formattingMenu.model = Logic.menuForColor(delegateMouse.currentColor) formattingMenu.open(0, rect.height)