Refactoring: move all apps inside a sub folder
This commit is contained in:
1 parent
33e4fe0c4e
commit
b1ca2a7cff
41 files changed
+54
-45
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)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,144 @@
|
||||
import QtQuick 2.5
|
||||
import "../Components"
|
||||
import "../Shared"
|
||||
import "../Shared/Remote.js" as Remote
|
||||
|
||||
// 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
|
||||
|
||||
property var rows: []
|
||||
property bool loading: true
|
||||
property string error: ""
|
||||
|
||||
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");
|
||||
}
|
||||
|
||||
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;
|
||||
page.goBack();
|
||||
}
|
||||
}
|
||||
|
||||
Row {
|
||||
id: actions
|
||||
spacing: Theme.spacingM
|
||||
|
||||
FocusButton {
|
||||
id: switchUserButton
|
||||
text: "Changer d'utilisateur"
|
||||
KeyNavigation.right: logoutButton
|
||||
KeyNavigation.down: rowsList
|
||||
onClicked: page.goBack()
|
||||
}
|
||||
|
||||
FocusButton {
|
||||
id: logoutButton
|
||||
text: "Se déconnecter"
|
||||
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,166 @@
|
||||
import QtQuick 2.5
|
||||
import "../Components"
|
||||
import "../Shared"
|
||||
|
||||
// Écran 4 : connexion par mot de passe ou par Quick Connect.
|
||||
Page {
|
||||
id: page
|
||||
|
||||
property string username: ""
|
||||
property bool quickConnect: false
|
||||
property bool quickConnectAvailable: false
|
||||
property string quickConnectCode: ""
|
||||
property bool busy: false
|
||||
property string error: ""
|
||||
|
||||
title: quickConnect ? "Quick Connect" : "Se connecter"
|
||||
subtitle: page.session && page.session.currentServer
|
||||
? "Serveur : " + page.session.currentServer.name
|
||||
: ""
|
||||
initialFocus: username !== "" ? passwordField : usernameField
|
||||
|
||||
function signIn() {
|
||||
if (busy)
|
||||
return;
|
||||
error = "";
|
||||
busy = true;
|
||||
page.session.authenticate(usernameField.text, passwordField.text, function (err) {
|
||||
page.busy = false;
|
||||
if (err) {
|
||||
page.error = err;
|
||||
(usernameField.text.trim() === "" ? usernameField : passwordField).forceActiveFocus();
|
||||
return;
|
||||
}
|
||||
// Réinitialise la pile : Retour ne doit pas revenir à l'écran de connexion.
|
||||
page.navigator.reset("Home");
|
||||
});
|
||||
}
|
||||
|
||||
function setQuickConnect(enabled) {
|
||||
error = "";
|
||||
quickConnect = enabled;
|
||||
if (enabled) {
|
||||
quickConnectCode = "";
|
||||
passwordModeButton.forceActiveFocus();
|
||||
page.session.startQuickConnect(function (err, code) {
|
||||
if (err) {
|
||||
page.error = err;
|
||||
return;
|
||||
}
|
||||
page.quickConnectCode = code;
|
||||
}, function (err) {
|
||||
if (err) {
|
||||
page.error = err;
|
||||
return;
|
||||
}
|
||||
page.navigator.reset("Home");
|
||||
});
|
||||
} else {
|
||||
page.session.stopQuickConnect();
|
||||
page.initialFocus.forceActiveFocus();
|
||||
}
|
||||
}
|
||||
|
||||
// Le bouton Quick Connect n'est proposé que si le serveur l'autorise.
|
||||
Component.onCompleted: {
|
||||
page.session.isQuickConnectEnabled(function (err, enabled) {
|
||||
page.quickConnectAvailable = enabled;
|
||||
});
|
||||
}
|
||||
|
||||
Component.onDestruction: if (page.session) page.session.cancel()
|
||||
|
||||
Column {
|
||||
id: passwordForm
|
||||
visible: !page.quickConnect
|
||||
width: Math.min(parent.width, 560)
|
||||
spacing: Theme.spacingL
|
||||
|
||||
TextField {
|
||||
id: usernameField
|
||||
width: parent.width
|
||||
label: "Nom d'utilisateur"
|
||||
text: page.username
|
||||
KeyNavigation.down: passwordField
|
||||
onAccepted: passwordField.forceActiveFocus()
|
||||
}
|
||||
|
||||
TextField {
|
||||
id: passwordField
|
||||
width: parent.width
|
||||
label: "Mot de passe"
|
||||
password: true
|
||||
KeyNavigation.up: usernameField
|
||||
KeyNavigation.down: signInButton
|
||||
onAccepted: page.signIn()
|
||||
}
|
||||
|
||||
Text {
|
||||
width: parent.width
|
||||
visible: text !== ""
|
||||
text: page.error
|
||||
color: Theme.error
|
||||
font.pixelSize: Theme.fontBody
|
||||
wrapMode: Text.WordWrap
|
||||
}
|
||||
|
||||
Row {
|
||||
spacing: Theme.spacingM
|
||||
|
||||
FocusButton {
|
||||
id: signInButton
|
||||
primary: true
|
||||
text: page.busy ? "Connexion…" : "Se connecter"
|
||||
KeyNavigation.up: passwordField
|
||||
KeyNavigation.right: page.quickConnectAvailable ? quickConnectButton : null
|
||||
onClicked: page.signIn()
|
||||
}
|
||||
|
||||
FocusButton {
|
||||
id: quickConnectButton
|
||||
visible: page.quickConnectAvailable
|
||||
text: "Utiliser Quick Connect"
|
||||
KeyNavigation.up: passwordField
|
||||
KeyNavigation.left: signInButton
|
||||
onClicked: page.setQuickConnect(true)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Column {
|
||||
id: quickConnectPanel
|
||||
visible: page.quickConnect
|
||||
width: Math.min(parent.width, 560)
|
||||
spacing: Theme.spacingL
|
||||
|
||||
Text {
|
||||
width: parent.width
|
||||
text: "Depuis un appareil déjà connecté, ouvrez Quick Connect dans les paramètres de votre compte Jellyfin et saisissez ce code :"
|
||||
color: Theme.textMuted
|
||||
font.pixelSize: Theme.fontBody
|
||||
wrapMode: Text.WordWrap
|
||||
}
|
||||
|
||||
Text {
|
||||
text: page.quickConnectCode !== "" ? page.quickConnectCode : "…"
|
||||
color: Theme.accent
|
||||
font.pixelSize: Theme.fontCode
|
||||
font.bold: true
|
||||
font.letterSpacing: 8
|
||||
}
|
||||
|
||||
Text {
|
||||
width: parent.width
|
||||
text: page.error !== "" ? page.error : "En attente d'autorisation…"
|
||||
color: page.error !== "" ? Theme.error : Theme.textMuted
|
||||
wrapMode: Text.WordWrap
|
||||
font.pixelSize: Theme.fontSmall
|
||||
}
|
||||
|
||||
FocusButton {
|
||||
id: passwordModeButton
|
||||
text: "Utiliser un mot de passe"
|
||||
onClicked: page.setQuickConnect(false)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
import QtQuick 2.5
|
||||
import "../Components"
|
||||
import "../Shared"
|
||||
|
||||
// Écran 2 : saisie manuelle de l'adresse d'un serveur.
|
||||
// Le clavier virtuel de la box n'a ni « : » ni « / » : on saisit l'hôte seul, le port
|
||||
// à part (facultatif), et Session détecte le protocole (https/http) et le port.
|
||||
Page {
|
||||
id: page
|
||||
|
||||
property bool busy: false
|
||||
property string error: ""
|
||||
|
||||
title: "Ajouter un serveur"
|
||||
subtitle: "Saisissez l'adresse IP ou le nom de domaine de votre serveur Jellyfin. Le protocole et le port sont détectés automatiquement."
|
||||
initialFocus: addressField
|
||||
|
||||
function connect() {
|
||||
if (busy)
|
||||
return;
|
||||
error = "";
|
||||
busy = true;
|
||||
page.session.connectToServer(addressField.text, portField.text, function (err) {
|
||||
page.busy = false;
|
||||
if (err) {
|
||||
page.error = err;
|
||||
var port = portField.text.trim();
|
||||
(port !== "" && !page.session.isValidPort(port) ? portField : addressField).forceActiveFocus();
|
||||
return;
|
||||
}
|
||||
// Remplace cet écran : Retour depuis la liste des utilisateurs ramène aux serveurs.
|
||||
page.navigator.replace("UserSelect");
|
||||
});
|
||||
}
|
||||
|
||||
Component.onDestruction: if (page.session) page.session.cancel()
|
||||
|
||||
Column {
|
||||
width: Math.min(parent.width, 560)
|
||||
spacing: Theme.spacingL
|
||||
|
||||
TextField {
|
||||
id: addressField
|
||||
width: parent.width
|
||||
label: "Adresse du serveur"
|
||||
placeholder: "192.168.1.20 ou jellyfin.example.com"
|
||||
inputMethodHints: Qt.ImhUrlCharactersOnly | Qt.ImhNoAutoUppercase | Qt.ImhNoPredictiveText
|
||||
KeyNavigation.down: portField
|
||||
onAccepted: portField.forceActiveFocus()
|
||||
}
|
||||
|
||||
TextField {
|
||||
id: portField
|
||||
width: 200
|
||||
label: "Port (facultatif)"
|
||||
placeholder: "Auto"
|
||||
inputMethodHints: Qt.ImhDigitsOnly
|
||||
validator: RegExpValidator { regExp: /\d{0,5}/ }
|
||||
maximumLength: 5
|
||||
KeyNavigation.up: addressField
|
||||
KeyNavigation.down: connectButton
|
||||
onAccepted: page.connect()
|
||||
}
|
||||
|
||||
Text {
|
||||
width: parent.width
|
||||
visible: text !== ""
|
||||
text: page.error
|
||||
color: Theme.error
|
||||
font.pixelSize: Theme.fontBody
|
||||
wrapMode: Text.WordWrap
|
||||
}
|
||||
|
||||
FocusButton {
|
||||
id: connectButton
|
||||
primary: true
|
||||
text: page.busy ? "Recherche du serveur…" : "Se connecter"
|
||||
KeyNavigation.up: portField
|
||||
onClicked: page.connect()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
import QtQuick 2.5
|
||||
import "../Components"
|
||||
import "../Shared"
|
||||
import "../Shared/Remote.js" as Remote
|
||||
|
||||
// Écran 1 : choix d'un serveur enregistré ou découvert sur le réseau local.
|
||||
Page {
|
||||
id: page
|
||||
|
||||
title: "Sélectionner un serveur"
|
||||
subtitle: serverList.count > 0
|
||||
? "Choisissez le serveur Jellyfin auquel vous connecter."
|
||||
: "Aucun serveur enregistré. Ajoutez l'adresse de votre serveur Jellyfin."
|
||||
initialFocus: serverList.count > 0 ? serverList : addButton
|
||||
|
||||
function openServer(index) {
|
||||
page.session.selectServer(index);
|
||||
page.navigator.push("UserSelect");
|
||||
}
|
||||
|
||||
ListView {
|
||||
id: serverList
|
||||
anchors {
|
||||
top: parent.top
|
||||
left: parent.left
|
||||
right: parent.right
|
||||
bottom: addButton.top
|
||||
bottomMargin: Theme.spacingL
|
||||
}
|
||||
clip: true
|
||||
spacing: Theme.spacingS
|
||||
model: page.session ? page.session.servers : null
|
||||
|
||||
// Serveur ajouté après l'affichage (dev-config) : on y place le focus.
|
||||
onCountChanged: {
|
||||
if (count > 0 && addButton.activeFocus) {
|
||||
currentIndex = 0;
|
||||
forceActiveFocus();
|
||||
}
|
||||
}
|
||||
|
||||
delegate: ServerItem {
|
||||
width: serverList.width
|
||||
name: model.name
|
||||
address: model.address
|
||||
highlighted: ListView.isCurrentItem && serverList.activeFocus
|
||||
onClicked: {
|
||||
serverList.currentIndex = index;
|
||||
page.openServer(index);
|
||||
}
|
||||
}
|
||||
|
||||
Keys.onPressed: {
|
||||
if (Remote.isAccept(event.key) && currentIndex >= 0) {
|
||||
event.accepted = true;
|
||||
page.openServer(currentIndex);
|
||||
}
|
||||
}
|
||||
// Laisse la ListView gérer Haut/Bas ; on ne sort qu'en bout de liste.
|
||||
KeyNavigation.priority: KeyNavigation.AfterItem
|
||||
KeyNavigation.down: addButton
|
||||
}
|
||||
|
||||
FocusButton {
|
||||
id: addButton
|
||||
anchors {
|
||||
left: parent.left
|
||||
bottom: parent.bottom
|
||||
}
|
||||
text: "Ajouter un serveur"
|
||||
KeyNavigation.up: serverList.count > 0 ? serverList : null
|
||||
onClicked: page.navigator.push("ServerAdd")
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,145 @@
|
||||
import QtQuick 2.5
|
||||
import "../Components"
|
||||
import "../Shared"
|
||||
import "../Shared/Remote.js" as Remote
|
||||
|
||||
// Écran 3 : choix de l'utilisateur parmi les comptes publics du serveur.
|
||||
// Si le serveur masque ses comptes, seule la carte « Ajouter un compte » est proposée,
|
||||
// plus les comptes de test éventuels (freebox-jellyfin deploy --user).
|
||||
Page {
|
||||
id: page
|
||||
|
||||
property var publicUsers: []
|
||||
// Comptes publics + comptes de test absents de la liste publique.
|
||||
property var users: mergeUsers(publicUsers, page.session ? page.session.devUsers : [])
|
||||
property bool loading: true
|
||||
property bool busy: false
|
||||
property string error: ""
|
||||
|
||||
title: "Qui regarde ?"
|
||||
subtitle: page.session && page.session.currentServer
|
||||
? page.session.currentServer.name + " · " + page.session.currentServer.address
|
||||
: ""
|
||||
initialFocus: userList
|
||||
|
||||
function mergeUsers(publicList, devList) {
|
||||
var result = publicList.slice();
|
||||
for (var i = 0; i < devList.length; i++) {
|
||||
var known = false;
|
||||
for (var j = 0; j < publicList.length; j++)
|
||||
known = known || publicList[j].name.toLowerCase() === devList[i].name.toLowerCase();
|
||||
if (!known)
|
||||
result.push({ name: devList[i].name, hasPassword: true, devPassword: devList[i].password });
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
function signInAs(name, password) {
|
||||
error = "";
|
||||
busy = true;
|
||||
page.session.authenticate(name, password, function (err) {
|
||||
page.busy = false;
|
||||
if (err) {
|
||||
page.error = err;
|
||||
return;
|
||||
}
|
||||
page.navigator.reset("Home");
|
||||
});
|
||||
}
|
||||
|
||||
function openUser(index) {
|
||||
if (busy)
|
||||
return;
|
||||
// Dernière carte : « Ajouter un compte » → identifiant libre.
|
||||
if (index >= users.length) {
|
||||
page.navigator.push("Login");
|
||||
return;
|
||||
}
|
||||
var user = users[index];
|
||||
// Compte de test avec mot de passe fourni : connexion directe.
|
||||
if (user.devPassword !== undefined) {
|
||||
signInAs(user.name, user.devPassword);
|
||||
return;
|
||||
}
|
||||
if (user.hasPassword) {
|
||||
page.navigator.push("Login", { username: user.name });
|
||||
return;
|
||||
}
|
||||
// Compte sans mot de passe : connexion directe, comme sur Android TV.
|
||||
signInAs(user.name, "");
|
||||
}
|
||||
|
||||
Component.onCompleted: {
|
||||
page.session.loadPublicUsers(function (err, users) {
|
||||
page.loading = false;
|
||||
if (err) {
|
||||
page.error = err;
|
||||
return;
|
||||
}
|
||||
page.publicUsers = users;
|
||||
});
|
||||
}
|
||||
|
||||
Component.onDestruction: if (page.session) page.session.cancel()
|
||||
|
||||
ListView {
|
||||
id: userList
|
||||
anchors {
|
||||
top: parent.top
|
||||
left: parent.left
|
||||
right: parent.right
|
||||
}
|
||||
height: 220
|
||||
orientation: ListView.Horizontal
|
||||
spacing: Theme.spacingL
|
||||
model: page.users.concat([{ name: "Ajouter un compte", add: true }])
|
||||
|
||||
delegate: UserCard {
|
||||
name: modelData.name
|
||||
addCard: modelData.add === true
|
||||
highlighted: ListView.isCurrentItem && userList.activeFocus
|
||||
onClicked: {
|
||||
userList.currentIndex = index;
|
||||
page.openUser(index);
|
||||
}
|
||||
}
|
||||
|
||||
Keys.onPressed: {
|
||||
if (Remote.isAccept(event.key) && currentIndex >= 0) {
|
||||
event.accepted = true;
|
||||
page.openUser(currentIndex);
|
||||
}
|
||||
}
|
||||
KeyNavigation.priority: KeyNavigation.AfterItem
|
||||
KeyNavigation.down: changeServerButton
|
||||
}
|
||||
|
||||
Text {
|
||||
id: statusText
|
||||
anchors {
|
||||
top: userList.bottom
|
||||
left: parent.left
|
||||
right: parent.right
|
||||
}
|
||||
visible: text !== ""
|
||||
text: page.busy ? "Connexion…"
|
||||
: page.loading ? "Chargement des utilisateurs…"
|
||||
: page.error !== "" ? page.error
|
||||
: page.users.length === 0 ? "Les comptes de ce serveur ne sont pas affichés publiquement : choisissez « Ajouter un compte » pour vous connecter."
|
||||
: ""
|
||||
color: page.error !== "" && !page.busy ? Theme.error : Theme.textMuted
|
||||
font.pixelSize: Theme.fontBody
|
||||
wrapMode: Text.WordWrap
|
||||
}
|
||||
|
||||
FocusButton {
|
||||
id: changeServerButton
|
||||
anchors {
|
||||
left: parent.left
|
||||
bottom: parent.bottom
|
||||
}
|
||||
text: "Changer de serveur"
|
||||
KeyNavigation.up: userList
|
||||
onClicked: page.navigator.reset("ServerSelect")
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user