5import org.mauikit.controls 1.2 as Maui
7import org.kde.kquickimageeditor 1.0 as KQuickImageEditor
8import Qt5Compat.GraphicalEffects
10import "private" as Private
24 readonly
property bool ready : String(control.url).length
26 readonly
property alias editor : imageDoc
28 headBar.visible: control.ready
30 headBar.leftContent: ToolButton
32 icon.name:
"edit-undo"
33 enabled: imageDoc.edited
34 onClicked: imageDoc.undo()
37 headBar.middleContent:
Maui.ToolActions
40 Layout.alignment:
Qt.AlignHCenter
42 property int currentIndex : 1
43 expanded: control.width >
Maui.Style.units.gridUnit * 30
44 display: ToolButton.TextBesideIcon
48 text:
i18nd(
"mauikitimagetools",
"Color")
49 checked: _editTools.currentIndex === 0
50 onTriggered: _editTools.currentIndex = 0
55 text:
i18nd(
"mauikitimagetools",
"Transform")
56 checked: _editTools.currentIndex === 1
57 onTriggered: _editTools.currentIndex = 1
62 text:
i18nd(
"mauikitimagetools",
"Layer")
63 checked: _editTools.currentIndex === 2
64 onTriggered: _editTools.currentIndex = 2
68 KQuickImageEditor.ImageItem
71 readonly
property real ratioX: editImage.paintedWidth / editImage.nativeWidth;
72 readonly
property real ratioY: editImage.paintedHeight / editImage.nativeHeight;
74 fillMode: KQuickImageEditor.ImageItem.PreserveAspectFit
77 anchors.margins:
Maui.Style.space.medium
79 rotation: _transBar.rotationSlider.value
81 KQuickImageEditor.ImageDocument
87 KQuickImageEditor.SelectionTool
90 visible: _transBar.cropButton.checked
91 width: editImage.paintedWidth
92 height: editImage.paintedHeight
93 x: editImage.horizontalPadding
94 y: editImage.verticalPadding
96 KQuickImageEditor.CropBackground
100 insideX: selectionTool.selectionX
101 insideY: selectionTool.selectionY
102 insideWidth: selectionTool.selectionWidth
103 insideHeight: selectionTool.selectionHeight
106 target: selectionTool.selectionArea
107 function onDoubleClicked() {
115 selectionTool.selectionX = 0
116 selectionTool.selectionY = 0
117 selectionTool.selectionWidth =
Qt.binding(() => selectionTool.width)
118 selectionTool.selectionHeight =
Qt.binding(() => selectionTool.height)
124 visible: _transBar.rotationButton.checked
126 anchors.fill : parent
127 property int wgrid: control.width / 20
129 var ctx = getContext(
"2d")
131 ctx.strokeStyle =
Maui.Theme.textColor
133 var nrows = height/wgrid;
134 for(var i=0; i < nrows+1; i++){
135 ctx.moveTo(0, wgrid*i);
136 ctx.lineTo(width, wgrid*i);
139 var ncols = width/wgrid
140 for(var j=0; j < ncols+1; j++){
141 ctx.moveTo(wgrid*j, 0);
142 ctx.lineTo(wgrid*j, height);
150 footBar.visible:
false
153 Private.TransformationBar
156 visible: _editTools.currentIndex === 1 && control.ready
163 visible: _editTools.currentIndex === 0 && control.ready
171 imageDoc.crop(selectionTool.selectionX / editImage.ratioX,
172 selectionTool.selectionY / editImage.ratioY,
173 selectionTool.selectionWidth / editImage.ratioX,
174 selectionTool.selectionHeight / editImage.ratioY);
QString i18nd(const char *domain, const char *text, const TYPE &arg...)
QString & fill(QChar ch, qsizetype size)