-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.qml
192 lines (159 loc) · 4.48 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
import QtQuick 2.6
import QtQuick.Window 2.2
import QtMultimedia 5.7
Window {
id: window
property bool cooldown: false
property bool twoPictures: true
property bool secondPicture: false
property string firstPictureText: "Schritt 1: Rahmen nehmen und bereit machen. \nSchritt 2: Knopf drücken \nSchritt 3: Lächeln!"
property string secondPictureText: "Und gleich nochmal!"
visible: true
title: "Raspberry Pi Photobooth"
minimumWidth: 720
minimumHeight: 480
color: 'black'
Camera {
id: camera
imageCapture.onImageSaved: {
spinner.visible = false;
console.log('Image saved', path);
cloud.uploadPhoto(path);
if(window.twoPictures && !window.secondPicture)
{
trigger(true);
window.secondPicture = true;
}
else
{
window.secondPicture = false;
}
}
}
Item {
id: container
anchors.fill: parent
anchors.margins: 10
Item {
id: tutorial
anchors.left: parent.left
width: parent.width * 0.5
height: parent.height
visible: false
Text {
text: !window.secondPicture ? window.firstPictureText : window.secondPictureText
color: 'white'
font.pixelSize: 25
width: parent.width * 0.6
wrapMode: Text.WordWrap
anchors.centerIn: parent
}
}
VideoOutput {
id: videoOutput
source: camera
focus: visible
orientation: 90
//anchors.left: tutorial.right
//height: container.height
//width: container.width * 0.5
anchors.fill: parent
Rectangle {
id:dummyVideo
anchors.fill: parent
color: Qt.rgba(0,0,0,1)
onColorChanged: console.log(color)
visible: !videoOutput.enabled
Timer {
id: dummyVideoTimer
property double r: 0
property double g: 0
property double b: 0
interval: 50
running: dummyVideo.visible
repeat: true
onTriggered: {
var rand = Math.random() * 1000;
if(rand < 333)
{
r = r + 0.1;
if(r > 1)
r = 0;
}
else if(rand >= 333 && rand < 666)
{
g = g + 0.1;
if(g > 1)
g = 0;
}
else
{
b = b + 0.1;
if(b > 1)
b = 0;
}
dummyVideo.color = Qt.rgba(r,g,b,1);
}
}
}
MouseArea {
anchors.fill: parent
onClicked: trigger(false)
}
}
}
Countdown {
id: countdown
anchors.fill: parent
onFinished: {
spinner.visible = true;
camera.imageCapture.capture();
}
}
Image {
source: "qrc:/power.png"
width: 24
height: 24
opacity: 0.1
MouseArea {
anchors.fill: parent
onClicked: Qt.quit()
}
}
Spinner {
id: spinner
visible: false
}
Timer {
id: cooldownTimer
interval: 5000
onTriggered: {
window.cooldown = false;
}
}
function trigger(again)
{
console.log("Triggered", again);
if(again)
{
window.cooldown = false;
}
if(!window.cooldown && !countdown.running)
{
if(again)
countdown.startWithLength(3);
else
countdown.start();
}
window.cooldown = true;
cooldownTimer.start();
}
Connections {
target: raspberry
onButtonPressedChanged: {
if(raspberry.buttonPressed) {
trigger(false);
}
}
}
}