Files
Jellyfin-Freebox/Views/SeasonView.qml
T

135 lines
4.1 KiB
QML

import QtQuick 2.5
import "../Components"
import "../Shared"
import "../Shared/Remote.js" as Remote
import "../Shared/Format.js" as Format
// Épisodes d'une saison ; OK ouvre la fiche de l'épisode.
Page {
id: page
property string seriesId: ""
property string seasonId: ""
property string seasonName: ""
property string seriesName: ""
property var episodes: []
property bool loading: true
property string error: ""
fullscreen: true
title: seriesName
subtitle: seasonName
initialFocus: list
Component.onCompleted: {
page.session.loadEpisodes(seriesId, seasonId, function (err, items) {
page.loading = false;
if (err) {
page.error = err;
return;
}
page.episodes = items;
list.forceActiveFocus();
});
}
Component.onDestruction: if (page.session) page.session.cancel()
ListView {
id: list
anchors.fill: parent
clip: true
focus: true
spacing: Theme.spacingS
model: page.episodes
delegate: Rectangle {
id: row
readonly property bool highlighted: ListView.isCurrentItem && list.activeFocus
width: list.width
height: 150
radius: Theme.radius
color: highlighted ? Theme.focusBackground : "transparent"
MediaCard {
id: thumb
anchors { left: parent.left; leftMargin: Theme.spacingS; verticalCenter: parent.verticalCenter }
width: 240
height: 135
imageHeight: 135
showText: false
imageSource: page.session ? page.session.thumbUrl(modelData) : ""
progress: Format.progress(modelData)
played: modelData.played
title: modelData.name
}
Column {
anchors {
left: thumb.right
leftMargin: Theme.spacingL
right: parent.right
rightMargin: Theme.spacingM
verticalCenter: parent.verticalCenter
}
spacing: 4
Text {
width: parent.width
text: modelData.name
elide: Text.ElideRight
color: row.highlighted ? Theme.textOnFocus : Theme.text
font.pixelSize: Theme.fontBody
font.bold: true
}
Text {
width: parent.width
visible: text !== ""
text: "Épisode " + modelData.indexNumber
+ (modelData.runtimeTicks ? " · " + Format.runtime(modelData.runtimeTicks) : "")
color: row.highlighted ? Theme.textOnFocusMuted : Theme.textMuted
font.pixelSize: Theme.fontSmall
}
Text {
width: parent.width
text: modelData.overview
wrapMode: Text.WordWrap
maximumLineCount: 3
elide: Text.ElideRight
color: row.highlighted ? Theme.textOnFocusMuted : Theme.textMuted
font.pixelSize: Theme.fontSmall
}
}
MouseArea {
anchors.fill: parent
onClicked: {
list.currentIndex = index;
page.navigator.openItem(modelData);
}
}
}
Keys.onPressed: {
if (Remote.isAccept(event.key) && currentIndex >= 0) {
event.accepted = true;
page.navigator.openItem(page.episodes[currentIndex]);
}
}
}
Text {
anchors.centerIn: parent
visible: text !== ""
text: page.loading ? "Chargement…"
: page.error !== "" ? page.error
: page.episodes.length === 0 ? "Aucun épisode." : ""
color: page.error !== "" ? Theme.error : Theme.textMuted
font.pixelSize: Theme.fontBody
}
}