MauiKit Image Tools

TransformationBar.qml
1import QtQuick
2import QtQuick.Controls
3import QtQuick.Layouts
4
5import org.mauikit.controls as Maui
6
7import org.kde.kquickimageeditor as KQuickImageEditor
8
9ColumnLayout
10{
11 id: control
12
13 spacing: 0
14
15 property alias rotationSlider: _freeRotationSlider
16 property alias rotationButton : _freeRotationButton
17 property alias cropButton : _cropButton
18
19 Maui.ToolBar
20 {
21 position: ToolBar.Footer
22 Layout.fillWidth: true
23 visible: _freeRotationButton.checked
24 background: Rectangle
25 {
26 color: Maui.Theme.backgroundColor
27 }
28 leftContent: [
29 ToolButton
30 {
31 icon.name: "object-flip-vertical"
32 text: i18nc("@action:button Mirror an image vertically", "Flip");
33 autoExclusive: true
34 onClicked: imageDoc.mirror(false, true);
35 },
36
37 ToolButton
38 {
39 icon.name: "object-flip-horizontal"
40 text: i18nc("@action:button Mirror an image horizontally", "Mirror");
41 checkable: true
42 autoExclusive: true
43 onClicked: imageDoc.mirror(true, false);
44 }
45
46 ]
47
48 rightContent: ToolButton
49 {
50 icon.name: "object-rotate-left"
51 // display: ToolButton.IconOnly
52 text: i18nc("@action:button Rotate an image 90°", "Rotate 90°");
53 onClicked:
54 {
55 let value = _freeRotationSlider.value-90
56 _freeRotationSlider.value = value < -180 ? 90 : value
57 }
58 }
59
60 // middleContent: Label
61 // {
62 // text: i18nd("mauikitimagetools","Rotate")
63 // }
64 }
65
66 Maui.ToolBar
67 {
68 id: _freeRotation
69
70 visible: _freeRotationButton.checked
71 position: ToolBar.Footer
72 background: Rectangle
73 {
74 color: Maui.Theme.backgroundColor
75 }
76
77 Layout.fillWidth: true
78
79
80 middleContent: Ruler
81 {
82 id: _freeRotationSlider
83 Layout.fillWidth: true
84 from : -180
85 to: 180
86 value: 0
87 snapMode: Slider.SnapAlways
88 stepSize: 1
89 }
90 }
91
92 Maui.ToolBar
93 {
94 position: ToolBar.Footer
95 Layout.fillWidth: true
96 background: Rectangle
97 {
98 color: Maui.Theme.backgroundColor
99 }
100 middleContent: Maui.ToolActions
101 {
102 autoExclusive: true
103 Layout.alignment: Qt.AlignHCenter
104 Action
105 {
106 id: _cropButton
107 checkable: true
108 icon.name: "transform-crop"
109 text: i18nc("@action:button Crop an image", "Crop");
110 }
111
112 Action
113 {
114 id: _freeRotationButton
115 icon.name: "transform-rotate"
116 checkable: true
117 text: i18nc("@action:button Rotate an image", "Rotate");
118 }
119 }
120
121 leftContent: ToolButton
122 {
123 // text: i18nd("mauikitimagetools","Accept")
124 visible: _freeRotationButton.checked || _cropButton.checked
125
126 icon.name: "checkmark"
127 onClicked:
128 {
129 if(_freeRotationButton.checked)
130 {
131 var value = _freeRotationSlider.value
132 _freeRotationSlider.value = 0
133
134 console.log("Rotate >> " , value)
135 imageDoc.rotate(value);
136 }
137
138 if(_cropButton.checked)
139 {
140 crop()
141 }
142 }
143 }
144
145 rightContent: ToolButton
146 {
147 // text: i18nd("mauikitimagetools","Cancel")
148 visible: _freeRotationButton.checked || _cropButton.checked
149 icon.name: "dialog-cancel"
150 onClicked:
151 {
152 if(_freeRotationButton.checked)
153 {
154 _freeRotationSlider.value = 0
155 _freeRotationButton.checked = false
156
157 }
158
159 if(_cropButton.checked)
160 {
161 _cropButton.checked = false
162 }
163 }
164 }
165 }
166}
167
QString i18nc(const char *context, const char *text, const TYPE &arg...)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Oct 11 2024 12:10:19 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.