Add basic behavior to play, show catalog and more basic feature
This commit is contained in:
1 parent
df847becc8
commit
8e6392a84c
17 files changed
+1455
-34
No files matched your search
@@ -0,0 +1,123 @@
|
||||
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)
|
||||
}
|
||||
}
|
||||
}
|
||||
+105
-15
@@ -3,27 +3,75 @@ import "../Components"
|
||||
import "../Shared"
|
||||
import "../Shared/Remote.js" as Remote
|
||||
|
||||
// Écran d'accueil provisoire : confirme la connexion en attendant la vraie bibliothèque.
|
||||
// Accueil : rangées « Reprendre », « Mes médias » et derniers ajouts de chaque bibliothèque.
|
||||
// Toutes les rangées sont chargées avant affichage, pour ne pas déplacer le focus en cours de route.
|
||||
Page {
|
||||
id: page
|
||||
|
||||
title: page.session && page.session.currentUser
|
||||
? "Bonjour " + page.session.currentUser.name
|
||||
: "Accueil"
|
||||
subtitle: page.session && page.session.currentServer
|
||||
? "Connecté à " + page.session.currentServer.name + "."
|
||||
: ""
|
||||
initialFocus: backButton
|
||||
property var rows: []
|
||||
property bool loading: true
|
||||
property string error: ""
|
||||
|
||||
// La pile a été réinitialisée à la connexion : on reconstruit Serveurs > Utilisateurs
|
||||
// pour revenir au choix de l'utilisateur.
|
||||
fullscreen: true
|
||||
title: page.session && page.session.currentUser ? "Bonjour " + page.session.currentUser.name : "Accueil"
|
||||
subtitle: page.session && page.session.currentServer ? page.session.currentServer.name : ""
|
||||
initialFocus: switchUserButton
|
||||
|
||||
// La pile a été réinitialisée à la connexion : on reconstruit Serveurs > Utilisateurs.
|
||||
function goBack() {
|
||||
page.navigator.reset("ServerSelect");
|
||||
page.navigator.push("UserSelect");
|
||||
}
|
||||
|
||||
// La touche Retour de la télécommande fait la même chose que le bouton
|
||||
// (sinon, à la racine de la pile, elle fermerait l'application).
|
||||
function load() {
|
||||
page.session.loadLibraries(function (err, libraries) {
|
||||
if (err) {
|
||||
page.error = err;
|
||||
page.loading = false;
|
||||
return;
|
||||
}
|
||||
var resume = [];
|
||||
var latest = [];
|
||||
var pending = 1 + libraries.length;
|
||||
function done() {
|
||||
if (--pending === 0)
|
||||
page.build(libraries, resume, latest);
|
||||
}
|
||||
page.session.loadResume(function (e, items) {
|
||||
resume = items;
|
||||
done();
|
||||
});
|
||||
for (var i = 0; i < libraries.length; i++) {
|
||||
(function (index) {
|
||||
page.session.loadLatest(libraries[index].id, function (e, items) {
|
||||
latest[index] = items;
|
||||
done();
|
||||
});
|
||||
})(i);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function build(libraries, resume, latest) {
|
||||
var list = [];
|
||||
if (resume.length > 0)
|
||||
list.push({ title: "Reprendre", items: resume, landscape: true });
|
||||
if (libraries.length > 0)
|
||||
list.push({ title: "Mes médias", items: libraries, landscape: true });
|
||||
for (var i = 0; i < libraries.length; i++) {
|
||||
if (latest[i] && latest[i].length > 0)
|
||||
list.push({ title: "Ajouts récents · " + libraries[i].name, items: latest[i], landscape: false });
|
||||
}
|
||||
rows = list;
|
||||
loading = false;
|
||||
if (list.length > 0)
|
||||
rowsList.forceActiveFocus();
|
||||
}
|
||||
|
||||
Component.onCompleted: load()
|
||||
Component.onDestruction: if (page.session) page.session.cancel()
|
||||
|
||||
// Retour : choix de l'utilisateur (sinon, à la racine de la pile, l'app se fermerait).
|
||||
Keys.onPressed: {
|
||||
if (Remote.isBack(event.key)) {
|
||||
event.accepted = true;
|
||||
@@ -32,23 +80,65 @@ Page {
|
||||
}
|
||||
|
||||
Row {
|
||||
id: actions
|
||||
spacing: Theme.spacingM
|
||||
|
||||
FocusButton {
|
||||
id: backButton
|
||||
text: "Retour"
|
||||
id: switchUserButton
|
||||
text: "Changer d'utilisateur"
|
||||
KeyNavigation.right: logoutButton
|
||||
KeyNavigation.down: rowsList
|
||||
onClicked: page.goBack()
|
||||
}
|
||||
|
||||
FocusButton {
|
||||
id: logoutButton
|
||||
text: "Se déconnecter"
|
||||
KeyNavigation.left: backButton
|
||||
KeyNavigation.left: switchUserButton
|
||||
KeyNavigation.down: rowsList
|
||||
onClicked: {
|
||||
page.session.logout();
|
||||
page.goBack();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ListView {
|
||||
id: rowsList
|
||||
anchors {
|
||||
top: actions.bottom
|
||||
topMargin: Theme.spacingL
|
||||
left: parent.left
|
||||
right: parent.right
|
||||
bottom: parent.bottom
|
||||
}
|
||||
clip: true
|
||||
spacing: Theme.spacingS
|
||||
model: page.rows
|
||||
|
||||
delegate: MediaRow {
|
||||
width: rowsList.width
|
||||
title: modelData.title
|
||||
items: modelData.items
|
||||
landscape: modelData.landscape
|
||||
session: page.session
|
||||
onActivated: page.navigator.openItem(item)
|
||||
}
|
||||
|
||||
// La rangée courante reste en haut de la zone visible.
|
||||
onCurrentIndexChanged: positionViewAtIndex(currentIndex, ListView.Beginning)
|
||||
|
||||
KeyNavigation.priority: KeyNavigation.AfterItem
|
||||
KeyNavigation.up: switchUserButton
|
||||
}
|
||||
|
||||
Text {
|
||||
anchors.centerIn: rowsList
|
||||
visible: text !== ""
|
||||
text: page.loading ? "Chargement…"
|
||||
: page.error !== "" ? page.error
|
||||
: page.rows.length === 0 ? "Aucun média disponible pour ce compte." : ""
|
||||
color: page.error !== "" ? Theme.error : Theme.textMuted
|
||||
font.pixelSize: Theme.fontBody
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,91 @@
|
||||
import QtQuick 2.5
|
||||
import "../Components"
|
||||
import "../Shared"
|
||||
import "../Shared/Remote.js" as Remote
|
||||
import "../Shared/Format.js" as Format
|
||||
|
||||
// Contenu d'une bibliothèque en grille d'affiches, chargé par pages à mesure qu'on descend.
|
||||
Page {
|
||||
id: page
|
||||
|
||||
property var library: null // { id, name, collectionType }
|
||||
property int total: 0
|
||||
property bool loading: false
|
||||
property string error: ""
|
||||
|
||||
readonly property int pageSize: 60
|
||||
|
||||
fullscreen: true
|
||||
title: library ? library.name : ""
|
||||
subtitle: total > 0 ? total + " élément" + (total > 1 ? "s" : "") : ""
|
||||
initialFocus: grid
|
||||
|
||||
function loadMore() {
|
||||
if (loading || (total > 0 && itemsModel.count >= total))
|
||||
return;
|
||||
loading = true;
|
||||
page.session.loadLibraryItems(library, itemsModel.count, pageSize, function (err, items, count) {
|
||||
page.loading = false;
|
||||
if (err) {
|
||||
page.error = err;
|
||||
return;
|
||||
}
|
||||
page.total = count;
|
||||
for (var i = 0; i < items.length; i++)
|
||||
itemsModel.append(items[i]);
|
||||
});
|
||||
}
|
||||
|
||||
Component.onCompleted: loadMore()
|
||||
Component.onDestruction: if (page.session) page.session.cancel()
|
||||
|
||||
ListModel {
|
||||
id: itemsModel
|
||||
}
|
||||
|
||||
GridView {
|
||||
id: grid
|
||||
anchors.fill: parent
|
||||
clip: true
|
||||
focus: true
|
||||
// Marges pour la carte agrandie (scale).
|
||||
leftMargin: 8
|
||||
topMargin: 8
|
||||
cellWidth: Theme.posterWidth + Theme.spacingL
|
||||
cellHeight: Theme.posterHeight + Theme.cardTextHeight + Theme.spacingL
|
||||
model: itemsModel
|
||||
|
||||
delegate: MediaCard {
|
||||
width: Theme.posterWidth
|
||||
title: model.name
|
||||
subtitle: Format.cardSubtitle(model)
|
||||
imageSource: page.session ? page.session.posterUrl(model) : ""
|
||||
progress: Format.progress(model)
|
||||
played: model.played
|
||||
highlighted: GridView.isCurrentItem && grid.activeFocus
|
||||
onClicked: {
|
||||
grid.currentIndex = index;
|
||||
page.navigator.openItem(itemsModel.get(index));
|
||||
}
|
||||
}
|
||||
|
||||
// Page suivante quand on approche de la fin.
|
||||
onCurrentIndexChanged: if (currentIndex >= count - 14) page.loadMore()
|
||||
|
||||
Keys.onPressed: {
|
||||
if (Remote.isAccept(event.key) && currentIndex >= 0) {
|
||||
event.accepted = true;
|
||||
page.navigator.openItem(itemsModel.get(currentIndex));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Text {
|
||||
anchors.centerIn: parent
|
||||
visible: text !== ""
|
||||
text: page.error !== "" ? page.error
|
||||
: itemsModel.count === 0 ? (page.loading ? "Chargement…" : "Cette bibliothèque est vide.") : ""
|
||||
color: page.error !== "" ? Theme.error : Theme.textMuted
|
||||
font.pixelSize: Theme.fontBody
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,244 @@
|
||||
import QtQuick 2.5
|
||||
import "../Components"
|
||||
import "../Shared"
|
||||
import "../Shared/Remote.js" as Remote
|
||||
import "../Shared/Format.js" as Format
|
||||
|
||||
// Lecteur plein écran.
|
||||
// Télécommande : OK = lecture/pause, Gauche/Droite = -10 s/+30 s, Haut/Bas = afficher les
|
||||
// informations, Retour = quitter (géré par le Navigator).
|
||||
// La progression est signalée au serveur (reprise, « vu ») au démarrage, toutes les 10 s et à l'arrêt.
|
||||
FocusScope {
|
||||
id: player
|
||||
|
||||
// Injectés par le Navigator
|
||||
property var navigator: null
|
||||
property var session: null
|
||||
property Item initialFocus: null
|
||||
property bool fullscreen: true
|
||||
|
||||
// Paramètres de push("Player", …)
|
||||
property string itemId: ""
|
||||
property string title: ""
|
||||
property real startMs: 0
|
||||
|
||||
property var info: null // résultat de Session.preparePlayback()
|
||||
property bool started: false // lecture effectivement démarrée et signalée
|
||||
property bool resumed: false
|
||||
// Reprise atteinte (ou lecture depuis le début) : avant ça, on ne signale rien, pour
|
||||
// ne pas écraser le point de reprise si le déplacement initial échoue.
|
||||
property bool resumeReached: startMs <= 0
|
||||
property bool finished: false
|
||||
property string error: ""
|
||||
|
||||
function showOsd() {
|
||||
osd.shown = true;
|
||||
osdTimer.restart();
|
||||
}
|
||||
|
||||
function seekBy(deltaMs) {
|
||||
if (video.duration <= 0)
|
||||
return;
|
||||
video.seek(video.position + deltaMs);
|
||||
showOsd();
|
||||
}
|
||||
|
||||
// Rien n'est signalé tant que la lecture n'a pas réellement démarré : un arrêt
|
||||
// signalé à la position 0 effacerait le point de reprise sur le serveur.
|
||||
function report(event) {
|
||||
if (!player.info || !player.started)
|
||||
return;
|
||||
if (event !== "start" && video.position <= 0)
|
||||
return;
|
||||
player.session.reportPlayback(event, player.info, video.position, video.playerState === "paused");
|
||||
}
|
||||
|
||||
// Signale le démarrage une fois la lecture lancée ET la position de reprise atteinte.
|
||||
function maybeReportStart() {
|
||||
if (player.started || !player.info || video.playerState !== "playing" || !player.resumeReached)
|
||||
return;
|
||||
player.started = true;
|
||||
player.report("start");
|
||||
}
|
||||
|
||||
function finish() {
|
||||
if (finished)
|
||||
return;
|
||||
finished = true;
|
||||
report("stop");
|
||||
player.navigator.pop();
|
||||
}
|
||||
|
||||
Component.onCompleted: {
|
||||
showOsd();
|
||||
player.session.preparePlayback(itemId, function (err, playback) {
|
||||
if (err) {
|
||||
player.error = err;
|
||||
return;
|
||||
}
|
||||
player.info = playback;
|
||||
video.source = playback.url;
|
||||
});
|
||||
}
|
||||
|
||||
// Retour (le Navigator dépile) ou fin : on signale l'arrêt au serveur.
|
||||
Component.onDestruction: {
|
||||
if (!finished) {
|
||||
finished = true;
|
||||
report("stop");
|
||||
}
|
||||
}
|
||||
|
||||
Keys.onPressed: {
|
||||
var key = event.key;
|
||||
if (Remote.isAccept(key) || key === Qt.Key_Space || key === Qt.Key_MediaTogglePlayPause
|
||||
|| key === Qt.Key_MediaPlay || key === Qt.Key_MediaPause) {
|
||||
video.togglePause();
|
||||
showOsd();
|
||||
} else if (key === Qt.Key_Left || key === Qt.Key_AudioRewind) {
|
||||
seekBy(-10000);
|
||||
} else if (key === Qt.Key_Right || key === Qt.Key_AudioForward) {
|
||||
seekBy(30000);
|
||||
} else if (key === Qt.Key_Up || key === Qt.Key_Down) {
|
||||
showOsd();
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
event.accepted = true;
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
anchors.fill: parent
|
||||
color: "black"
|
||||
}
|
||||
|
||||
VideoSurface {
|
||||
id: video
|
||||
anchors.fill: parent
|
||||
|
||||
onPlayerStateChanged: {
|
||||
player.maybeReportStart();
|
||||
if (playerState === "paused")
|
||||
player.showOsd();
|
||||
}
|
||||
// Reprise : déplacement une fois la durée connue.
|
||||
onDurationChanged: {
|
||||
if (!player.resumed && player.startMs > 0 && duration > 0) {
|
||||
player.resumed = true;
|
||||
seek(player.startMs);
|
||||
}
|
||||
}
|
||||
onPositionChanged: {
|
||||
if (!player.resumeReached && position >= player.startMs - 15000) {
|
||||
player.resumeReached = true;
|
||||
player.maybeReportStart();
|
||||
}
|
||||
}
|
||||
onEnded: player.finish()
|
||||
}
|
||||
|
||||
Timer {
|
||||
interval: 10000
|
||||
repeat: true
|
||||
running: player.started && !player.finished
|
||||
onTriggered: player.report("progress")
|
||||
}
|
||||
|
||||
// Messages au centre : chargement / erreur.
|
||||
Text {
|
||||
anchors.centerIn: parent
|
||||
width: parent.width * 0.7
|
||||
horizontalAlignment: Text.AlignHCenter
|
||||
wrapMode: Text.WordWrap
|
||||
visible: text !== ""
|
||||
text: player.error !== "" ? player.error + "\nAppuyez sur Retour pour quitter."
|
||||
: video.playerState === "error" ? video.errorString + "\nAppuyez sur Retour pour quitter."
|
||||
: video.playerState === "loading" || video.playerState === "idle" ? "Chargement…" : ""
|
||||
color: player.error !== "" || video.playerState === "error" ? Theme.error : Theme.text
|
||||
font.pixelSize: Theme.fontBody
|
||||
style: Text.Outline
|
||||
styleColor: "black"
|
||||
}
|
||||
|
||||
// Informations de lecture (masquées après 4 s, sauf en pause).
|
||||
Item {
|
||||
id: osd
|
||||
|
||||
property bool shown: true
|
||||
|
||||
anchors.fill: parent
|
||||
opacity: shown || video.playerState === "paused" ? 1 : 0
|
||||
|
||||
Behavior on opacity { NumberAnimation { duration: 200 } }
|
||||
|
||||
Rectangle {
|
||||
anchors { left: parent.left; right: parent.right; bottom: parent.bottom }
|
||||
height: 170
|
||||
gradient: Gradient {
|
||||
GradientStop { position: 0; color: "transparent" }
|
||||
GradientStop { position: 1; color: "#E0000000" }
|
||||
}
|
||||
}
|
||||
|
||||
Column {
|
||||
anchors {
|
||||
left: parent.left
|
||||
right: parent.right
|
||||
bottom: parent.bottom
|
||||
margins: Theme.pageMargin
|
||||
}
|
||||
spacing: Theme.spacingS
|
||||
|
||||
Text {
|
||||
width: parent.width
|
||||
text: player.title
|
||||
elide: Text.ElideRight
|
||||
color: Theme.text
|
||||
font.pixelSize: Theme.fontTitle - 6
|
||||
font.bold: true
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
width: parent.width
|
||||
height: 6
|
||||
radius: 3
|
||||
color: "#55FFFFFF"
|
||||
|
||||
Rectangle {
|
||||
width: video.duration > 0 ? parent.width * Math.min(1, video.position / video.duration) : 0
|
||||
height: parent.height
|
||||
radius: 3
|
||||
color: Theme.accent
|
||||
}
|
||||
}
|
||||
|
||||
Item {
|
||||
width: parent.width
|
||||
height: stateText.implicitHeight
|
||||
|
||||
Text {
|
||||
id: stateText
|
||||
text: video.playerState === "paused" ? "Pause"
|
||||
: video.playerState === "playing" ? "Lecture"
|
||||
: video.playerState === "loading" ? "Chargement…" : ""
|
||||
color: Theme.text
|
||||
font.pixelSize: Theme.fontSmall
|
||||
font.bold: true
|
||||
}
|
||||
|
||||
Text {
|
||||
anchors.right: parent.right
|
||||
text: Format.clock(video.position) + " / " + Format.clock(video.duration)
|
||||
color: Theme.text
|
||||
font.pixelSize: Theme.fontSmall
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Timer {
|
||||
id: osdTimer
|
||||
interval: 4000
|
||||
onTriggered: osd.shown = false
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,134 @@
|
||||
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
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user