-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.qml
146 lines (131 loc) · 4.28 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
import QtQuick 2.7
import QtQuick.Controls 2.0
import QtQuick.Layouts 1.0
import QtQuick.Window 2.2
ApplicationWindow {
id: appWindow
objectName: "appWindow"
visible: true
width: 640
height: 480
property int showImageDuration: 5000 // 5 seconds (5000 milliseconds)
property int imageFadeDuration: 2000
property int backgroundTransitionDuration: 3000
property real backgroundOpacity: 0.75
property int blurValue: 99
property int shadowOffset: 4
property string pictureHome: ""
property bool movingForward: true
// visibility: "FullScreen"
function toggleFullScreen() {
// console.log("****VISIBILITY IS:",appWindow.visibility)
if(appWindow.visibility===5)
appWindow.visibility="Windowed"
else
appWindow.visibility="FullScreen"
}
function getImage() {
return myImages.nextImage()
}
function loadNextImage() {
if(movingForward) {
mainWindow.nextImage = myImages.nextImage()
// console.log("Next Image")
}
else {
mainWindow.nextImage = myImages.previousImage()
movingForward = true
// console.log("****LOADING PREVIOUS IMAGE***")
}
}
function imageTimerStart() {
imageTimer.start()
// console.log("starting image timeer")
}
// trying to make a simultaneous cross-fade between old and new backgrounds
function setImageState(imgState) {
if(imgState==="Initialize") {
mainWindow.state = imgState
setImageState("ImageOut")
}
else if(imgState==="ImageOut") {
loadNextImage()
mainWindow.state = imgState
}
else if(imgState==="ImageSwitch") {
mainWindow.state = imgState
mainWindow.currentImage = mainWindow.nextImage
}
else if(imgState==="ImageIn") {
mainWindow.state = imgState
}
else if(imgState==="ImageDisplay") {
mainWindow.oldImage = mainWindow.currentImage
mainWindow.state = imgState
}
else if(imgState==="ImageInterrupt") {
loadNextImage()
mainWindow.state = imgState
// console.log("state is ImageInterrupt")
}
else {
console.log("HELP!! Unknown image state:", imgState)
}
}
function goToImage(direction) {
imageTimer.stop()
if(direction === "next") {
movingForward = true
} else {
movingForward = false
}
console.log("Moving Forward:", movingForward, "timer is running?", imageTimer.running)
appWindow.setImageState("ImageInterrupt")
}
function loadSettingsDialog() {
Qt.createComponent("SettingsDialog.qml").createObject(appWindow,{})
}
function changeSettings(newBlurValue, newDurationValue, newURL) {
// console.log("blur:",newBlurValue,"duration:",newDurationValue,"URL:",newURL)
if(newBlurValue > 0)
blurValue = newBlurValue
if(newDurationValue > 0)
showImageDuration = newDurationValue * 1000
if(newURL!= "") {
pictureHome = newURL
}
}
Timer {
id: imageTimer
interval: showImageDuration
running: false
onTriggered: {
// console.log("imageTimer triggered")
mainWindow.state = "ImageReset"
}
}
MainPage {
id: mainWindow
property string currentImage: appWindow.getImage()
property string nextImage: ""
property string oldImage: ""
property bool isFirstImage: true
anchors.fill: parent
}
MouseArea {
anchors.fill: parent
onDoubleClicked: loadSettingsDialog() //launch settings dialog
onPressAndHold: appWindow.toggleFullScreen()
onClicked: {
console.log("MOUSE CLICK", mouseX)
console.log("Screen width:", parent.width)
if(mouseX < parent.width / 4) { // we clicked on the left so we want to back up
goToImage("previous")
} else if(mouseX > 3*parent.width / 4){
goToImage("next")
}
}
}
Keys.onLeftPressed: goToImage("previous")
Keys.onRightPressed: goToImage("next")
}