-
Notifications
You must be signed in to change notification settings - Fork 1
/
Talk.qml
350 lines (329 loc) · 11.7 KB
/
Talk.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
/*
Copyright (C) 2012 Andrew Baldwin
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
import QtQuick 2.0
FocusScope {
id: show
Behavior on opacity { NumberAnimation { duration: 1000 } }
opacity: 0
Component.onCompleted: {
opacity=1.0;
goToSlide(0,true);
}
property real time: 0.0
Background {
time:show.time
anchors.fill: parent
}
focus: true
onFocusChanged: console.log("show focus",focus)
onActiveFocusChanged: console.log("show active focus",focus)
//property ListView foregroundSlide: view
//property ListView backgroundSlide: view
ShaderEffectSource {
id: oldSlideSource
anchors.fill: parent
visible: false
hideSource: false
live: false
textureSize: Qt.size(parent.width,parent.height)
sourceItem: slides.children[0];
}
ShaderEffectSource {
id: newSlideSource
anchors.fill: parent
visible: false
hideSource: false
live: false
textureSize: Qt.size(parent.width,parent.height)
sourceItem: slides.children[1];
}
SlideTransition2 {
visible: false
anchors.fill: parent
id: transition
oldSlide: oldSlideSource
newSlide: newSlideSource
onVisibleChanged: console.log("trans visible",visible);
//onProgressChanged: console.log("progress",progress);
SequentialAnimation {
id: anim
//ScriptAction { script: time.pause(); }
PropertyAction { target: transition; property: "visible"; value: true }
//PropertyAnimation { target: view; property: "visible"; to: false }
NumberAnimation { target: transition; property: "progress"; from: 0.0; to: 1.0; duration: 1000 }
PropertyAction { target: transition; property: "visible"; value: false }
//PropertyAnimation { target: view; property: "visible"; to: true }
//ScriptAction { script: show.goToSlide(show.currentSlide+1); }
PropertyAction { target: oldSlideSource; property: "hideSource"; value: false }
PropertyAction { target: newSlideSource; property: "hideSource"; value: false }
ScriptAction { script: goToSlide(currentSlide+1,true); }
}
}
function repositionQMark()
{
}
function transitionToNextSlide()
{
if (anim.running&&transition.progress<1.0) return;
if ((currentSlide+1)>=slides.children.length) return;
// Hide the normal view
// Snapshot old slide
oldSlideSource.hideSource = true;
oldSlideSource.sourceItem = slides.children[currentSlide];
//slides.children[currentSlide].visible = true;
//oldSlide.visible = false;
oldSlideSource.scheduleUpdate();
// Move to new slide
//goToSlide(currentSlide+1,false);
// Snapshot new slide
newSlideSource.hideSource = true;
newSlideSource.sourceItem = slides.children[currentSlide+1];
//newSlide.anchors.fill = slides.children[currentSlide+1];
//transition.anchors.fill = slides.children[currentSlide+1];
//slides.children[currentSlide+1].visible = true;
//newSlide.visible = false;
newSlideSource.scheduleUpdate();
//
//transition.visible = true;
//goToSlide(currentSlide+1,true);
anim.restart();
}
Keys.onSpacePressed: { transitionToNextSlide();}
//property ListView tempSlide: view
property int currentSlide: 0
property bool behaviorEnabled: false
Keys.onPressed: {
switch(event.key)
{
case 16777239:
transitionToNextSlide();
break;
case 16777238:
goToSlide(currentSlide-1,false);
break;
}
}
Keys.onEscapePressed: {
if (slides.children[currentSlide].focus)
slides.children[currentSlide].focus = false;
else
Qt.quit();
}
Keys.onLeftPressed: {goToSlide(currentSlide-1,false); }
Keys.onRightPressed: {goToSlide(currentSlide+1,true); }
Keys.onTabPressed: { slides.children[currentSlide].focus = true; }
function goToSlide(target,leftToRight) {
if (target<0) return;
if (target>=slides.children.length) return;
//if (anim.running&&transition.progress<1.0) return;
console.log("go to ",target,slides.children.length);
if (currentSlide!=target) {
slides.children[currentSlide].visible = false;
slides.children[currentSlide].timeRunning = false;
}
slides.children[target].x = show.x;
slides.children[target].y = show.y;
slides.children[target].width = show.width;
slides.children[target].height = show.height;
slides.children[target].visible = true;
slides.children[target].timeRunning = true;
//slides.children[target].focus = true;
//foregroundSlide.positionViewAtIndex(target,ListView.Contain);
currentSlide = target;
//foregroundSlide.currentIndex = target;
}
Image {
id : raspberry
source : "raspgrid.png"
anchors.centerIn : parenti
visible : false;
}
FocusScope {
id: slides
anchors.fill: parent
focus: true
onFocusChanged: console.log("slides focus",focus)
Slide {
Column {
anchors.centerIn: parent
Box {
topColor : "red"
edgeColor: "red"
edgeBlur: 0.25
cornerRadius: 50
Column {
x: parent.cornerRadius/2
y: parent.cornerRadius/2
Title { text: "Qt 5 on Raspberry Pi" }
Body { text: "Jeroen Bouwens"; font.pixelSize: 80 }
Body { text: "With thanks to Andrew Baldwin"; font.pixelSize: 20 }
}
}
}
}
Slide {
Column {
anchors.centerIn: parent
spacing: 20
Title { text: "What is a Raspberry Pi?" }
Body { text: "Small, cheap, ARM11-based computer" }
Body { text: "700 MHz processor, 256 MB memory" }
Body { text: "HDMI, Ethernet, USB, Audio, SD card reader" }
Body { text: "Hardware accelerated graphics: OpenGL ES and Video" }
}
}
Slide{
Image {
source : "myraspi.jpg"
anchors.centerIn: parent
scale : 1.3
}
}
Slide{
Image {
source : "raspi_arduino.jpg"
anchors.centerIn: parent
scale : 1.3
}
}
Slide {
Column {
anchors.centerIn: parent
spacing: 20
Title { text: "What is Qt?" }
Body { text: "Cross-platform C++ toolkit" }
Body { text: "Started as GUI toolkit, evolved into extensive framework" }
Body { text: "More than 20 years development" }
Body { text: "" }
}
}
Slide {
Column {
anchors.centerIn: parent
spacing: 20
Title { text: "QtQuick / QML" }
Body { text: "Declarative language to describe UI" }
Body { text: "Rich UI's, both for desktop and mobile devices" }
Body { text: "Imperative logic with JavaScript" }
Body { text: "Integrate with C++" }
Body { text: "Strong separation between model and presentation" }
}
}
Slide {
Column {
anchors.centerIn: parent
spacing: 20
Title { text: "The big deal with Qt5" }
Body { text: "Introduction of QML 2.0" }
Body { text: "OpenGL-based rendering pipeline: kick-ass performance" }
Body { text: "Shaders as first-class citizens" }
Body { text: "No OpenGL == No Qt5!" }
}
}
Slide {
Column {
anchors.centerIn: parent
spacing: 20
Title { text: "Current Caveats" }
Body { text: "Bleeding edge, so Alpha/Beta status" }
Body { text: "QtCreator does not yet support QML 2" }
Body { text: "Project for standard components not ready" }
Body { text: "" }
}
}
Slide {
Editor {
id : codeEditor
focus: true
editorFocus: parent.focus
initialtext: "import QtQuick 2.0
Rectangle {
\twidth: 200
\theight: 100
\tcolor:\"white\"
}";
anchors.fill: parent
BoxTitle {
anchors.top: parent.top
anchors.topMargin: 10
anchors.right: parent.right
anchors.rightMargin: 10
text:"QML";
}
}
}
Slide {
id : shaderEditor
Editor {
focus: true
editorFocus: parent.focus
initialtext: "import QtQuick 2.0
ShaderEffect {
\tanchors.fill: parent
\tproperty variant tex: raspberry
\tproperty real time: shaderEditor.time*0.001
\tfragmentShader:\"
\tuniform sampler2D tex;
\tuniform lowp float qt_Opacity;
\tvarying highp vec2 qt_TexCoord0;
\tuniform float time;
\tvoid main() {
\t\thighp vec2 c = qt_TexCoord0;
\t\tgl_FragColor =
\t\t\tvec4(0.,0.,0.,0.)
\t\t\t*qt_Opacity;
\t}\"
}";
anchors.fill: parent
BoxTitle {
anchors.top: parent.top
anchors.topMargin: 10
anchors.right: parent.right
anchors.rightMargin: 10
text:"Shaders";
}
}
}
Slide {
Text {
x : parent.width / 2.0
y : parent.height / 2.0
id : qmark
text : "?"
color : "white"
font.family : "Verdana"
font.pixelSize : 200
SequentialAnimation
{
id : reposition
NumberAnimation { target: qmark; property: "opacity"; to: 0.0; duration: 1000; }
ScriptAction { script: {qmark.x = Math.random()*1800; qmark.y = Math.random()*900;} }
NumberAnimation { target: qmark; property: "opacity"; to: 1.0; duration: 1000; }
}
Timer {
interval : 5000; running: true; repeat: true;
onTriggered:
{
reposition.restart();
}
}
}
}
}
}