MauiKit Image Tools

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

KDE's Doxygen guidelines are available online.