124 lines
3.9 KiB
QML
124 lines
3.9 KiB
QML
import QtQuick 2.5
|
||
import "../Components"
|
||
import "../Shared"
|
||
import "../Shared/Format.js" as Format
|
||
|
||
// Fiche d'un film, d'un épisode ou d'une série (saisons).
|
||
Page {
|
||
id: page
|
||
|
||
property string itemId: ""
|
||
property var item: null
|
||
property var seasons: []
|
||
property string error: ""
|
||
|
||
readonly property bool isSeries: item !== null && item.type === "Series"
|
||
readonly property real resumeMs: item ? Format.ticksToMs(item.positionTicks) : 0
|
||
|
||
fullscreen: true
|
||
title: item ? item.name : ""
|
||
subtitle: item ? (item.type === "Episode" && item.seriesName ? item.seriesName + " · " : "")
|
||
+ Format.infoLine(item) : ""
|
||
backdrop: item && page.session ? page.session.backdropUrl(item, 720) : ""
|
||
initialFocus: playButton
|
||
|
||
function play(startMs) {
|
||
var label = item.type === "Episode"
|
||
? item.seriesName + " · " + Format.episodeCode(item) + " – " + item.name : item.name;
|
||
page.navigator.push("Player", { itemId: item.id, title: label, startMs: startMs });
|
||
}
|
||
|
||
Component.onCompleted: {
|
||
page.session.loadItem(itemId, function (err, loaded) {
|
||
if (err) {
|
||
page.error = err;
|
||
return;
|
||
}
|
||
page.item = loaded;
|
||
if (loaded.type === "Series") {
|
||
page.session.loadSeasons(loaded.id, function (e, list) {
|
||
page.seasons = list;
|
||
seasonsRow.forceActiveFocus();
|
||
});
|
||
} else {
|
||
playButton.forceActiveFocus();
|
||
}
|
||
});
|
||
}
|
||
|
||
Component.onDestruction: if (page.session) page.session.cancel()
|
||
|
||
Rectangle {
|
||
id: poster
|
||
width: 200
|
||
height: 300
|
||
radius: Theme.radius
|
||
color: Theme.surface
|
||
|
||
Image {
|
||
anchors.fill: parent
|
||
// Épisode : affiche de la série (l'image de l'épisode est en 16:9).
|
||
source: !page.item || !page.session ? ""
|
||
: page.item.type === "Episode" && page.item.seriesPrimaryTag
|
||
? page.session.imageUrl(page.item.seriesId, "Primary", page.item.seriesPrimaryTag, 450)
|
||
: page.session.posterUrl(page.item, 450)
|
||
fillMode: Image.PreserveAspectCrop
|
||
asynchronous: true
|
||
sourceSize.height: 300
|
||
}
|
||
}
|
||
|
||
Column {
|
||
anchors {
|
||
left: poster.right
|
||
leftMargin: Theme.spacingXL
|
||
right: parent.right
|
||
top: parent.top
|
||
}
|
||
spacing: Theme.spacingL
|
||
|
||
Text {
|
||
width: parent.width
|
||
visible: text !== ""
|
||
text: page.error !== "" ? page.error : page.item ? page.item.overview : "Chargement…"
|
||
color: page.error !== "" ? Theme.error : Theme.text
|
||
font.pixelSize: Theme.fontBody
|
||
wrapMode: Text.WordWrap
|
||
maximumLineCount: page.isSeries ? 4 : 8
|
||
elide: Text.ElideRight
|
||
lineHeight: 1.15
|
||
}
|
||
|
||
Row {
|
||
spacing: Theme.spacingM
|
||
visible: page.item !== null && !page.isSeries
|
||
|
||
FocusButton {
|
||
id: playButton
|
||
primary: true
|
||
text: page.resumeMs > 0 ? "Reprendre à " + Format.clock(page.resumeMs) : "Lire"
|
||
KeyNavigation.right: restartButton.visible ? restartButton : null
|
||
onClicked: page.play(page.resumeMs)
|
||
}
|
||
|
||
FocusButton {
|
||
id: restartButton
|
||
visible: page.resumeMs > 0
|
||
text: "Lire depuis le début"
|
||
KeyNavigation.left: playButton
|
||
onClicked: page.play(0)
|
||
}
|
||
}
|
||
|
||
MediaRow {
|
||
id: seasonsRow
|
||
width: parent.width
|
||
visible: page.seasons.length > 0
|
||
title: "Saisons"
|
||
items: page.seasons
|
||
session: page.session
|
||
onActivated: page.navigator.openItem(item)
|
||
}
|
||
}
|
||
}
|