-
Notifications
You must be signed in to change notification settings - Fork 1
/
Main.qml
767 lines (720 loc) · 23.7 KB
/
Main.qml
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
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
import QtQuick
import QtQuick.Window
import QtQuick.Controls
import QtQuick.Layouts
import Qt.labs.qmlmodels
import org.tal
ApplicationWindow {
id: root
width: 800
height: 480
minimumHeight: 480
minimumWidth: 800
visible: true
color: "grey"
title: qsTr("CutePocketRemote")
property bool smallInterface: height>500 ? false : true
property int smallFontSize: smallInterface ? 16 : 24
property bool relativeFocus: menuFocusRelative.checked
CameraDiscovery {
id: disocvery
onDiscoveryStart: {
cameraStatus.text='Connecting...'
cameraDrawer.open()
}
onDiscoveryStop: (devices) => {
if (devices==0) {
cameraStatus.text="No cameras found!"
cameraDrawer.close()
return;
}
cameraStatus.text="Found "+devices
var d=getDevices();
deviceList.model=d;
}
}
ListModel {
id: deviceModel
}
Drawer {
id: cameraDrawer
height: parent.height
width: parent.width/2
interactive: false
modal: true
closePolicy: Popup.NoAutoClose
ColumnLayout {
anchors.fill: parent
anchors.margins: 8
Text {
id: deviceCount
text: "Cameras: "+disocvery.count
}
ListView {
id: deviceList
enabled: !disocvery.discovering
Layout.fillHeight: true
Layout.fillWidth: true
delegate: ItemDelegate {
text: modelData.name+" ("+modelData.address+")"
font.italic: modelData.rssi==0 ? true : false
enabled: modelData.rssi!=0
onClicked: {
var device=disocvery.getBluetoothDevice(modelData.address);
console.debug(device)
deviceList.currentIndex=index;
cd.connectDevice(device)
cameraDrawer.close()
}
}
}
RowLayout {
Button {
enabled: !disocvery.discovering
text: "Refresh"
onClicked: disocvery.startDeviceDiscovery()
}
Button {
enabled: !disocvery.discovering
text: "Close"
onClicked: {
cameraDrawer.close()
}
}
}
}
ProgressBar {
id: discoveringProgress
anchors.centerIn: parent
indeterminate: visible
visible: disocvery.discovering
}
}
CameraDevice {
id: cd
onStatusChanged: {
console.debug("CameraStatus is now: "+status)
switch (status) {
case 1:
cameraStatus.text="Connected"
break;
case 3:
cameraStatus.text="Ready"
break;
}
}
onAutoFocusTriggered: {
console.debug("Autofocusing...")
setTimedMessage('AutoFocus');
}
onIsoChanged: {
console.debug("ISO is:"+iso)
comboISO.currentIndex=comboISO.indexOfValue(iso)
}
onShutterSpeedChanged: {
console.debug("shutterSpeed is:"+shutterSpeed)
comboShutter.currentIndex=comboShutter.indexOfValue(shutterSpeed)
}
onApertureChanged: {
console.debug("Aperture is: "+cd.aperture)
let tmp=cd.aperture.toFixed(1);
console.log(tmp)
comboAperture.currentIndex=comboAperture.indexOfValue(tmp)
}
onWbChanged: {
console.debug("WB is:"+wb)
comboWB.currentIndex=comboWB.indexOfValue(wb)
}
onTintChanged: {
spinTint.value=tint
}
onConnectionFailure: {
cameraStatus.text="Failed to connect"
}
property bool connectionReady: cd.connected && cd.status==3
}
Action {
id: quitAction
shortcut: StandardKey.Quit
onTriggered: Qt.quit()
}
menuBar: MenuBar {
id: mainMenu
visible: !smallInterface
Menu {
title: "File"
MenuItem {
text: "Slate"
enabled: cd.connectionReady
onClicked: slateDrawer.open()
}
MenuItem {
text: "Quit"
onClicked: Qt.quit()
}
}
Menu {
title: "Device"
MenuItem {
text: "Find"
enabled: !cd.connected
onClicked: disocvery.startDeviceDiscovery()
}
MenuItem {
text: "&Disconnect"
enabled: cd.connected
onClicked: cd.disconnectFromDevice()
}
}
Menu {
title: "Lens control"
MenuItem {
id: menuFocusRelative
text: "Relative Focus"
checkable: true
checked: true
ButtonGroup.group: focusGroup
}
MenuItem {
id: menuFocusAbsolute
text: "Absolute Focus"
checkable: true
ButtonGroup.group: focusGroup
}
MenuSeparator {
}
MenuItem {
id: menuZoomEnabled
text: "Show zoom"
checkable: true
checked: false
}
}
}
ButtonGroup {
id: focusGroup
onClicked: (button) => {
}
}
header: ToolBar {
RowLayout {
ToolButton {
text: "Find"
enabled: !cd.connected
onClicked: disocvery.startDeviceDiscovery()
}
ToolButton {
text: "&Disconnect"
enabled: cd.connected
onClicked: cd.disconnectFromDevice()
}
ToolButton {
text: "Play"
enabled: cd.connectionReady && !cd.recording && !cd.playing
onClicked: cd.play(true);
icon.name: "play"
}
/*
ToolButton {
text: "CCR"
enabled: cd.connectionReady
onClicked: cd.colorCorrectionReset()
}
*/
ToolButton {
text: "Slate"
enabled: cd.connectionReady
onClicked: slateDrawer.open()
}
}
}
Timer {
id: timerMessageTimer
interval: 2000
triggeredOnStart: false
repeat: false
onTriggered: timedMessage.text=''
}
function setTimedMessage(msg) {
timedMessage.text=msg;
timerMessageTimer.start()
}
footer: ToolBar {
RowLayout {
anchors.fill: parent
Label {
id: cameraStatus
text: ''
font.pixelSize: smallFontSize
Layout.alignment: Qt.AlignLeft
}
Label {
id: cameraName
text: cd.connected ? cd.name : 'N/A'
font.pixelSize: smallFontSize
Layout.alignment: Qt.AlignLeft
}
Label {
id: timedMessage
text: ''
font.pixelSize: smallFontSize
Layout.alignment: Qt.AlignLeft
}
Label {
id: zoom
text: cd.connectionReady ? cd.zoom : '--'
font.pixelSize: smallFontSize
}
Label {
text: cd.connectionReady ? cd.iso : '---'
font.pixelSize: smallFontSize
}
Label {
text: cd.connectionReady ? '1/'+cd.shutterSpeed : '-/--'
font.pixelSize: smallFontSize
}
Label {
id: aperture
text: cd.connectionReady ? 'f'+cd.aperture.toFixed(1) : '--'
font.pixelSize: smallFontSize
}
Label {
text: cd.connectionReady ? cd.wb+"K" : '--'
font.pixelSize: smallFontSize
}
Label {
text: cd.connectionReady ? cd.tint : '--'
font.pixelSize: smallFontSize
}
Label {
text: cd.connectionReady ? 'Take: '+cd.metaTakeNumber : ''
}
TimeCodeText {
id: timeCodeText
Layout.preferredWidth: 12*24
camera: cd
Layout.alignment: Qt.AlignRight
font.pixelSize: smallFontSize
}
}
}
StackView {
anchors.fill: parent
focus: true
Keys.enabled: true
Keys.onPressed: {
switch (event.key) {
case Qt.Key_F2:
if (!cd.connected)
disocvery.startDeviceDiscovery()
event.accepted=true;
break;
}
}
ColumnLayout {
anchors.fill: parent
anchors.margins: 4
spacing: 4
enabled: cd.connectionReady
RowLayout {
id: bc
Layout.fillWidth: true
Layout.fillHeight: true
Layout.margins: 0
Layout.alignment: Qt.AlignTop
spacing: 4
ColumnLayout {
id: buttonsContainer
Layout.alignment: Qt.AlignTop
Layout.fillWidth: true
Layout.fillHeight: true
Layout.minimumWidth: 100
Layout.maximumWidth: 200
Layout.minimumHeight: 100
Layout.maximumHeight: 300
Button {
Layout.fillWidth: true
Layout.fillHeight: true
text: "Record"
icon.name: "media-record"
enabled: !cd.recording
highlighted: cd.recording
onClicked: cd.record(true)
}
Button {
Layout.fillWidth: true
Layout.fillHeight: true
text: "Stop"
icon.name: "media-playback-stop"
enabled: cd.recording || cd.playing
onClicked: {
cd.record(false) // false=stop
}
}
Button {
Layout.fillWidth: true
Layout.fillHeight: true
text: "Capture"
icon.name: "camera-photo"
enabled: cd.connectionReady && !cd.recording && !cd.playing
onClicked: cd.captureStill()
}
}
TimeCodeText {
id: timeCodeText2
Layout.fillWidth: true
Layout.fillHeight: true
Layout.margins: 4
Layout.preferredWidth: 12*32
Layout.minimumWidth: 12*18 // contentWidth
Layout.alignment: Qt.AlignHCenter | Qt.AlignTop
height: buttonsContainer.height
minimumPixelSize: 18
font.pixelSize: 92
font.weight: Font.Bold
horizontalAlignment: Text.AlignHCenter
fontSizeMode:Text.HorizontalFit
color: cd.recording ? "red" : "white"
style: Text.Outline
styleColor: "black"
camera: cd
onClicked: {
cd.setDisplay(!cd.timecodeDisplay)
}
}
ColumnLayout {
RelativeFocus {
cd: cd
visible: relativeFocus
Layout.fillWidth: true
Layout.alignment: Qt.AlignTop
}
AbsoluteFocus {
cd: cd
visible: !relativeFocus
Layout.fillWidth: true
Layout.alignment: Qt.AlignTop
}
Label {
text: cd.metaLensDistance
}
Label {
text: cd.metaLensFocal
}
}
ColumnLayout {
Zoom {
cd: cd
visible: menuZoomEnabled.checked
Layout.fillWidth: true
Layout.alignment: Qt.AlignTop
}
}
}
Label {
text: "Shutter speed: "+ cd.shutterSpeed
visible: !smallInterface
}
RowLayout {
Layout.fillWidth: true
ComboBox {
id: comboShutter
model: [24,25,30,50,60,100,120,125,160,200,250,500,1000,2000]
onActivated: {
cd.setShutterSpeed(currentValue)
}
}
Slider {
id: shutterSpeedSlider
Layout.fillWidth: true
from: 24
to: 5000
value: 60
stepSize: 1
live: false
wheelEnabled: true
onValueChanged: {
cd.setShutterSpeed(value)
}
}
}
Label {
text: "Aperture"
visible: !smallInterface
}
RowLayout {
Layout.fillWidth: true
ComboBox {
id: comboAperture
model: [ '2.8', '2.9', '3.1',
'4.0', '4.2', '4.4', '4.6', '4.8',
'5.0', '5.2', '5.4', '5.6', '5.9', '6.2', '6.4', '6.7',
'7.0', '8.0', '10.0', '11.0', '12.0',
'13.0', '14.0', '15.0', '16.0', '17.0', '18.0', '19.0', '20.0', '21.0', '22.0' ]
displayText: "f/"+currentText
onActivated: {
cd.setAperture(currentValue)
}
}
Slider {
id: apertureSlider
Layout.fillWidth: true
from: 0
to: 1
value: 0
stepSize: 0.05
live: false
wheelEnabled: true
onValueChanged: {
cd.setApertureNormalized(value)
}
}
Button {
Layout.fillWidth: false
text: "f/4.0"
onClicked: cd.setAperture('4.0')
}
Button {
Layout.fillWidth: false
text: "f/5.6"
onClicked: cd.setAperture('5.6')
}
Button {
Layout.fillWidth: false
text: "f/6.2"
onClicked: cd.setAperture('6.2')
}
Button {
Layout.fillWidth: false
text: "f/8.0"
onClicked: cd.setAperture('8.0')
}
Button {
id: autoApertureButton
Layout.fillWidth: false
text: "Auto\nAperture"
onClicked: cd.autoAperture()
}
}
Label {
text: "ISO: "+cd.iso
visible: !smallInterface
}
RowLayout {
Layout.fillWidth: true
ComboBox {
id: comboISO
model: [100,125,160,200,250,320,400,500,640,800,1000,1250,1600,2000,2500,3200,4000,5000,6400,8000,10000,12800,16000,20000,25600]
displayText: "ISO "+currentText
onActivated: {
cd.setISO(currentValue)
}
}
Label {
text: "Gain: "+gain.value
}
Slider {
id: gain
Layout.fillWidth: true
from: -10
to: 10
value: 0
stepSize: 1
live: false
wheelEnabled: true
onValueChanged: {
cd.setGain(value)
}
}
Button {
Layout.fillWidth: true
text: "400"
onClicked: {
cd.setISO(400)
}
}
Button {
Layout.fillWidth: true
text: "600"
onClicked: {
cd.setISO(600)
}
}
Button {
Layout.fillWidth: true
text: "800"
onClicked: {
cd.setISO(800)
}
}
Button {
Layout.fillWidth: true
text: "3200"
onClicked: {
cd.setISO(3200)
}
}
}
Label {
text: "White Balance: "+cd.wb+'K/'+cd.tint
visible: !smallInterface
}
RowLayout {
spacing: 4
ColumnLayout {
ComboBox {
id: comboWB
model: [3200,3600,4000,4600,5600,6500,7500]
displayText: currentText+"K"
onActivated: {
cd.whiteBalance(currentValue, spinTint.value)
}
}
SpinBox {
id: spinTint
Layout.fillWidth: true
from: -50
to: 50
value: cd.connectionReady ? cd.tint : 0
wheelEnabled: true
onValueModified: {
cd.whiteBalance(sliderWb.value, value)
}
}
}
ColumnLayout {
Layout.fillWidth: true
Slider {
Layout.fillWidth: true
id: sliderWb
from: 2500
to: 10000
value: cd.connectionReady ? cd.wb : 4600
stepSize: 50
live: false
snapMode: Slider.SnapAlways
wheelEnabled: true
property bool userMoved: false
onMoved: userMoved=true
onValueChanged: {
if (pressed || userMoved)
cd.whiteBalance(value, spinTint.value)
userMoved=false
}
}
}
ColumnLayout {
Button {
Layout.fillWidth: true
text: "Auto"
onClicked: cd.autoWhitebalance();
}
Button {
Layout.fillWidth: true
text: "Restore"
onClicked: cd.restoreAutoWhiteBalance()
}
}
GridLayout {
rows: 2
columns: 3
Button {
Layout.fillWidth: true
text: "Sun"
onClicked: {
cd.whiteBalance(5600, 10)
}
}
Button {
Layout.fillWidth: true
text: "Light 1"
onClicked: {
cd.whiteBalance(3200, 0)
}
}
Button {
Layout.fillWidth: true
text: "Light 2"
onClicked: {
cd.whiteBalance(4000, 15)
}
}
Button {
Layout.fillWidth: true
text: "Shade"
onClicked: {
cd.whiteBalance(4500, 15)
}
}
Button {
Layout.fillWidth: true
text: "Cloudy"
onClicked: {
cd.whiteBalance(6500, 10)
}
}
Button {
Layout.fillWidth: true
text: "4600K"
onClicked: {
cd.whiteBalance(4600, 0)
}
}
}
}
}
}
TableModel {
id: metadataModel
TableModelColumn { display: "metadata" }
TableModelColumn { display: "value" }
rows: [
{
metadata: "Camera ID",
value: cd.metaCameraID
},
{
metadata: "Camera operator",
value: cd.metaCameraOperator
},
{
metadata: "Director",
value: cd.metaDirector
},
{
metadata: "Project name",
value: cd.metaProjectName
},
{
metadata: "Lens type",
value: cd.metaLensType
},
{
metadata: "Lens iris",
value: cd.metaLensIris
},
{
metadata: "Lens focal",
value: cd.metaLensFocal
},
{
metadata: "Lens distance",
value: cd.metaLensDistance
},
]
}
Drawer {
id: slateDrawer
width: parent.width/1.5
height: parent.height
TableView {
anchors.fill: parent
columnSpacing: 2
rowSpacing: 1
model: metadataModel
delegate: ItemDelegate {
text: model.display
}
}
}
}