blob: b985880227834fae22a7eb88203805c530d689fb (
plain)
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
|
import QtQuick 2.0
Item {
id: root
property variant slides: []
property int currentSlide;
property bool faded: false
Component.onCompleted: {
var slideCount = 0;
var slides = [];
for (var i=0; i<root.resources.length; ++i) {
var r = root.resources[i];
if (r.isSlide) {
slides.push(r);
}
}
root.slides = slides;
// Make first slide visible...
if (root.slides.length > 0) {
root.currentSlide = 0;
root.slides[root.currentSlide].visible = true;
}
}
function switchSlides(from, to) {
from.visible = false
to.visible = true
return true
}
function goToNextSlide() {
if (faded)
return
if (root.currentSlide + 1 < root.slides.length) {
var from = slides[currentSlide]
var to = slides[currentSlide + 1]
if (switchSlides(from, to))
currentSlide = currentSlide + 1;
}
}
function goToPreviousSlide() {
if (root.faded)
return
if (root.currentSlide - 1 >= 0) {
var from = slides[currentSlide]
var to = slides[currentSlide - 1]
if (switchSlides(from, to))
currentSlide = currentSlide - 1;
}
}
focus: true
Keys.onSpacePressed: goToNextSlide();
Keys.onRightPressed: goToNextSlide();
Keys.onLeftPressed: goToPreviousSlide();
Keys.onEscapePressed: root.faded = !root.faded;
Rectangle {
z: 1000
color: "black"
anchors.fill: parent
opacity: root.faded ? 1 : 0
Behavior on opacity { NumberAnimation { duration: 250 } }
}
MouseArea {
id: mouseArea
anchors.fill: parent
onClicked: goToNextSlide()
}
}
|