forked from andreagen0r/ColorPicker
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathColorSampler.qml
More file actions
84 lines (72 loc) · 1.71 KB
/
ColorSampler.qml
File metadata and controls
84 lines (72 loc) · 1.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
import QtQuick
import ColorTools
Item {
id: root
property alias color: internal.color
property bool border: true
property real radius: 0
signal clicked
signal doubleClicked
ColorSampler_p {
id: internal
}
Image {
anchors.fill: parent
visible: internal.color.a < 1
fillMode: Image.Tile
horizontalAlignment: Image.AlignLeft
verticalAlignment: Image.AlignTop
source: "assets/alphaBackground.png"
}
Rectangle {
anchors.fill: parent
radius: root.radius
border.width: root.border ? 1 : 0
color: internal.color
Rectangle {
anchors.fill: parent
anchors.margins: 1
color: "transparent"
border.width: root.border ? 1 : 0
border.color: "lightgray"
radius: root.radius
}
}
DropArea {
id: dropAreag
anchors.fill: parent
keys: ["application/x-color"]
onEntered: drag => {
if (!drag.hasColor) {
drag.accepted = false
}
}
onDropped: drop => {
if (drop.hasColor) {
if (drop.proposedAction === Qt.CopyAction) {
internal.setColor(drop.colorData)
drop.acceptProposedAction()
}
}
}
}
Item {
id: draggable
anchors.fill: parent
Drag.dragType: Drag.Automatic
Drag.supportedActions: Qt.CopyAction
Drag.mimeData: {
"application/x-color": internal.color
}
MouseArea {
anchors.fill: parent
onClicked: root.clicked()
onDoubleClicked: root.doubleClicked()
}
}
DragHandler {
id: dragHandler
target: draggable
onActiveChanged: draggable.Drag.active = active
}
}