-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGameVideoItem.qml
159 lines (141 loc) · 4.19 KB
/
GameVideoItem.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
// Pegasus Frontend
// Copyright (C) 2017-2018 Mátyás Mustoha
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
import QtQuick 2.8
import QtMultimedia 5.9
import QtGraphicalEffects 1.12
Item {
property var game
property var collectionView
property var detailView
property var collectionShortName
property bool steam: false
onGameChanged: {
if ( detailView ) {
videoPreviewLoader.sourceComponent = undefined;
unfadescreenshot.restart();
videoDelay.restart();
} else {
videoPreviewLoader.sourceComponent = undefined;
}
}
onCollectionViewChanged: {
if ( collectionView ) {
videoPreviewLoader.sourceComponent = undefined;
unfadescreenshot.restart();
videoDelay.stop();
} else {
videoPreviewLoader.sourceComponent = undefined;
videoDelay.restart();
}
if (collectionShortName == "steam") {
steam = true
} else {
steam = false
}
}
// a small delay to avoid loading videos during scrolling
Timer {
id: videoDelay
interval: 666
onTriggered: {
if (game.assets.videos.length) {
videoPreviewLoader.sourceComponent = videoPreviewWrapper;
fadescreenshot.restart();
}
}
}
Timer {
id: fadescreenshot
interval: 1000
onTriggered: {
screenshot.opacity = 0;
}
}
Timer {
id: unfadescreenshot
interval: 10
onTriggered: {
screenshot.opacity = 100;
}
}
// Actual art
Image {
id: screenshot
width: root.Width
height: root.Height
z: 3
anchors {
fill: parent
margins: vpx(4)
}
asynchronous: true
visible: game.assets.screenshots[0] || game.assets.boxFront || false
smooth: true
source: (steam) ? game.assets.logo : game.assets.screenshots[0] || ""
sourceSize { width: 256; height: 256 }
fillMode: Image.PreserveAspectCrop
property bool rounded: true
property bool adapt: true
Behavior on opacity { PropertyAnimation { duration: 1000; easing.type: Easing.OutQuart; easing.amplitude: 2.0; } }
layer.enabled: rounded
layer.effect: OpacityMask {
maskSource: Item {
width: screenshot.width
height: screenshot.height
Rectangle {
anchors.centerIn: parent
width: screenshot.width
height: screenshot.height
radius: vpx(10)
}
}
}
}
// Video preview
Component {
id: videoPreviewWrapper
Video {
source: game.assets.videos.length ? game.assets.videos[0] : ""
anchors.fill: parent
fillMode: VideoOutput.PreserveAspectCrop
//muted: true
volume: 0.3
loops: MediaPlayer.Infinite
autoPlay: true
}
}
Loader {
id: videoPreviewLoader
asynchronous: true
anchors {
fill: parent
margins: vpx(4)
}
layer.enabled: true
layer.effect: OpacityMask {
maskSource: Item {
width: videoPreviewLoader.width
height: videoPreviewLoader.height
Rectangle {
anchors.centerIn: parent
width: videoPreviewLoader.width
height: videoPreviewLoader.height
radius: vpx(10)
}
}
}
}
}