Repository navigation
Expand file tree
/
Copy pathCaptureOverlay.qml
More file actions
707 lines (645 loc) · 25.3 KB
/
Copy pathCaptureOverlay.qml
File metadata and controls
707 lines (645 loc) · 25.3 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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
// SPDX-License-Identifier: GPL-3.0-or-later
pragma ComponentBehavior: Bound
import QtQuick
import GrabInk
Window {
id: overlay
required property ScreenshotService screenshotService
visible: false
color: "transparent"
flags: Qt.FramelessWindowHint | Qt.WindowStaysOnTopHint
title: qsTr("选择并标注截图")
property real startX: 0
property real startY: 0
property real dragSelectionX: 0
property real dragSelectionY: 0
property real dragSelectionWidth: 0
property real dragSelectionHeight: 0
property real selectionX: 0
property real selectionY: 0
property real selectionWidth: 0
property real selectionHeight: 0
property real pointerX: 0
property real pointerY: 0
property real textLocalX: 0
property real textLocalY: 0
property bool editing: false
property bool finishing: false
property bool colorPaletteVisible: false
property bool textEditing: false
property string activeTool: ""
property string previousDrawTool: "pen"
property string selectionDragMode: ""
property string selectedColor: "#FF5967"
property string hoveredPixelColor: "#000000"
property var annotations: []
property var draftAnnotation: null
readonly property color shadeColor: "#52000000"
readonly property real minimumSelectionSize: 8
readonly property real newSelectionDragThreshold: 3
readonly property real resizeHitMargin: 7
readonly property real selectionHandleSize: 8
readonly property bool selectionValid: selectionWidth >= 8 && selectionHeight >= 8
readonly property real imageLeft: (width - baseImage.paintedWidth) / 2
readonly property real imageTop: (height - baseImage.paintedHeight) / 2
readonly property real imageRight: imageLeft + baseImage.paintedWidth
readonly property real imageBottom: imageTop + baseImage.paintedHeight
readonly property real selectableLeft: imageLeft
readonly property real selectableTop: imageTop
readonly property real selectableRight: imageRight
readonly property real selectableBottom: imageBottom
readonly property real imageScaleX: baseImage.sourceSize.width > 0
&& baseImage.paintedWidth > 0
? baseImage.sourceSize.width / baseImage.paintedWidth : 1
readonly property real imageScaleY: baseImage.sourceSize.height > 0
&& baseImage.paintedHeight > 0
? baseImage.sourceSize.height / baseImage.paintedHeight : 1
onAnnotationsChanged: annotationLayer.requestPaint()
onDraftAnnotationChanged: annotationLayer.requestPaint()
onClosing: close => {
close.accepted = false
overlay.cancel()
}
function showOverlay() {
selectionX = 0
selectionY = 0
selectionWidth = 0
selectionHeight = 0
pointerX = 0
pointerY = 0
editing = false
finishing = false
colorPaletteVisible = false
textEditing = false
activeTool = ""
previousDrawTool = "pen"
selectionDragMode = ""
annotations = []
draftAnnotation = null
showFullScreen()
requestActivate()
}
function clampImageX(value) {
return Math.max(selectableLeft, Math.min(selectableRight, value))
}
function clampImageY(value) {
return Math.max(selectableTop, Math.min(selectableBottom, value))
}
function resizeModeAt(x, y) {
if (!editing || !selectionValid)
return ""
const left = selectionX
const top = selectionY
const right = selectionX + selectionWidth
const bottom = selectionY + selectionHeight
const nearLeft = Math.abs(x - left) <= resizeHitMargin
const nearRight = Math.abs(x - right) <= resizeHitMargin
const nearTop = Math.abs(y - top) <= resizeHitMargin
const nearBottom = Math.abs(y - bottom) <= resizeHitMargin
const withinHorizontal = x >= left - resizeHitMargin
&& x <= right + resizeHitMargin
const withinVertical = y >= top - resizeHitMargin
&& y <= bottom + resizeHitMargin
if (nearLeft && nearTop) return "nw"
if (nearRight && nearTop) return "ne"
if (nearLeft && nearBottom) return "sw"
if (nearRight && nearBottom) return "se"
if (nearTop && withinHorizontal) return "n"
if (nearBottom && withinHorizontal) return "s"
if (nearLeft && withinVertical) return "w"
if (nearRight && withinVertical) return "e"
return ""
}
function resizeCursor(mode) {
if (mode === "n" || mode === "s") return Qt.SizeVerCursor
if (mode === "e" || mode === "w") return Qt.SizeHorCursor
if (mode === "nw" || mode === "se") return Qt.SizeFDiagCursor
if (mode === "ne" || mode === "sw") return Qt.SizeBDiagCursor
return Qt.ArrowCursor
}
function selectionCursorShape() {
if (selectionDragMode === "new" || selectionDragMode === "pendingNew")
return Qt.CrossCursor
const mode = selectionDragMode !== ""
? selectionDragMode : resizeModeAt(pointerX, pointerY)
if (mode !== "")
return resizeCursor(mode)
if (!editing || !pointInsideSelection(pointerX, pointerY))
return Qt.CrossCursor
if (activeTool === "text")
return Qt.IBeamCursor
return activeTool !== "" ? Qt.CrossCursor : Qt.ArrowCursor
}
function handleCenterX(mode) {
if (mode.indexOf("w") !== -1) return selectionX
if (mode.indexOf("e") !== -1) return selectionX + selectionWidth
return selectionX + selectionWidth / 2
}
function handleCenterY(mode) {
if (mode.indexOf("n") !== -1) return selectionY
if (mode.indexOf("s") !== -1) return selectionY + selectionHeight
return selectionY + selectionHeight / 2
}
function clearSelectionContent() {
editing = false
activeTool = ""
colorPaletteVisible = false
textEditing = false
textInput.text = ""
annotations = []
draftAnnotation = null
annotationLayer.requestPaint()
}
function beginNewSelection(x, y) {
clearSelectionContent()
const imageX = clampImageX(x)
const imageY = clampImageY(y)
startX = imageX
startY = imageY
selectionX = imageX
selectionY = imageY
selectionWidth = 0
selectionHeight = 0
selectionDragMode = "new"
}
function prepareNewSelection(x, y) {
startX = clampImageX(x)
startY = clampImageY(y)
colorPaletteVisible = false
selectionDragMode = "pendingNew"
}
function beginSelectionResize(mode) {
selectionDragMode = mode
dragSelectionX = selectionX
dragSelectionY = selectionY
dragSelectionWidth = selectionWidth
dragSelectionHeight = selectionHeight
colorPaletteVisible = false
draftAnnotation = null
}
function translateAnnotations(deltaX, deltaY) {
if ((deltaX === 0 && deltaY === 0) || annotations.length === 0)
return
const translated = []
for (let i = 0; i < annotations.length; ++i) {
const item = annotations[i]
const copy = {}
for (let key in item)
copy[key] = item[key]
if (typeof item.x1 === "number") copy.x1 = item.x1 + deltaX
if (typeof item.y1 === "number") copy.y1 = item.y1 + deltaY
if (typeof item.x2 === "number") copy.x2 = item.x2 + deltaX
if (typeof item.y2 === "number") copy.y2 = item.y2 + deltaY
if (item.points) {
copy.points = []
for (let j = 0; j < item.points.length; ++j) {
copy.points.push({
x: item.points[j].x + deltaX,
y: item.points[j].y + deltaY
})
}
}
translated.push(copy)
}
annotations = translated
}
function updateSelectionResize(x, y) {
const mode = selectionDragMode
const originalRight = dragSelectionX + dragSelectionWidth
const originalBottom = dragSelectionY + dragSelectionHeight
const imageX = clampImageX(x)
const imageY = clampImageY(y)
let left = dragSelectionX
let top = dragSelectionY
let right = originalRight
let bottom = originalBottom
if (mode.indexOf("w") !== -1)
left = Math.max(selectableLeft,
Math.min(originalRight - minimumSelectionSize, imageX))
if (mode.indexOf("e") !== -1)
right = Math.min(selectableRight,
Math.max(dragSelectionX + minimumSelectionSize, imageX))
if (mode.indexOf("n") !== -1)
top = Math.max(selectableTop,
Math.min(originalBottom - minimumSelectionSize, imageY))
if (mode.indexOf("s") !== -1)
bottom = Math.min(selectableBottom,
Math.max(dragSelectionY + minimumSelectionSize, imageY))
const deltaX = selectionX - left
const deltaY = selectionY - top
selectionX = left
selectionY = top
selectionWidth = right - left
selectionHeight = bottom - top
translateAnnotations(deltaX, deltaY)
annotationLayer.requestPaint()
}
function cancel() {
if (finishing)
return
hide()
overlay.screenshotService.cancelSelection()
}
function handleEscape() {
if (textEditing) {
textEditing = false
textInput.text = ""
} else if (colorPaletteVisible) {
colorPaletteVisible = false
} else {
cancel()
}
}
function resetSelection() {
selectionDragMode = ""
clearSelectionContent()
selectionWidth = 0
selectionHeight = 0
}
function undo() {
if (annotations.length === 0)
return
annotations = annotations.slice(0, annotations.length - 1)
}
function selectTool(tool) {
if (textEditing)
commitText()
colorPaletteVisible = false
if (tool !== "picker" && tool !== "blur" && tool !== "mosaic")
previousDrawTool = tool
activeTool = activeTool === tool ? "" : tool
}
function beginText(point) {
textLocalX = point.x
textLocalY = point.y
textInput.text = ""
textEditing = true
Qt.callLater(function() { textInput.forceActiveFocus() })
}
function commitText() {
if (!textEditing)
return
const value = textInput.text.trim()
textEditing = false
textInput.text = ""
if (value.length === 0)
return
annotations = annotations.concat([{
type: "text",
x1: textLocalX,
y1: textLocalY,
text: value,
color: selectedColor,
width: 1,
fontSize: 18
}])
}
function confirm() {
if (!selectionValid || finishing)
return
if (textEditing)
commitText()
finishing = true
const resultAnnotations = annotations
hide()
overlay.screenshotService.finishAnnotatedSelection(
selectionX - imageLeft, selectionY - imageTop,
selectionWidth, selectionHeight,
baseImage.paintedWidth, baseImage.paintedHeight,
resultAnnotations)
finishing = false
}
function pointInsideSelection(x, y) {
return x >= selectionX && x <= selectionX + selectionWidth
&& y >= selectionY && y <= selectionY + selectionHeight
}
function localPoint(x, y) {
return {
x: Math.max(0, Math.min(selectionWidth, x - selectionX)),
y: Math.max(0, Math.min(selectionHeight, y - selectionY))
}
}
function toolLabel(tool) {
if (tool === "rect") return qsTr("矩形")
if (tool === "arrow") return qsTr("箭头")
if (tool === "pen") return qsTr("画笔")
if (tool === "text") return qsTr("文字")
if (tool === "picker") return qsTr("像素取色")
if (tool === "blur") return qsTr("模糊")
if (tool === "mosaic") return qsTr("马赛克")
return qsTr("未选择工具")
}
Shortcut { sequence: "Escape"; enabled: overlay.visible && !overlay.textEditing; onActivated: overlay.handleEscape() }
Shortcut { sequence: "Return"; enabled: overlay.visible && overlay.selectionValid && !overlay.textEditing; onActivated: overlay.confirm() }
Shortcut { sequence: "Ctrl+Z"; enabled: overlay.visible && overlay.editing && !overlay.textEditing; onActivated: overlay.undo() }
Connections {
target: overlay.screenshotService
function onSelectionRequested() { overlay.showOverlay() }
}
Rectangle {
anchors.fill: parent
color: "black"
z: -2
}
Image {
id: baseImage
anchors.fill: parent
source: overlay.screenshotService.selectionSource
fillMode: Image.PreserveAspectFit
cache: false
asynchronous: false
}
AnnotationLayer {
id: annotationLayer
x: overlay.selectionX
y: overlay.selectionY
width: overlay.selectionWidth
height: overlay.selectionHeight
clip: true
visible: overlay.selectionValid
z: 1
source: overlay.screenshotService.selectionSource
annotations: overlay.annotations
draftAnnotation: overlay.draftAnnotation
viewportWidth: overlay.width
viewportHeight: overlay.height
}
Rectangle {
anchors.fill: parent
color: overlay.shadeColor
visible: !overlay.selectionValid
z: 2
}
Rectangle { x: 0; y: 0; width: parent.width; height: overlay.selectionY; color: overlay.shadeColor; visible: overlay.selectionValid; z: 2 }
Rectangle { x: 0; y: overlay.selectionY; width: overlay.selectionX; height: overlay.selectionHeight; color: overlay.shadeColor; visible: overlay.selectionValid; z: 2 }
Rectangle { x: overlay.selectionX + overlay.selectionWidth; y: overlay.selectionY; width: parent.width - x; height: overlay.selectionHeight; color: overlay.shadeColor; visible: overlay.selectionValid; z: 2 }
Rectangle { x: 0; y: overlay.selectionY + overlay.selectionHeight; width: parent.width; height: parent.height - y; color: overlay.shadeColor; visible: overlay.selectionValid; z: 2 }
Rectangle {
x: overlay.selectionX
y: overlay.selectionY
width: overlay.selectionWidth
height: overlay.selectionHeight
color: "transparent"
border.width: 2
border.color: "#6F80FF"
visible: overlay.selectionValid
z: 3
}
Item {
anchors.fill: parent
visible: overlay.editing && overlay.selectionValid
z: 6
Repeater {
model: ["nw", "n", "ne", "e", "se", "s", "sw", "w"]
delegate: Rectangle {
id: selectionHandle
required property string modelData
x: overlay.handleCenterX(modelData) - width / 2
y: overlay.handleCenterY(modelData) - height / 2
width: overlay.selectionHandleSize
height: overlay.selectionHandleSize
radius: 1
color: "white"
border.width: 1
border.color: "#4358E8"
}
}
}
MouseArea {
id: selectMouse
anchors.fill: parent
enabled: !overlay.textEditing
hoverEnabled: true
cursorShape: overlay.selectionCursorShape()
z: 5
onPressed: mouse => {
if (overlay.finishing)
return
overlay.pointerX = mouse.x
overlay.pointerY = mouse.y
if (!overlay.editing) {
overlay.beginNewSelection(mouse.x, mouse.y)
return
}
const resizeMode = overlay.resizeModeAt(mouse.x, mouse.y)
if (resizeMode !== "") {
overlay.beginSelectionResize(resizeMode)
return
}
if (!overlay.pointInsideSelection(mouse.x, mouse.y)) {
overlay.prepareNewSelection(mouse.x, mouse.y)
return
}
if (overlay.activeTool === "")
return
if (overlay.activeTool === "picker") {
const picked = overlay.screenshotService.pixelColor(
mouse.x - overlay.imageLeft, mouse.y - overlay.imageTop,
baseImage.paintedWidth, baseImage.paintedHeight)
overlay.selectedColor = picked
overlay.hoveredPixelColor = picked
overlay.activeTool = overlay.previousDrawTool
return
}
const p = overlay.localPoint(mouse.x, mouse.y)
if (overlay.activeTool === "text") {
overlay.beginText(p)
return
}
overlay.draftAnnotation = {
type: overlay.activeTool,
color: overlay.selectedColor,
width: overlay.activeTool === "pen" ? 4 : 3,
x1: p.x, y1: p.y, x2: p.x, y2: p.y,
points: [{ x: p.x, y: p.y }]
}
}
onPositionChanged: mouse => {
overlay.pointerX = mouse.x
overlay.pointerY = mouse.y
if (overlay.editing && overlay.activeTool === "picker"
&& overlay.pointInsideSelection(mouse.x, mouse.y)) {
overlay.hoveredPixelColor = overlay.screenshotService.pixelColor(
mouse.x - overlay.imageLeft, mouse.y - overlay.imageTop,
baseImage.paintedWidth, baseImage.paintedHeight)
}
if (!pressed || overlay.finishing)
return
if (overlay.selectionDragMode === "pendingNew") {
const pendingX = overlay.clampImageX(mouse.x)
const pendingY = overlay.clampImageY(mouse.y)
if (Math.abs(pendingX - overlay.startX) < overlay.newSelectionDragThreshold
&& Math.abs(pendingY - overlay.startY)
< overlay.newSelectionDragThreshold) {
return
}
overlay.beginNewSelection(overlay.startX, overlay.startY)
}
if (overlay.selectionDragMode === "new") {
const imageX = overlay.clampImageX(mouse.x)
const imageY = overlay.clampImageY(mouse.y)
overlay.selectionX = Math.min(overlay.startX, imageX)
overlay.selectionY = Math.min(overlay.startY, imageY)
overlay.selectionWidth = Math.abs(imageX - overlay.startX)
overlay.selectionHeight = Math.abs(imageY - overlay.startY)
return
}
if (overlay.selectionDragMode !== "") {
overlay.updateSelectionResize(mouse.x, mouse.y)
return
}
if (!overlay.draftAnnotation)
return
const p = overlay.localPoint(mouse.x, mouse.y)
overlay.draftAnnotation.x2 = p.x
overlay.draftAnnotation.y2 = p.y
if (overlay.draftAnnotation.type === "pen")
overlay.draftAnnotation.points.push({ x: p.x, y: p.y })
annotationLayer.requestPaint()
}
onReleased: {
if (overlay.finishing)
return
if (overlay.selectionDragMode === "pendingNew") {
overlay.selectionDragMode = ""
return
}
if (overlay.selectionDragMode === "new") {
overlay.selectionDragMode = ""
if (overlay.selectionValid) {
overlay.editing = true
}
return
}
if (overlay.selectionDragMode !== "") {
overlay.selectionDragMode = ""
return
}
if (!overlay.draftAnnotation)
return
const dx = Math.abs(overlay.draftAnnotation.x2 - overlay.draftAnnotation.x1)
const dy = Math.abs(overlay.draftAnnotation.y2 - overlay.draftAnnotation.y1)
if (overlay.draftAnnotation.type === "pen" || dx >= 2 || dy >= 2)
overlay.annotations = overlay.annotations.concat([overlay.draftAnnotation])
overlay.draftAnnotation = null
}
onCanceled: {
overlay.selectionDragMode = ""
overlay.draftAnnotation = null
overlay.editing = overlay.selectionValid
}
}
Rectangle {
anchors.horizontalCenter: parent.horizontalCenter
anchors.top: parent.top
anchors.topMargin: 26
width: hintText.implicitWidth + 34
height: 38
radius: 10
color: "#D91B1E26"
z: 10
Text {
id: hintText
anchors.centerIn: parent
text: !overlay.editing
? qsTr("拖动选择截图区域 · Esc 取消")
: overlay.activeTool === "picker"
? qsTr("移动鼠标查看像素颜色,点击应用颜色")
: qsTr("选择工具进行标注 · Ctrl+Z 撤销 · Enter 完成")
color: "white"
font.pixelSize: 12
font.weight: Font.Medium
}
}
Rectangle {
id: pickerBadge
x: Math.max(10, Math.min(overlay.width - width - 10, overlay.pointerX + 18))
y: Math.max(10, Math.min(overlay.height - height - 10, overlay.pointerY + 18))
width: 116
height: 38
radius: 10
color: "#F21D2028"
visible: overlay.editing && overlay.activeTool === "picker"
&& overlay.pointInsideSelection(overlay.pointerX, overlay.pointerY)
z: 18
Row {
anchors.centerIn: parent
spacing: 8
Rectangle { width: 20; height: 20; radius: 5; color: overlay.hoveredPixelColor; border.color: "#80FFFFFF" }
Text { text: overlay.hoveredPixelColor; color: "white"; font.pixelSize: 12; font.family: "monospace" }
}
}
Rectangle {
id: textEditor
x: Math.max(8, Math.min(overlay.width - width - 8,
overlay.selectionX + overlay.textLocalX))
y: Math.max(8, Math.min(overlay.height - height - 8,
overlay.selectionY + overlay.textLocalY))
width: Math.max(140, Math.min(300,
overlay.selectionWidth - overlay.textLocalX))
height: 40
radius: 7
color: "#F21D2028"
border.color: overlay.selectedColor
visible: overlay.textEditing
z: 30
TextInput {
id: textInput
anchors.fill: parent
anchors.leftMargin: 10
anchors.rightMargin: 10
color: overlay.selectedColor
selectionColor: "#5B6EF5"
selectedTextColor: "white"
verticalAlignment: TextInput.AlignVCenter
font.pixelSize: 18
clip: true
Keys.onReturnPressed: event => {
event.accepted = true
overlay.commitText()
}
Keys.onEscapePressed: event => {
event.accepted = true
overlay.textEditing = false
textInput.text = ""
}
}
}
CaptureToolbar {
id: toolbar
x: Math.max(12, Math.min(parent.width - width - 12,
overlay.selectionX + overlay.selectionWidth - width))
y: Math.max(12, overlay.selectionY + overlay.selectionHeight + 10 + height <= parent.height
? overlay.selectionY + overlay.selectionHeight + 10
: overlay.selectionY - height - 10)
visible: overlay.editing && overlay.selectionValid
z: 20
activeTool: overlay.activeTool
selectedColor: overlay.selectedColor
paletteVisible: overlay.colorPaletteVisible
annotationCount: overlay.annotations.length
selectionPixelWidth: Math.round(overlay.selectionWidth * overlay.imageScaleX)
selectionPixelHeight: Math.round(overlay.selectionHeight * overlay.imageScaleY)
activeToolLabel: overlay.toolLabel(overlay.activeTool)
finishing: overlay.finishing
onToolSelected: tool => overlay.selectTool(tool)
onPaletteToggled: overlay.colorPaletteVisible = !overlay.colorPaletteVisible
onUndoRequested: overlay.undo()
onReselectRequested: overlay.resetSelection()
onCancelRequested: overlay.cancel()
onConfirmRequested: overlay.confirm()
}
ColorPalette {
id: colorPalette
x: Math.max(12, Math.min(overlay.width - width - 12, toolbar.x + toolbar.width - width))
y: toolbar.y >= height + 20 ? toolbar.y - height - 8
: toolbar.y + toolbar.height + 8
visible: overlay.colorPaletteVisible && toolbar.visible
z: 25
selectedColor: overlay.selectedColor
onColorSelected: color => {
overlay.selectedColor = color
overlay.colorPaletteVisible = false
}
}
}