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

KDE's Doxygen guidelines are available online.