5import org.mauikit.controls as Maui
7import org.kde.kquickimageeditor as KQuickImageEditor
9import "../private" as Private
23 readonly
property bool ready : String(control.url).length
25 readonly
property alias editor : imageDoc
27 headBar.visible: control.ready
29 headBar.leftContent: ToolButton
31 icon.name:
"edit-undo"
32 enabled: imageDoc.edited
33 onClicked: imageDoc.undo()
36 headBar.middleContent:
Maui.ToolActions
39 Layout.alignment:
Qt.AlignHCenter
41 property int currentIndex : 1
42 expanded: control.width >
Maui.Style.units.gridUnit * 30
43 display: ToolButton.TextBesideIcon
47 text:
i18nd(
"mauikitimagetools",
"Color")
48 checked: _editTools.currentIndex === 0
49 onTriggered: _editTools.currentIndex = 0
54 text:
i18nd(
"mauikitimagetools",
"Transform")
55 checked: _editTools.currentIndex === 1
56 onTriggered: _editTools.currentIndex = 1
61 text:
i18nd(
"mauikitimagetools",
"Layer")
62 checked: _editTools.currentIndex === 2
63 onTriggered: _editTools.currentIndex = 2
67 KQuickImageEditor.ImageItem
70 readonly
property real ratioX: editImage.paintedWidth / editImage.nativeWidth;
71 readonly
property real ratioY: editImage.paintedHeight / editImage.nativeHeight;
73 fillMode: KQuickImageEditor.ImageItem.PreserveAspectFit
76 anchors.margins:
Maui.Style.space.medium
78 rotation: _transBar.rotationSlider.value
80 KQuickImageEditor.ImageDocument
86 KQuickImageEditor.SelectionTool
89 visible: _transBar.cropButton.checked
90 width: editImage.paintedWidth
91 height: editImage.paintedHeight
92 x: editImage.horizontalPadding
93 y: editImage.verticalPadding
95 KQuickImageEditor.CropBackground
99 insideX: selectionTool.selectionX
100 insideY: selectionTool.selectionY
101 insideWidth: selectionTool.selectionWidth
102 insideHeight: selectionTool.selectionHeight
105 target: selectionTool.selectionArea
106 function onDoubleClicked() {
114 selectionTool.selectionX = 0
115 selectionTool.selectionY = 0
116 selectionTool.selectionWidth =
Qt.binding(() => selectionTool.width)
117 selectionTool.selectionHeight =
Qt.binding(() => selectionTool.height)
123 visible: _transBar.rotationButton.checked
125 anchors.fill : parent
126 property int wgrid: control.width / 20
128 var ctx = getContext(
"2d")
130 ctx.strokeStyle =
Maui.Theme.textColor
132 var nrows = height/wgrid;
133 for(var i=0; i < nrows+1; i++){
134 ctx.moveTo(0, wgrid*i);
135 ctx.lineTo(width, wgrid*i);
138 var ncols = width/wgrid
139 for(var j=0; j < ncols+1; j++){
140 ctx.moveTo(wgrid*j, 0);
141 ctx.lineTo(wgrid*j, height);
149 footBar.visible:
false
152 Private.TransformationBar
155 visible: _editTools.currentIndex === 1 && control.ready
162 visible: _editTools.currentIndex === 0 && control.ready
170 imageDoc.crop(selectionTool.selectionX / editImage.ratioX,
171 selectionTool.selectionY / editImage.ratioY,
172 selectionTool.selectionWidth / editImage.ratioX,
173 selectionTool.selectionHeight / editImage.ratioY);
QString i18nd(const char *domain, const char *text, const TYPE &arg...)
QString & fill(QChar ch, qsizetype size)