Add basic behavior to play, show catalog and more basic feature

This commit is contained in:
stilobique committed 2026-11-08 12:06:15 +01:00
1 parent df847becc8
commit 8e6392a84c
17 files changed
+1455 -34

No files matched your search

+77
View File
@@ -0,0 +1,77 @@
.pragma library
// Mise en forme des durées et des libellés de médias.
var TICKS_PER_MS = 10000; // Jellyfin compte en « ticks » de 100 ns
function ticksToMs(ticks) {
return Math.floor((ticks || 0) / TICKS_PER_MS);
}
function msToTicks(ms) {
return Math.floor((ms || 0) * TICKS_PER_MS);
}
// « 1 h 34 min », « 52 min »
function runtime(ticks) {
var minutes = Math.round(ticksToMs(ticks) / 60000);
if (minutes <= 0)
return "";
if (minutes < 60)
return minutes + " min";
var m = minutes % 60;
return Math.floor(minutes / 60) + " h" + (m > 0 ? " " + (m < 10 ? "0" : "") + m + " min" : "");
}
// « 1:02:03 », « 4:05 »
function clock(ms) {
var total = Math.max(0, Math.floor((ms || 0) / 1000));
var h = Math.floor(total / 3600);
var m = Math.floor((total % 3600) / 60);
var s = total % 60;
var mm = h > 0 && m < 10 ? "0" + m : String(m);
return (h > 0 ? h + ":" : "") + mm + ":" + (s < 10 ? "0" : "") + s;
}
// « S1 · É3 » pour un épisode
function episodeCode(item) {
if (!item || item.type !== "Episode")
return "";
return "S" + (item.parentIndexNumber || 0) + " · É" + (item.indexNumber || 0);
}
// Libellés des cartes du catalogue.
function cardTitle(item) {
return item.type === "Episode" && item.seriesName ? item.seriesName : item.name;
}
function cardSubtitle(item) {
if (item.type === "Episode")
return episodeCode(item) + " – " + item.name;
if (item.type === "Series" && item.childCount)
return item.childCount + " saison" + (item.childCount > 1 ? "s" : "");
return item.year ? String(item.year) : "";
}
// Avancement 0..1 (pour la barre de progression des cartes).
function progress(item) {
if (item.playedPercentage)
return item.playedPercentage / 100;
return item.runtimeTicks ? item.positionTicks / item.runtimeTicks : 0;
}
// Ligne d'informations : « 1997 · 1 h 34 min · Tous publics »
function infoLine(item) {
var parts = [];
if (item.type === "Episode")
parts.push(episodeCode(item));
if (item.year)
parts.push(String(item.year));
if (item.runtimeTicks)
parts.push(runtime(item.runtimeTicks));
if (item.rating)
parts.push(item.rating);
if (item.communityRating)
parts.push(item.communityRating.toFixed(1).replace(".", ",") + "/10");
return parts.join(" · ");
}
+7
View File
@@ -31,6 +31,13 @@ QtObject {
readonly property int fontTitle: 32
readonly property int fontCode: 56
// Cartes du catalogue (affiche 2:3, vignette 16:9)
readonly property int posterWidth: 150
readonly property int posterHeight: 225
readonly property int thumbWidth: 267
readonly property int thumbHeight: 150
readonly property int cardTextHeight: 52
// Contrôles
readonly property int controlHeight: 48
readonly property int radius: 6