/
PanelRight.qml
172 lines (137 loc) · 4.4 KB
/
PanelRight.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
// 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.6
import QtMultimedia 5.9
Item {
property var game
onGameChanged: {
videoPreview.stop();
videoPreview.playlist.clear();
videoDelay.restart();
}
// a small delay to avoid loading videos during scrolling
Timer {
id: videoDelay
interval: 250
onTriggered: {
if (game && game.assets.videos.length > 0) {
for (var i = 0; i < game.assets.videos.length; i++)
videoPreview.playlist.addItem(game.assets.videos[i]);
videoPreview.play();
}
}
}
Image {
id: logo
width: parent.width
height: width * 0.35
asynchronous: true
source: (game && game.assets.logo) || ""
sourceSize { width: 512; height: 192 }
fillMode: Image.PreserveAspectFit
// title
Text {
color: "#eee"
text: (game && game.title) || ""
width: parent.width * 0.8
anchors.centerIn: parent
wrapMode: Text.WordWrap
horizontalAlignment: Text.AlignHCenter
font {
bold: true
pixelSize: vpx(30)
capitalization: Font.SmallCaps
family: globalFonts.sans
}
visible: parent.status != Image.Ready && parent.status != Image.Loading
}
}
// year -- developer / publisher -- players
Text {
id: releaseDetails
width: parent.width
wrapMode: Text.WordWrap
horizontalAlignment: Text.AlignHCenter
anchors.top: logo.bottom
topPadding: vpx(16)
bottomPadding: vpx(16)
text: {
var text_tmp = "";
if (!game)
return text_tmp;
if (game.year > 0)
text_tmp += game.year;
if (game.developer) {
if (text_tmp)
text_tmp += " \u2014 ";
text_tmp += game.developer;
if (game.publisher && game.developer !== game.publisher)
text_tmp += " / " + game.publisher;
}
return text_tmp;
}
color: "#eee"
font {
pixelSize: vpx(18)
family: globalFonts.sans
}
visible: text
}
Text {
id: summary
width: parent.width
wrapMode: Text.WordWrap
anchors.top: releaseDetails.bottom
topPadding: vpx(20)
bottomPadding: vpx(40)
text: game ? (game.summary || game.description) : ""
color: "#eee"
font {
pixelSize: vpx(16)
family: globalFonts.sans
}
maximumLineCount: 4
elide: Text.ElideRight
visible: text
}
Rectangle {
id: videoBox
color: "#000"
border { color: "#444"; width: 1 }
anchors.top: summary.bottom
anchors.bottom: parent.bottom
width: parent.width
radius: vpx(4)
visible: (game && (game.assets.videos.length || game.assets.screenshots.length)) || false
Video {
id: videoPreview
visible: playlist.itemCount > 0
anchors { fill: parent; margins: 1 }
fillMode: VideoOutput.PreserveAspectFit
playlist: Playlist {
playbackMode: Playlist.Loop
}
}
Image {
visible: !videoPreview.visible
anchors { fill: parent; margins: 1 }
fillMode: Image.PreserveAspectFit
source: (game && game.assets.screenshots.length && game.assets.screenshots[0]) || ""
sourceSize { width: 512; height: 512 }
asynchronous: true
}
}
}