main.qml
10.2 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
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
/* 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 QtQuick.Layouts
import Ak
import RippleElement
GridLayout {
columns: 3
function modeIndex(mode)
{
var index = -1
for (var i = 0; i < cbxMode.model.count; i++)
if (cbxMode.model.get(i).mode == mode) {
index = i
break
}
return index
}
Connections {
target: Ripple
function onAmplitudeChanged(amplitude)
{
sldAmplitude.value = amplitude
spbAmplitude.value = amplitude
}
function onDecayChanged(decay)
{
sldDecay.value = decay
spbDecay.value = decay
}
function onThresholdChanged(threshold)
{
sldThreshold.value = threshold
spbThreshold.value = threshold
}
function onLumaThresholdChanged(lumaThreshold)
{
sldLumaThreshold.value = lumaThreshold
spbLumaThreshold.value = lumaThreshold
}
function onMinDropSizeChanged(minDropSize)
{
sldMinDropSize.value = minDropSize
spbMinDropSize.value = minDropSize
}
function onMaxDropSizeChanged(maxDropSize)
{
sldMaxDropSize.value = maxDropSize
spbMaxDropSize.value = maxDropSize
}
function onDropSigmaChanged(dropSigma)
{
sldDropSigma.value = dropSigma
spbDropSigma.value = dropSigma * spbDropSigma.multiplier
}
function onDropProbabilityChanged(dropProbability)
{
sldDropProbability.value = dropProbability
spbDropProbability.value = dropProbability * spbDropProbability.multiplier
}
}
Label {
id: txtMode
text: qsTr("Mode")
}
ComboBox {
id: cbxMode
textRole: "text"
currentIndex: modeIndex(Ripple.mode)
Layout.columnSpan: 2
Layout.fillWidth: true
Accessible.description: txtMode.text
model: ListModel {
ListElement {
text: qsTr("Motion detect")
mode: RippleElement.RippleModeMotionDetect
}
ListElement {
text: qsTr("Rain")
mode: RippleElement.RippleModeRain
}
}
onCurrentIndexChanged: Ripple.mode = cbxMode.model.get(currentIndex).mode
}
Label {
text: qsTr("<b>General parameters</b>")
topPadding: AkUnit.create(16 * AkTheme.controlScale, "dp").pixels
bottomPadding: AkUnit.create(16 * AkTheme.controlScale, "dp").pixels
wrapMode: Text.Wrap
Layout.columnSpan: 3
Layout.fillWidth: true
}
Label {
id: txtAmplitude
text: qsTr("Amplitude")
}
Slider {
id: sldAmplitude
value: Ripple.amplitude
stepSize: 1
to: 1024
Layout.fillWidth: true
Accessible.name: txtAmplitude.text
onValueChanged: Ripple.amplitude = value
}
SpinBox {
id: spbAmplitude
value: Ripple.amplitude
to: sldAmplitude.to
stepSize: sldAmplitude.stepSize
editable: true
Accessible.name: txtAmplitude.text
onValueChanged: Ripple.amplitude = Number(value)
}
Label {
id: txtDecay
text: qsTr("Decay")
}
Slider {
id: sldDecay
value: Ripple.decay
stepSize: 1
to: 8
Layout.fillWidth: true
Accessible.name: txtDecay.text
onValueChanged: Ripple.decay = value
}
SpinBox {
id: spbDecay
value: Ripple.decay
to: sldDecay.to
stepSize: sldDecay.stepSize
editable: true
Accessible.name: txtDecay.text
onValueChanged: Ripple.decay = Number(value)
}
Label {
text: qsTr("<b>Motion detection parameters</b>")
topPadding: AkUnit.create(16 * AkTheme.controlScale, "dp").pixels
bottomPadding: AkUnit.create(16 * AkTheme.controlScale, "dp").pixels
wrapMode: Text.Wrap
Layout.columnSpan: 3
Layout.fillWidth: true
}
Label {
id: txtThreshold
text: qsTr("Threshold")
}
Slider {
id: sldThreshold
value: Ripple.threshold
stepSize: 1
to: 256
Layout.fillWidth: true
Accessible.name: txtThreshold.text
onValueChanged: Ripple.threshold = value
}
SpinBox {
id: spbThreshold
value: Ripple.threshold
to: sldThreshold.to
stepSize: sldThreshold.stepSize
editable: true
Accessible.name: txtThreshold.text
onValueChanged: Ripple.threshold = Number(value)
}
Label {
id: txtLumaThreshold
/*: Minimum luminance/light/white level/intensity in a gray or black and
white picture.
https://en.wikipedia.org/wiki/Luma_(video)
*/
text: qsTr("Luma threshold")
}
Slider {
id: sldLumaThreshold
value: Ripple.lumaThreshold
stepSize: 1
to: 256
Layout.fillWidth: true
Accessible.name: txtLumaThreshold.text
onValueChanged: Ripple.lumaThreshold = value
}
SpinBox {
id: spbLumaThreshold
value: Ripple.lumaThreshold
to: sldLumaThreshold.to
stepSize: sldLumaThreshold.stepSize
editable: true
Accessible.name: txtLumaThreshold.text
onValueChanged: Ripple.lumaThreshold = Number(value)
}
Label {
text: qsTr("<b>Rain parameters</b>")
topPadding: AkUnit.create(16 * AkTheme.controlScale, "dp").pixels
bottomPadding: AkUnit.create(16 * AkTheme.controlScale, "dp").pixels
wrapMode: Text.Wrap
Layout.columnSpan: 3
Layout.fillWidth: true
}
Label {
id: txtMinDropSize
text: qsTr("Minimum drop size")
}
Slider {
id: sldMinDropSize
value: Ripple.minDropSize
stepSize: 1
to: 1024
Layout.fillWidth: true
Accessible.name: txtMinDropSize.text
onValueChanged: Ripple.minDropSize = value
}
SpinBox {
id: spbMinDropSize
value: Ripple.minDropSize
to: sldMinDropSize.to
stepSize: sldMinDropSize.stepSize
editable: true
Accessible.name: txtMinDropSize.text
onValueChanged: Ripple.minDropSize = Number(value)
}
Label {
id: txtMaxDropSize
text: qsTr("Maximum drop size")
}
Slider {
id: sldMaxDropSize
value: Ripple.maxDropSize
stepSize: 1
to: 1024
Layout.fillWidth: true
Accessible.name: txtMaxDropSize.text
onValueChanged: Ripple.maxDropSize = value
}
SpinBox {
id: spbMaxDropSize
value: Ripple.maxDropSize
to: sldMaxDropSize.to
stepSize: sldMaxDropSize.stepSize
editable: true
Accessible.name: txtMaxDropSize.text
onValueChanged: Ripple.maxDropSize = Number(value)
}
Label {
id: lblDropSigma
text: qsTr("Drop thickness")
}
Slider {
id: sldDropSigma
value: Ripple.dropSigma
stepSize: 0.01
from: 0
to: 10
Layout.fillWidth: true
Accessible.name: lblDropSigma.text
onValueChanged: Ripple.dropSigma = value
}
SpinBox {
id: spbDropSigma
value: multiplier * Ripple.dropSigma
from: multiplier * sldDropSigma.from
to: multiplier * sldDropSigma.to
stepSize: multiplier * sldDropSigma.stepSize
editable: true
Accessible.name: lblDropSigma.text
readonly property int decimals: 2
readonly property int multiplier: Math.pow(10, decimals)
validator: DoubleValidator {
bottom: Math.min(spbDropSigma.from, spbDropSigma.to)
top: Math.max(spbDropSigma.from, spbDropSigma.to)
}
textFromValue: function(value, locale) {
return Number(value / multiplier).toLocaleString(locale, 'f', decimals)
}
valueFromText: function(text, locale) {
return Number.fromLocaleString(locale, text) * multiplier
}
onValueModified: Ripple.dropSigma = value / multiplier
}
Label {
id: lblDropProbability
text: qsTr("Drop frequency")
}
Slider {
id: sldDropProbability
value: Ripple.dropProbability
stepSize: 0.01
from: 0
to: 1
Layout.fillWidth: true
Accessible.name: lblDropProbability.text
onValueChanged: Ripple.dropProbability = value
}
SpinBox {
id: spbDropProbability
value: multiplier * Ripple.dropProbability
from: multiplier * sldDropProbability.from
to: multiplier * sldDropProbability.to
stepSize: multiplier * sldDropProbability.stepSize
editable: true
Accessible.name: lblDropProbability.text
readonly property int decimals: 2
readonly property int multiplier: Math.pow(10, decimals)
validator: DoubleValidator {
bottom: Math.min(spbDropProbability.from, spbDropProbability.to)
top: Math.max(spbDropProbability.from, spbDropProbability.to)
}
textFromValue: function(value, locale) {
return Number(value / multiplier).toLocaleString(locale, 'f', decimals)
}
valueFromText: function(text, locale) {
return Number.fromLocaleString(locale, text) * multiplier
}
onValueModified: Ripple.dropProbability = value / multiplier
}
}