main.qml
7.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
/* Webcamoid, webcam capture application.
* Copyright (C) 2016 Gonzalo Exequiel Pedone
*
* Webcamoid is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Webcamoid is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Webcamoid. If not, see <http://www.gnu.org/licenses/>.
*
* Web-Site: http://webcamoid.github.io/
*/
import QtQuick
import QtQuick.Controls
import Qt.labs.platform as LABS
import QtQuick.Layouts
import Ak
GridLayout {
id: glyHalftone
columns: 3
readonly property string filePrefix: Ak.platform() == "windows"?
"file:///":
"file://"
function toQrc(uri)
{
if (uri.indexOf(":") == 0)
return "qrc" + uri
return "file:" + uri
}
function strToSize(str)
{
if (str.length < 1)
return Qt.size()
var size = str.split("x")
if (size.length < 2)
return Qt.size()
return Qt.size(size[0], size[1])
}
Connections {
target: Halftone
function onLightningChanged(lightning)
{
sldLightning.value = lightning
spbLightning.value = lightning
}
}
Label {
id: txtPattern
text: qsTr("Pattern")
}
ComboBox {
id: cbxPattern
textRole: "text"
Layout.fillWidth: true
Layout.columnSpan: 2
Accessible.description: txtPattern.text
model: ListModel {
ListElement {
text: qsTr("90° Halftone 6x6")
pattern: ":/Halftone/share/patterns/dither90Halftone6x6Matrix.bmp"
}
ListElement {
text: qsTr("Cluster 3")
pattern: ":/Halftone/share/patterns/ditherCluster3Matrix.bmp"
}
ListElement {
text: qsTr("Cluster 4")
pattern: ":/Halftone/share/patterns/ditherCluster4Matrix.bmp"
}
ListElement {
text: qsTr("Cluster 8")
pattern: ":/Halftone/share/patterns/ditherCluster8Matrix.bmp"
}
ListElement {
text: qsTr("Lines 4x4")
pattern: ":/Halftone/share/patterns/ditherLines4x4Matrix.bmp"
}
ListElement {
text: qsTr("Magic 2x2")
pattern: ":/Halftone/share/patterns/ditherMagic2x2Matrix.bmp"
}
ListElement {
text: qsTr("Magic 4x4")
pattern: ":/Halftone/share/patterns/ditherMagic4x4Matrix.bmp"
}
ListElement {
text: qsTr("Ordered 4x4")
pattern: ":/Halftone/share/patterns/ditherOrdered4x4Matrix.bmp"
}
ListElement {
text: qsTr("Ordered 6x6")
pattern: ":/Halftone/share/patterns/ditherOrdered6x6Matrix.bmp"
}
ListElement {
text: qsTr("Ordered 8x8")
pattern: ":/Halftone/share/patterns/ditherOrdered8x8Matrix.bmp"
}
ListElement {
text: qsTr("Custom")
pattern: ""
}
}
onCurrentIndexChanged: Halftone.pattern = cbxPattern.model.get(currentIndex).pattern
}
ColumnLayout {
Layout.columnSpan: 3
RowLayout {
Image {
width: 16
height: 16
fillMode: Image.PreserveAspectFit
sourceSize.width: 16
sourceSize.height: 16
source: toQrc(txtBitmapPattern.text)
}
TextField {
id: txtBitmapPattern
text: Halftone.pattern
placeholderText: qsTr("Bitmap pattern")
selectByMouse: true
Layout.fillWidth: true
Accessible.name: qsTr("Image to use as pattern")
onTextChanged: {
for (var i = 0; i < cbxPattern.model.count; i++) {
if (cbxPattern.model.get(i).pattern == Halftone.pattern) {
cbxPattern.currentIndex = i
break
}
else if (i == cbxPattern.model.count - 1) {
cbxPattern.model.get(i).pattern = Halftone.pattern
cbxPattern.currentIndex = i
break
}
}
}
}
Button {
text: qsTr("Search")
icon.source: "image://icons/search"
Accessible.description: qsTr("Search the image to use as pattern")
onClicked: fileDialog.open()
}
}
}
Label {
id: txtPatternSize
text: qsTr("Pattern size")
}
TextField {
text: Halftone.patternSize.width + "x" + Halftone.patternSize.height
placeholderText: qsTr("Pattern size")
selectByMouse: true
validator: RegularExpressionValidator {
regularExpression: /-?\d+x-?\d+/
}
Layout.fillWidth: true
Layout.columnSpan: 2
Accessible.name: txtPatternSize.text
onTextChanged: Halftone.patternSize = strToSize(text)
}
Label {
id: txtLightning
text: qsTr("Lightning")
}
Slider {
id: sldLightning
value: Halftone.lightning
stepSize: 0
to: 255
Layout.fillWidth: true
Accessible.name: txtLightning.text
onValueChanged: Halftone.lightning = value
}
SpinBox {
id: spbLightning
value: Halftone.lightning
to: sldLightning.to
stepSize: sldLightning.stepSize
editable: true
Accessible.name: txtLightning.text
onValueChanged: Halftone.lightning = Number(value)
}
Label {
id: txtSlope
text: qsTr("Slope")
}
TextField {
text: Halftone.slope
placeholderText: qsTr("Slope")
selectByMouse: true
validator: RegularExpressionValidator {
regularExpression: /-?(\d+\.\d+|\d+\.|\.\d+|\d+)/
}
Layout.fillWidth: true
Layout.columnSpan: 2
Accessible.name: txtSlope.text
onTextChanged: Halftone.slope = Number(text)
}
Label {
id: txtInterception
text: qsTr("Interception")
}
TextField {
text: Halftone.interception
placeholderText: qsTr("Intercept")
selectByMouse: true
validator: RegularExpressionValidator {
regularExpression: /-?(\d+\.\d+|\d+\.|\.\d+|\d+)/
}
Layout.fillWidth: true
Layout.columnSpan: 2
Accessible.name: txtInterception.text
onTextChanged: Halftone.interception = Number(text)
}
LABS.FileDialog {
id: fileDialog
title: qsTr("Please choose an image file")
nameFilters: ["Image files (*.bmp *.gif *.jpg *.jpeg *.png *.pbm *.pgm *.ppm *.xbm *.xpm)"]
folder: glyHalftone.filePrefix + picturesPath
onAccepted: Halftone.pattern =
String(file).replace(glyHalftone.filePrefix, "")
}
}