-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBackgroundImage.qml
136 lines (117 loc) · 3.23 KB
/
BackgroundImage.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
import QtQuick 2.8
import QtGraphicalEffects 1.12
Item {
id: root
property var gameData//: currentCollection.games.get(gameList.currentIndex)
property var collectionView
property var detailView
property real dimopacity: 0.666
property string bgSource: gameData ? gameData.assets.background || gameData.assets.screenshots[0] || 'assets/backgrounds/blank.png' : 'assets/backgrounds/blank.png'
property string bgImage1
property string bgImage2
property bool firstBG: true
onBgSourceChanged: {
if ( detailView ) {
swapImage(bgSource);
}
}
onCollectionViewChanged: {
if ( collectionView ) {
bgImage1: 'assets/backgrounds/blank.png'
bgImage2: 'assets/backgrounds/blank.png'
} else {
swapImage(bgSource);
}
}
Item {
id: bg
anchors.fill: parent
states: [
State { // this will fade in rect2 and fade out rect
name: "fadeInRect2"
PropertyChanges { target: rect; opacity: 0}
PropertyChanges { target: rect2; opacity: 1}
},
State { // this will fade in rect and fade out rect2
name:"fadeOutRect2"
PropertyChanges { target: rect;opacity:1}
PropertyChanges { target: rect2;opacity:0}
}
]
transitions: [
Transition {
NumberAnimation { property: "opacity"; easing.type: Easing.InOutQuad; duration: 1000 }
}
]
Image {
id: rect2Img
anchors.fill: parent
visible: false //gameData
asynchronous: true
source: bgImage1
sourceSize { width: 1920; height: 1080 }
fillMode: Image.PreserveAspectCrop
smooth: false
}
Image {
id: rectImg
anchors.fill: parent
visible: false //gameData
asynchronous: true
source: bgImage2
sourceSize { width: 1920; height: 1080 }
fillMode: Image.PreserveAspectCrop
smooth: false
}
FastBlur {
id: rect
anchors.fill: rectImg
source: rectImg
radius: vpx(20)
}
FastBlur {
id: rect2
anchors.fill: rect2Img
source: rect2Img
radius: vpx(20)
}
state: "fadeInRect2"
}
function swapImage(newSource) {
if (firstBG) {
// Go to second image
if (newSource)
bgImage2 = newSource
firstBG = false
} else {
// Go to first image
if (newSource)
bgImage1 = newSource
firstBG = true
}
bg.state = bg.state == "fadeInRect2" ? "fadeOutRect2" : "fadeInRect2"
}
LinearGradient {
z: parent.z + 1
width: parent.width
height: parent.height
anchors {
top: parent.top; topMargin: vpx(200)
right: parent.right
bottom: parent.bottom
}
start: Qt.point(0, 0)
end: Qt.point(0, height)
gradient: Gradient {
GradientStop { position: 0.1; color: "#00000000" }
GradientStop { position: 0.7; color: "#ff000000" }
}
}
Rectangle {
id: backgrounddim
anchors.fill: parent
color: "#15181e"
opacity: dimopacity
Behavior on opacity { NumberAnimation { duration: 2000 } }
}
}