Compare commits
5
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
acb58142d9 | ||
|
|
f6462f05b8 | ||
|
|
e99e5bf6b4 | ||
|
|
49d8524597 | ||
|
|
186cff1d73 |
No files matched your search
@@ -70,3 +70,6 @@ Thumbs.db
|
||||
*.dll
|
||||
*.exe
|
||||
|
||||
|
||||
# Log de tools/deploy.py
|
||||
deploy.log
|
||||
Generated
+15
@@ -0,0 +1,15 @@
|
||||
# Default ignored files
|
||||
/shelf/
|
||||
/workspace.xml
|
||||
# Editor-based HTTP Client requests
|
||||
/httpRequests/
|
||||
# Rider ignored files
|
||||
/modules.xml
|
||||
/contentModel.xml
|
||||
/projectSettingsUpdater.xml
|
||||
/.idea.Jellyfin-Freebox.iml
|
||||
# Ignored default folder with query files
|
||||
/queries/
|
||||
# Datasource local storage ignored files
|
||||
/dataSources/
|
||||
/dataSources.local.xml
|
||||
Generated
+23
@@ -0,0 +1,23 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!-- ***** BEGIN LICENSE BLOCK *****
|
||||
- Part of the Jellyfin project (https://jellyfin.media)
|
||||
-
|
||||
- All copyright belongs to the Jellyfin contributors; a full list can
|
||||
- be found in the file CONTRIBUTORS.md
|
||||
-
|
||||
- This work is licensed under the Creative Commons Attribution-ShareAlike 4.0 International License.
|
||||
- To view a copy of this license, visit http://creativecommons.org/licenses/by-sa/4.0/.
|
||||
- ***** END LICENSE BLOCK ***** -->
|
||||
<svg version="1.1" id="icon-transparent" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 512 512">
|
||||
<defs>
|
||||
<linearGradient id="linear-gradient" gradientUnits="userSpaceOnUse" x1="110.25" y1="213.3" x2="496.14" y2="436.09">
|
||||
<stop offset="0" style="stop-color:#AA5CC3"/>
|
||||
<stop offset="1" style="stop-color:#00A4DC"/>
|
||||
</linearGradient>
|
||||
</defs>
|
||||
<title>icon-transparent</title>
|
||||
<g id="icon-transparent">
|
||||
<path id="inner-shape" d="M256,201.6c-20.4,0-86.2,119.3-76.2,139.4s142.5,19.9,152.4,0S276.5,201.6,256,201.6z" fill="url(#linear-gradient)"/>
|
||||
<path id="outer-shape" d="M256,23.3c-61.6,0-259.8,359.4-229.6,420.1s429.3,60,459.2,0S317.6,23.3,256,23.3z M406.5,390.8c-19.6,39.3-281.1,39.8-300.9,0s110.1-275.3,150.4-275.3S426.1,351.4,406.5,390.8z" fill="url(#linear-gradient)"/>
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 1.3 KiB |
@@ -0,0 +1,26 @@
|
||||
<component name="ProjectRunConfigurationManager">
|
||||
<configuration default="false" name="Local Deploy" type="PythonConfigurationType" factoryName="Python">
|
||||
<module name="rider.module" />
|
||||
<option name="ENV_FILES" value="" />
|
||||
<option name="INTERPRETER_OPTIONS" value="" />
|
||||
<option name="PARENT_ENVS" value="true" />
|
||||
<envs>
|
||||
<env name="PYTHONUNBUFFERED" value="1" />
|
||||
</envs>
|
||||
<option name="SDK_HOME" value="" />
|
||||
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$" />
|
||||
<option name="IS_MODULE_SDK" value="true" />
|
||||
<option name="ADD_CONTENT_ROOTS" value="true" />
|
||||
<option name="ADD_SOURCE_ROOTS" value="true" />
|
||||
<option name="DEBUG_JUST_MY_CODE" value="false" />
|
||||
<option name="RUN_TOOL" value="" />
|
||||
<option name="SCRIPT_NAME" value="$PROJECT_DIR$/tools/deploy.py" />
|
||||
<option name="PARAMETERS" value="" />
|
||||
<option name="SHOW_COMMAND_LINE" value="false" />
|
||||
<option name="EMULATE_TERMINAL" value="false" />
|
||||
<option name="MODULE_MODE" value="false" />
|
||||
<option name="REDIRECT_INPUT" value="false" />
|
||||
<option name="INPUT_FILE" value="" />
|
||||
<method v="2" />
|
||||
</configuration>
|
||||
</component>
|
||||
@@ -0,0 +1,47 @@
|
||||
# CLAUDE.md
|
||||
|
||||
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
|
||||
|
||||
## Project
|
||||
|
||||
A Jellyfin client for the Freebox Player (Revolution), written in pure QML (no C++). The app runs inside the Freebox's QML runtime via the `fbx.application` module, The UI follows the Jellyfin Android TV app's flow and conventions. UI text is in French.
|
||||
|
||||
## Build / run
|
||||
|
||||
There is no build system or test suite.
|
||||
|
||||
**Local preview on the PC** (no Freebox needed): `fbx.application` from [libfbxqml](https://github.com/fbx/libfbxqml) is pure QML (a fullscreen `Window` scaled to a 720p virtual height), so the app runs with Qt 5's `qmlscene`.
|
||||
|
||||
- Prerequisites: `sudo apt install qmlscene qml-module-qtmultimedia qtdeclarative5-dev-tools`, and libfbxqml cloned next to the repo (`../libfbxqml`, override with `LIBFBXQML=`).
|
||||
- `tools/run-local.sh` — 1280×720 window via `tools/preview.qml`; `tools/run-local.sh --fullscreen` runs `Jellyfin.qml` as the box would.
|
||||
- `QT_QPA_PLATFORM=offscreen tools/run-local.sh` — headless run, useful to catch QML warnings.
|
||||
- Lint: `qmllint Jellyfin.qml Components/*.qml Core/*.qml Shared/*.qml Views/*.qml`
|
||||
- **Reproduce the box's loading mode**: the Player loads the app over HTTP, which behaves differently from local files (see constraints below). Check with `python3 -m http.server 8765 --directory .` then `QT_QPA_PLATFORM=offscreen qmlscene -I ../libfbxqml http://127.0.0.1:8765/Jellyfin.qml` — it must print no warnings.
|
||||
- The desktop has Qt 5.15 while the box targets QtQuick 2.5: code that runs locally can still use APIs too new for the box.
|
||||
|
||||
**Deploying a test build to the Freebox**: `tools/deploy.py` (Python stdlib only; Player must be in developer mode). It discovers the Player via SSDP (`fbx:devel`) or takes `--box <IP>`, serves the repo over HTTP, calls JSON-RPC `debug_qml_app` on `http://<box>/pub/devel`, and streams the app's stdout/stderr until it exits. Output is also written to `deploy.log` (repo root, gitignored, overwritten each run) — read it to diagnose on-box failures. The Player fetches files lazily from that HTTP server, so the script must keep running while the app is in use. This replicates the "Run" of the official QtCreator plugin, whose own setup is:
|
||||
|
||||
- SDK setup: https://dev.freebox.fr/sdk/player.html (Windows: https://github.com/fbx/freebox-qtcreator-plugin/issues/8)
|
||||
- Open `Jellyfin.fbxproject` in QtCreator with the Freebox plugin; the run target deploys to a Freebox Player on the LAN (configured in `Jellyfin.fbxproject.user`, which is machine-specific).
|
||||
- `Jellyfin.fbxproject` packages every QML/JS/image/font/`qmldir` file under the repo root plus `manifest.json` — new files are picked up automatically.
|
||||
|
||||
## Architecture
|
||||
|
||||
- `Jellyfin.qml` — root `Application`: logo panel (1/3) + `Navigator` (2/3), owns the single `Session` instance.
|
||||
- `Core/Navigator.qml` — screen stack on a `Loader`. `push("Name")` loads `Views/NameView.qml`; also `replace`, `pop`, `reset`. Every view gets `navigator` and `session` injected, plus any props passed to `push`. Remote Back/Escape pops; at the root it propagates (exits app). After loading, focus goes to the view's `initialFocus`.
|
||||
- `Core/Session.qml` — servers (`ListModel`), `currentServer`, `currentUser`. Network calls are **mocked** via `_simulate()`; each has a `TODO API` comment naming the Jellyfin endpoint. Async functions use `callback(error, result)` — keep that shape when wiring the real API. Views call `session.cancel()` on destruction.
|
||||
- `Components/` — reusable widgets, listed in `Components/qmldir`.
|
||||
- `Shared/` — `Theme` singleton (colors, spacing, fonts; the only type in `Shared/qmldir`) and `Remote.js` (`.pragma library`, `isAccept`/`isBack` key mapping, imported `as Remote`).
|
||||
- `Views/` — one screen per file, each rooted in `Page` (title/subtitle header + content area). Current flow: `ServerSelect` → `ServerAdd` → `UserSelect` → `Login` (password or Quick Connect) → `Home` (placeholder).
|
||||
|
||||
## Platform constraints
|
||||
|
||||
- Target is QtQuick 2.5 (Qt 5.5 era): **ES5 JavaScript only** (`var`, `function`; no `let`/`const`/arrow functions) and no QtQuick.Controls.
|
||||
- Input is a TV remote: navigation uses `KeyNavigation` + explicit focus. On a `ListView`, set `KeyNavigation.priority: KeyNavigation.AfterItem` so the list handles arrows itself and only hands off at its ends.
|
||||
- The box's virtual keyboard lacks `:` (and likely `/`): never require typing a URL scheme or `host:port`. Server entry takes host + optional numeric port; `Session.serverCandidates()` derives the URLs to probe (https, http:8096, https:8920, http).
|
||||
- In bindings, guard `page.session`/`page.navigator` against null: they are injected after bindings are first evaluated.
|
||||
- **HTTP loading rules** (the box fetches files over HTTP, so directories can't be listed):
|
||||
- every imported directory needs a `qmldir` listing all its types (`Core/`, `Components/`, `Shared/`); a missing one gives "X is not a type" only on the box;
|
||||
- a singleton must not live in the same directory as the components that use it, and a directory must hold at most one singleton — otherwise "Cyclic dependency detected". Put helpers in `.pragma library` JS files instead of new singletons;
|
||||
- no `import "."` self-imports.
|
||||
- Don't disable (`enabled: false`) a focused control during loading — it loses focus and the remote stops responding; guard with a `busy` flag instead.
|
||||
@@ -0,0 +1,47 @@
|
||||
import QtQuick 2.5
|
||||
import "../Shared"
|
||||
import "../Shared/Remote.js" as Remote
|
||||
|
||||
// Bouton navigable à la télécommande : surbrillance blanche quand il a le focus.
|
||||
Rectangle {
|
||||
id: root
|
||||
|
||||
property alias text: label.text
|
||||
property bool primary: false
|
||||
signal clicked()
|
||||
|
||||
implicitWidth: Math.max(160, label.implicitWidth + Theme.spacingL * 2)
|
||||
implicitHeight: Theme.controlHeight
|
||||
radius: Theme.radius
|
||||
opacity: enabled ? 1 : 0.5
|
||||
color: activeFocus ? Theme.focusBackground : (primary ? Theme.accent : Theme.surface)
|
||||
scale: activeFocus ? 1.05 : 1
|
||||
|
||||
Behavior on scale { NumberAnimation { duration: Theme.animFast } }
|
||||
Behavior on color { ColorAnimation { duration: Theme.animFast } }
|
||||
|
||||
Text {
|
||||
id: label
|
||||
anchors.centerIn: parent
|
||||
color: root.activeFocus ? Theme.textOnFocus : Theme.text
|
||||
font.pixelSize: Theme.fontBody
|
||||
font.bold: root.activeFocus
|
||||
}
|
||||
|
||||
Keys.onPressed: {
|
||||
if (Remote.isAccept(event.key)) {
|
||||
event.accepted = true;
|
||||
root.clicked();
|
||||
}
|
||||
}
|
||||
|
||||
// Souris : pratique pour tester hors de la box.
|
||||
MouseArea {
|
||||
anchors.fill: parent
|
||||
enabled: root.enabled
|
||||
onClicked: {
|
||||
root.forceActiveFocus();
|
||||
root.clicked();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
import QtQuick 2.5
|
||||
import "../Shared"
|
||||
|
||||
// Panneau de gauche avec le logo, affiché sur tous les écrans de connexion.
|
||||
Rectangle {
|
||||
color: Theme.panel
|
||||
|
||||
Image {
|
||||
anchors.centerIn: parent
|
||||
source: "../icon.png"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
import QtQuick 2.5
|
||||
import "../Shared"
|
||||
|
||||
// Base de chaque écran : en-tête (titre + sous-titre) et zone de contenu.
|
||||
// `navigator` et `session` sont injectés par le Navigator au chargement.
|
||||
FocusScope {
|
||||
id: page
|
||||
|
||||
property var navigator: null
|
||||
property var session: null
|
||||
// Élément qui reçoit le focus quand l'écran s'affiche.
|
||||
property Item initialFocus: null
|
||||
|
||||
property alias title: titleText.text
|
||||
property alias subtitle: subtitleText.text
|
||||
default property alias content: body.data
|
||||
|
||||
Column {
|
||||
id: header
|
||||
anchors {
|
||||
top: parent.top
|
||||
left: parent.left
|
||||
right: parent.right
|
||||
margins: Theme.pageMargin
|
||||
}
|
||||
spacing: Theme.spacingS
|
||||
|
||||
Text {
|
||||
id: titleText
|
||||
width: parent.width
|
||||
color: Theme.text
|
||||
font.pixelSize: Theme.fontTitle
|
||||
font.bold: true
|
||||
elide: Text.ElideRight
|
||||
}
|
||||
|
||||
Text {
|
||||
id: subtitleText
|
||||
width: parent.width
|
||||
visible: text !== ""
|
||||
color: Theme.textMuted
|
||||
font.pixelSize: Theme.fontBody
|
||||
wrapMode: Text.WordWrap
|
||||
}
|
||||
}
|
||||
|
||||
Item {
|
||||
id: body
|
||||
anchors {
|
||||
top: header.bottom
|
||||
topMargin: Theme.spacingXL
|
||||
left: parent.left
|
||||
right: parent.right
|
||||
bottom: parent.bottom
|
||||
leftMargin: Theme.pageMargin
|
||||
rightMargin: Theme.pageMargin
|
||||
bottomMargin: Theme.pageMargin
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,94 @@
|
||||
import QtQuick 2.5
|
||||
import "../Shared"
|
||||
|
||||
// Ligne de la liste des serveurs.
|
||||
Rectangle {
|
||||
id: root
|
||||
|
||||
property string name: ""
|
||||
property string address: ""
|
||||
property bool discovered: false
|
||||
property bool highlighted: false
|
||||
signal clicked()
|
||||
|
||||
height: 72
|
||||
radius: Theme.radius
|
||||
color: highlighted ? Theme.focusBackground : Theme.surface
|
||||
|
||||
Behavior on color { ColorAnimation { duration: Theme.animFast } }
|
||||
|
||||
Rectangle {
|
||||
id: icon
|
||||
anchors {
|
||||
left: parent.left
|
||||
leftMargin: Theme.spacingM
|
||||
verticalCenter: parent.verticalCenter
|
||||
}
|
||||
width: 40
|
||||
height: 40
|
||||
radius: width / 2
|
||||
color: Theme.avatarColor(root.name)
|
||||
|
||||
Text {
|
||||
anchors.centerIn: parent
|
||||
text: root.name.charAt(0).toUpperCase()
|
||||
color: Theme.text
|
||||
font.pixelSize: Theme.fontBody
|
||||
font.bold: true
|
||||
}
|
||||
}
|
||||
|
||||
Column {
|
||||
anchors {
|
||||
left: icon.right
|
||||
leftMargin: Theme.spacingM
|
||||
right: root.discovered ? tag.left : parent.right
|
||||
rightMargin: Theme.spacingM
|
||||
verticalCenter: parent.verticalCenter
|
||||
}
|
||||
|
||||
Text {
|
||||
width: parent.width
|
||||
text: root.name
|
||||
color: root.highlighted ? Theme.textOnFocus : Theme.text
|
||||
font.pixelSize: Theme.fontBody
|
||||
font.bold: true
|
||||
elide: Text.ElideRight
|
||||
}
|
||||
|
||||
Text {
|
||||
width: parent.width
|
||||
text: root.address
|
||||
color: root.highlighted ? Theme.textOnFocusMuted : Theme.textMuted
|
||||
font.pixelSize: Theme.fontSmall
|
||||
elide: Text.ElideRight
|
||||
}
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
id: tag
|
||||
visible: root.discovered
|
||||
anchors {
|
||||
right: parent.right
|
||||
rightMargin: Theme.spacingM
|
||||
verticalCenter: parent.verticalCenter
|
||||
}
|
||||
width: tagText.implicitWidth + Theme.spacingM
|
||||
height: tagText.implicitHeight + Theme.spacingS
|
||||
radius: height / 2
|
||||
color: Theme.accentAlt
|
||||
|
||||
Text {
|
||||
id: tagText
|
||||
anchors.centerIn: parent
|
||||
text: "Réseau local"
|
||||
color: Theme.text
|
||||
font.pixelSize: Theme.fontSmall
|
||||
}
|
||||
}
|
||||
|
||||
MouseArea {
|
||||
anchors.fill: parent
|
||||
onClicked: root.clicked()
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
import QtQuick 2.5
|
||||
import "../Shared"
|
||||
|
||||
// Champ de saisie avec libellé. Haut/Bas ne sont pas consommés par le TextInput
|
||||
// et remontent donc jusqu'au KeyNavigation posé sur ce composant.
|
||||
FocusScope {
|
||||
id: root
|
||||
|
||||
property alias label: labelText.text
|
||||
property alias text: input.text
|
||||
property alias placeholder: placeholderText.text
|
||||
property bool password: false
|
||||
// Ex. Qt.ImhDigitsOnly pour demander un clavier numérique (si le système le gère).
|
||||
property alias inputMethodHints: input.inputMethodHints
|
||||
property alias validator: input.validator
|
||||
property alias maximumLength: input.maximumLength
|
||||
signal accepted()
|
||||
|
||||
implicitWidth: 400
|
||||
implicitHeight: column.implicitHeight
|
||||
|
||||
MouseArea {
|
||||
anchors.fill: parent
|
||||
onClicked: input.forceActiveFocus()
|
||||
}
|
||||
|
||||
Column {
|
||||
id: column
|
||||
width: parent.width
|
||||
spacing: Theme.spacingS
|
||||
|
||||
Text {
|
||||
id: labelText
|
||||
visible: text !== ""
|
||||
color: root.activeFocus ? Theme.text : Theme.textMuted
|
||||
font.pixelSize: Theme.fontSmall
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
width: parent.width
|
||||
height: Theme.controlHeight
|
||||
radius: Theme.radius
|
||||
color: Theme.surface
|
||||
border.width: 2
|
||||
border.color: root.activeFocus ? Theme.accent : Theme.border
|
||||
|
||||
TextInput {
|
||||
id: input
|
||||
anchors {
|
||||
fill: parent
|
||||
leftMargin: Theme.spacingM
|
||||
rightMargin: Theme.spacingM
|
||||
}
|
||||
focus: true
|
||||
clip: true
|
||||
verticalAlignment: TextInput.AlignVCenter
|
||||
color: Theme.text
|
||||
selectionColor: Theme.accent
|
||||
font.pixelSize: Theme.fontBody
|
||||
echoMode: root.password ? TextInput.Password : TextInput.Normal
|
||||
onAccepted: root.accepted()
|
||||
}
|
||||
|
||||
Text {
|
||||
id: placeholderText
|
||||
anchors.fill: input
|
||||
visible: input.text === ""
|
||||
verticalAlignment: Text.AlignVCenter
|
||||
color: Theme.textMuted
|
||||
font: input.font
|
||||
elide: Text.ElideRight
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
import QtQuick 2.5
|
||||
import "../Shared"
|
||||
|
||||
// Carte utilisateur (avatar rond + nom). `addCard` affiche la carte « Ajouter un compte ».
|
||||
Item {
|
||||
id: root
|
||||
|
||||
property string name: ""
|
||||
property bool addCard: false
|
||||
property bool highlighted: false
|
||||
signal clicked()
|
||||
|
||||
width: 140
|
||||
height: 200
|
||||
|
||||
Rectangle {
|
||||
id: avatar
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
y: Theme.spacingS
|
||||
width: 120
|
||||
height: 120
|
||||
radius: width / 2
|
||||
color: root.addCard ? Theme.surface : Theme.avatarColor(root.name)
|
||||
border.width: root.highlighted ? 4 : 0
|
||||
border.color: Theme.focusBackground
|
||||
scale: root.highlighted ? 1.1 : 1
|
||||
|
||||
Behavior on scale { NumberAnimation { duration: Theme.animFast } }
|
||||
|
||||
Text {
|
||||
anchors.centerIn: parent
|
||||
text: root.addCard ? "+" : root.name.charAt(0).toUpperCase()
|
||||
color: Theme.text
|
||||
font.pixelSize: 48
|
||||
font.bold: true
|
||||
}
|
||||
}
|
||||
|
||||
Text {
|
||||
anchors {
|
||||
top: avatar.bottom
|
||||
topMargin: Theme.spacingL
|
||||
left: parent.left
|
||||
right: parent.right
|
||||
}
|
||||
text: root.name
|
||||
horizontalAlignment: Text.AlignHCenter
|
||||
wrapMode: Text.WordWrap
|
||||
maximumLineCount: 2
|
||||
elide: Text.ElideRight
|
||||
color: root.highlighted ? Theme.text : Theme.textMuted
|
||||
font.pixelSize: Theme.fontBody
|
||||
font.bold: root.highlighted
|
||||
}
|
||||
|
||||
MouseArea {
|
||||
anchors.fill: parent
|
||||
onClicked: root.clicked()
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
Page 1.0 Page.qml
|
||||
FocusButton 1.0 FocusButton.qml
|
||||
TextField 1.0 TextField.qml
|
||||
ServerItem 1.0 ServerItem.qml
|
||||
UserCard 1.0 UserCard.qml
|
||||
Logo 1.0 Logo.qml
|
||||
@@ -0,0 +1,74 @@
|
||||
import QtQuick 2.5
|
||||
import "../Shared"
|
||||
import "../Shared/Remote.js" as Remote
|
||||
|
||||
// Pile de navigation entre les écrans de Views/.
|
||||
// push("ServerAdd") charge Views/ServerAddView.qml ; la touche Retour dépile.
|
||||
// Chaque écran reçoit `navigator` et `session`, plus les propriétés passées à push().
|
||||
FocusScope {
|
||||
id: root
|
||||
|
||||
property var session: null
|
||||
property int depth: 0
|
||||
property var _stack: []
|
||||
|
||||
function push(name, props) {
|
||||
_stack.push({ name: name, props: props || {} });
|
||||
_load();
|
||||
}
|
||||
|
||||
function replace(name, props) {
|
||||
if (_stack.length > 0)
|
||||
_stack.pop();
|
||||
push(name, props);
|
||||
}
|
||||
|
||||
function pop() {
|
||||
if (_stack.length <= 1)
|
||||
return false;
|
||||
_stack.pop();
|
||||
_load();
|
||||
return true;
|
||||
}
|
||||
|
||||
function reset(name, props) {
|
||||
_stack = [];
|
||||
push(name, props);
|
||||
}
|
||||
|
||||
function _load() {
|
||||
var entry = _stack[_stack.length - 1];
|
||||
var props = { navigator: root, session: root.session };
|
||||
for (var key in entry.props)
|
||||
props[key] = entry.props[key];
|
||||
depth = _stack.length;
|
||||
loader.setSource(Qt.resolvedUrl("../Views/" + entry.name + "View.qml"), props);
|
||||
}
|
||||
|
||||
Loader {
|
||||
id: loader
|
||||
anchors.fill: parent
|
||||
focus: true
|
||||
|
||||
onLoaded: {
|
||||
fadeIn.restart();
|
||||
var target = item.initialFocus ? item.initialFocus : item;
|
||||
target.forceActiveFocus();
|
||||
}
|
||||
}
|
||||
|
||||
NumberAnimation {
|
||||
id: fadeIn
|
||||
target: loader.item
|
||||
property: "opacity"
|
||||
from: 0
|
||||
to: 1
|
||||
duration: 180
|
||||
}
|
||||
|
||||
// Retour : on dépile ; à la racine, la touche remonte (fermeture de l'app).
|
||||
Keys.onPressed: {
|
||||
if (Remote.isBack(event.key) && pop())
|
||||
event.accepted = true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,163 @@
|
||||
import QtQuick 2.5
|
||||
|
||||
// État de connexion : serveurs connus, serveur et utilisateur courants.
|
||||
// Les appels réseau sont SIMULÉS (_simulate) : à remplacer par l'API Jellyfin
|
||||
// en gardant la forme des callbacks `callback(erreur, résultat)`.
|
||||
QtObject {
|
||||
id: session
|
||||
|
||||
property ListModel servers: ListModel {
|
||||
// Données fictives
|
||||
ListElement { name: "Maison"; address: "http://192.168.1.20:8096"; discovered: false }
|
||||
ListElement { name: "jellyfin-nas"; address: "http://192.168.1.42:8096"; discovered: true }
|
||||
}
|
||||
|
||||
property var currentServer: null // { name, address }
|
||||
property var currentUser: null // { name }
|
||||
|
||||
function selectServer(index) {
|
||||
var server = servers.get(index);
|
||||
currentServer = { name: server.name, address: server.address };
|
||||
}
|
||||
|
||||
// Ajoute (ou retrouve) un serveur à partir de l'hôte saisi et d'un port facultatif.
|
||||
// Le clavier de la box n'a ni « : » ni « / » : le protocole et le port sont
|
||||
// détectés en essayant chaque adresse de serverCandidates() dans l'ordre.
|
||||
function connectToServer(host, port, callback) {
|
||||
if ((host || "").trim() === "") {
|
||||
callback("Veuillez saisir l'adresse du serveur.");
|
||||
return;
|
||||
}
|
||||
var portText = (port || "").trim();
|
||||
if (portText !== "" && !isValidPort(portText)) {
|
||||
callback("Le port doit être un nombre entre 1 et 65535.");
|
||||
return;
|
||||
}
|
||||
_probeCandidates(serverCandidates(host, portText), 0, function (err, address) {
|
||||
if (err) {
|
||||
callback(err);
|
||||
return;
|
||||
}
|
||||
var index = _indexOfServer(address);
|
||||
if (index < 0) {
|
||||
servers.insert(0, { name: _hostOf(address), address: address, discovered: false });
|
||||
index = 0;
|
||||
}
|
||||
selectServer(index);
|
||||
callback(null, currentServer);
|
||||
});
|
||||
}
|
||||
|
||||
// Adresses à essayer, de la plus probable à la moins probable
|
||||
// (même logique que les clients Jellyfin officiels).
|
||||
function serverCandidates(host, port) {
|
||||
var text = (host || "").trim().replace(/\/+$/, "");
|
||||
if (text === "")
|
||||
return [];
|
||||
// Adresse complète (saisie depuis un clavier qui a « : ») : utilisée telle quelle.
|
||||
if (/^https?:\/\//i.test(text)) {
|
||||
if (port && !/:\d+$/.test(text.replace(/^https?:\/\//i, "")))
|
||||
text += ":" + port;
|
||||
return [text];
|
||||
}
|
||||
if (port)
|
||||
return ["https://" + text + ":" + port, "http://" + text + ":" + port];
|
||||
// Port déjà inclus dans l'hôte (ex. 192.168.1.20:8096).
|
||||
if (/:\d+$/.test(text))
|
||||
return ["https://" + text, "http://" + text];
|
||||
return [
|
||||
"https://" + text,
|
||||
"http://" + text + ":8096",
|
||||
"https://" + text + ":8920",
|
||||
"http://" + text
|
||||
];
|
||||
}
|
||||
|
||||
// Essaie les adresses une par une ; renvoie la première qui répond.
|
||||
// TODO API : GET <adresse>/System/Info/Public, accepter si la réponse contient un Id,
|
||||
// et utiliser ServerName comme nom. Simulation : la première adresse « répond ».
|
||||
function _probeCandidates(candidates, index, callback) {
|
||||
if (index >= candidates.length) {
|
||||
callback("Aucun serveur Jellyfin trouvé à cette adresse.");
|
||||
return;
|
||||
}
|
||||
_simulate(function () {
|
||||
callback(null, candidates[index]);
|
||||
});
|
||||
}
|
||||
|
||||
function isValidPort(text) {
|
||||
if (!/^\d+$/.test(text))
|
||||
return false;
|
||||
var value = parseInt(text, 10);
|
||||
return value >= 1 && value <= 65535;
|
||||
}
|
||||
|
||||
// TODO API : GET /Users/Public
|
||||
function publicUsers() {
|
||||
return [
|
||||
{ name: "Alice", hasPassword: true },
|
||||
{ name: "Bob", hasPassword: false },
|
||||
{ name: "Enfants", hasPassword: false }
|
||||
];
|
||||
}
|
||||
|
||||
// TODO API : POST /Users/AuthenticateByName
|
||||
function authenticate(username, password, callback) {
|
||||
var name = (username || "").trim();
|
||||
if (name === "") {
|
||||
callback("Veuillez saisir votre nom d'utilisateur.");
|
||||
return;
|
||||
}
|
||||
_simulate(function () {
|
||||
currentUser = { name: name };
|
||||
callback(null, currentUser);
|
||||
});
|
||||
}
|
||||
|
||||
// TODO API : POST /QuickConnect/Initiate puis interroger /QuickConnect/Connect
|
||||
function startQuickConnect() {
|
||||
var code = "";
|
||||
for (var i = 0; i < 6; i++)
|
||||
code += Math.floor(Math.random() * 10);
|
||||
return code;
|
||||
}
|
||||
|
||||
function logout() {
|
||||
currentUser = null;
|
||||
}
|
||||
|
||||
function cancel() {
|
||||
_pending = null;
|
||||
_latency.stop();
|
||||
}
|
||||
|
||||
function _hostOf(address) {
|
||||
return address.replace(/^https?:\/\//i, "").split(/[:\/]/)[0];
|
||||
}
|
||||
|
||||
function _indexOfServer(address) {
|
||||
for (var i = 0; i < servers.count; i++) {
|
||||
if (servers.get(i).address === address)
|
||||
return i;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Simulation de latence réseau.
|
||||
property var _pending: null
|
||||
property Timer _latency: Timer {
|
||||
interval: 700
|
||||
onTriggered: {
|
||||
var callback = session._pending;
|
||||
session._pending = null;
|
||||
if (callback)
|
||||
callback();
|
||||
}
|
||||
}
|
||||
|
||||
function _simulate(callback) {
|
||||
_pending = callback;
|
||||
_latency.restart();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
Session 1.0 Session.qml
|
||||
Navigator 1.0 Navigator.qml
|
||||
+28
-18
@@ -1,32 +1,42 @@
|
||||
import QtQuick 2.5
|
||||
import fbx.application 1.0
|
||||
import "Views" as View
|
||||
import "Components"
|
||||
import "Shared"
|
||||
import "Core"
|
||||
|
||||
Application {
|
||||
Rectangle {
|
||||
anchors.fill: parent
|
||||
color: Theme.background
|
||||
}
|
||||
|
||||
Session {
|
||||
id: appSession
|
||||
}
|
||||
|
||||
Row {
|
||||
anchors.fill: parent
|
||||
spacing: 10
|
||||
|
||||
Rectangle {
|
||||
width: parent.width / 3 - 5
|
||||
Logo {
|
||||
id: logo
|
||||
width: parent.width / 3
|
||||
height: parent.height
|
||||
|
||||
View.Logo {}
|
||||
}
|
||||
Rectangle {
|
||||
width: parent.width / 3 * 2 - 5
|
||||
|
||||
Navigator {
|
||||
id: navigator
|
||||
width: parent.width - logo.width
|
||||
height: parent.height
|
||||
|
||||
color: "#000B25"
|
||||
|
||||
session: appSession
|
||||
focus: true
|
||||
|
||||
View.Login {}
|
||||
}
|
||||
|
||||
Component.onCompleted: {
|
||||
// Setup the login view to be focus on start
|
||||
columnLogin.updateSelection();
|
||||
}
|
||||
}
|
||||
|
||||
// Appelée par le runtime Freebox (ouverture de l'app via une URL / un lien profond).
|
||||
// Pas encore utilisée : la déclarer évite l'avertissement au démarrage.
|
||||
function handleUrl(url) {
|
||||
console.log("handleUrl:", url);
|
||||
}
|
||||
|
||||
Component.onCompleted: navigator.push("ServerSelect")
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
.pragma library
|
||||
|
||||
// Correspondance des touches de la télécommande Freebox.
|
||||
// Plusieurs codes sont acceptés tant que le mapping exact sur la box n'est pas vérifié.
|
||||
|
||||
function isAccept(key) {
|
||||
return key === Qt.Key_Return || key === Qt.Key_Enter || key === Qt.Key_Select;
|
||||
}
|
||||
|
||||
function isBack(key) {
|
||||
return key === Qt.Key_Back || key === Qt.Key_Escape;
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
pragma Singleton
|
||||
import QtQuick 2.5
|
||||
|
||||
// Couleurs, tailles et animations partagées par toute l'application.
|
||||
QtObject {
|
||||
// Couleurs (inspirées de la palette Jellyfin)
|
||||
readonly property color background: "#101010"
|
||||
readonly property color panel: "#000B25"
|
||||
readonly property color surface: "#202020"
|
||||
readonly property color border: "#3A3A3A"
|
||||
readonly property color focusBackground: "#FFFFFF"
|
||||
readonly property color text: "#FFFFFF"
|
||||
readonly property color textMuted: "#A0A0A0"
|
||||
readonly property color textOnFocus: "#101010"
|
||||
readonly property color textOnFocusMuted: "#505050"
|
||||
readonly property color accent: "#00A4DC"
|
||||
readonly property color accentAlt: "#AA5CC3"
|
||||
readonly property color error: "#FF5252"
|
||||
readonly property var avatarColors: ["#AA5CC3", "#00A4DC", "#E67E22", "#27AE60", "#C0392B", "#2C3E50"]
|
||||
|
||||
// Espacements
|
||||
readonly property int pageMargin: 48
|
||||
readonly property int spacingS: 8
|
||||
readonly property int spacingM: 16
|
||||
readonly property int spacingL: 24
|
||||
readonly property int spacingXL: 40
|
||||
|
||||
// Typographie
|
||||
readonly property int fontSmall: 14
|
||||
readonly property int fontBody: 18
|
||||
readonly property int fontTitle: 32
|
||||
readonly property int fontCode: 56
|
||||
|
||||
// Contrôles
|
||||
readonly property int controlHeight: 48
|
||||
readonly property int radius: 6
|
||||
readonly property int animFast: 120
|
||||
|
||||
// Couleur stable dérivée d'un nom (avatars, icônes de serveur).
|
||||
function avatarColor(name) {
|
||||
var hash = 0;
|
||||
for (var i = 0; i < name.length; i++)
|
||||
hash = (hash * 31 + name.charCodeAt(i)) % 100000;
|
||||
return avatarColors[hash % avatarColors.length];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
singleton Theme 1.0 Theme.qml
|
||||
@@ -0,0 +1,54 @@
|
||||
import QtQuick 2.5
|
||||
import "../Components"
|
||||
import "../Shared"
|
||||
import "../Shared/Remote.js" as Remote
|
||||
|
||||
// Écran d'accueil provisoire : confirme la connexion en attendant la vraie bibliothèque.
|
||||
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
|
||||
|
||||
// La pile a été réinitialisée à la connexion : on reconstruit Serveurs > Utilisateurs
|
||||
// pour revenir au choix de l'utilisateur.
|
||||
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).
|
||||
Keys.onPressed: {
|
||||
if (Remote.isBack(event.key)) {
|
||||
event.accepted = true;
|
||||
page.goBack();
|
||||
}
|
||||
}
|
||||
|
||||
Row {
|
||||
spacing: Theme.spacingM
|
||||
|
||||
FocusButton {
|
||||
id: backButton
|
||||
text: "Retour"
|
||||
KeyNavigation.right: logoutButton
|
||||
onClicked: page.goBack()
|
||||
}
|
||||
|
||||
FocusButton {
|
||||
id: logoutButton
|
||||
text: "Se déconnecter"
|
||||
KeyNavigation.left: backButton
|
||||
onClicked: {
|
||||
page.session.logout();
|
||||
page.goBack();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,75 +0,0 @@
|
||||
import QtQuick 2.5
|
||||
|
||||
Column {
|
||||
// Liste des labels et types
|
||||
property var fields: [
|
||||
{label: "Server", type: "text"},
|
||||
{label: "User", type: "text"},
|
||||
{label: "Password", type: "password"}
|
||||
]
|
||||
|
||||
property int currentIndex: 0
|
||||
|
||||
id: columnLogin
|
||||
|
||||
//anchors.centerIn: parent
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
anchors.margins: 20
|
||||
spacing: 15
|
||||
width: parent.width * 0.8
|
||||
|
||||
function updateSelection() {
|
||||
for (let i = 0; i < repeater.count; i++) {
|
||||
repeater.itemAt(i).color = i === columnLogin.currentIndex ? "lightblue" : "transparent";
|
||||
}
|
||||
}
|
||||
|
||||
// Repeater pour générer les champs basés sur la liste des labels et types
|
||||
Repeater {
|
||||
model: fields
|
||||
|
||||
Row {
|
||||
spacing: 10
|
||||
|
||||
Text {
|
||||
width: parent.width / 2 - 5
|
||||
text: modelData.label + ":"
|
||||
color: "white"
|
||||
font.pixelSize: 16
|
||||
}
|
||||
|
||||
// TextInput pour les champs Server et User, et mode Password pour Password
|
||||
Rectangle {
|
||||
width: 200
|
||||
height: 20
|
||||
color: "white"
|
||||
//border.color: "black"
|
||||
//border.width: 3
|
||||
//radius: 5
|
||||
|
||||
TextInput {
|
||||
font.pixelSize: 16
|
||||
color: "black"
|
||||
text: modelData.label
|
||||
|
||||
// Détermine le mode de saisie en fonction du type
|
||||
echoMode: modelData.type === "password" ? TextInput.Password : TextInput.Normal
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Keys.onPressed: {
|
||||
if (event.key === Qt.Key_Up) {
|
||||
if (currentIndex > 0) {
|
||||
currentIndex--;
|
||||
updateSelection();
|
||||
}
|
||||
} else if (event.key == Qt.Key_Down) {
|
||||
if (currentIndex < repeater.children.length - 1) {
|
||||
currentIndex++;
|
||||
updateSelection()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,141 @@
|
||||
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 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 = page.session.startQuickConnect();
|
||||
passwordModeButton.forceActiveFocus();
|
||||
} else {
|
||||
page.initialFocus.forceActiveFocus();
|
||||
}
|
||||
}
|
||||
|
||||
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: quickConnectButton
|
||||
onClicked: page.signIn()
|
||||
}
|
||||
|
||||
FocusButton {
|
||||
id: quickConnectButton
|
||||
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
|
||||
color: Theme.accent
|
||||
font.pixelSize: Theme.fontCode
|
||||
font.bold: true
|
||||
font.letterSpacing: 8
|
||||
}
|
||||
|
||||
Text {
|
||||
text: "En attente d'autorisation…"
|
||||
color: Theme.textMuted
|
||||
font.pixelSize: Theme.fontSmall
|
||||
}
|
||||
|
||||
FocusButton {
|
||||
id: passwordModeButton
|
||||
text: "Utiliser un mot de passe"
|
||||
onClicked: page.setQuickConnect(false)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
import QtQuick 2.5
|
||||
|
||||
// Display the logo
|
||||
Rectangle {
|
||||
width: parent.width
|
||||
height: parent.height
|
||||
|
||||
color: "#000B25"
|
||||
|
||||
Image {
|
||||
anchors.centerIn: parent
|
||||
source: "../icon.png"
|
||||
}
|
||||
}
|
||||
@@ -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 ? "Connexion…" : "Se connecter"
|
||||
KeyNavigation.up: portField
|
||||
onClicked: page.connect()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
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
|
||||
|
||||
delegate: ServerItem {
|
||||
width: serverList.width
|
||||
name: model.name
|
||||
address: model.address
|
||||
discovered: model.discovered
|
||||
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,104 @@
|
||||
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.
|
||||
Page {
|
||||
id: page
|
||||
|
||||
property var users: page.session ? page.session.publicUsers() : []
|
||||
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 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];
|
||||
if (user.hasPassword) {
|
||||
page.navigator.push("Login", { username: user.name });
|
||||
return;
|
||||
}
|
||||
// Compte sans mot de passe : connexion directe, comme sur Android TV.
|
||||
error = "";
|
||||
busy = true;
|
||||
page.session.authenticate(user.name, "", function (err) {
|
||||
page.busy = false;
|
||||
if (err) {
|
||||
page.error = err;
|
||||
return;
|
||||
}
|
||||
page.navigator.reset("Home");
|
||||
});
|
||||
}
|
||||
|
||||
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.error
|
||||
color: page.busy ? Theme.textMuted : Theme.error
|
||||
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")
|
||||
}
|
||||
}
|
||||
@@ -10,3 +10,23 @@ Cette application permet d'utiliser jellyfin sur la freebox.
|
||||
# Configurer un environement de travail
|
||||
[Documentation pour le SDK de la freebox](https://dev.freebox.fr/sdk/player.html).
|
||||
Pour Windows, [voir ce billet sur Github](https://github.com/fbx/freebox-qtcreator-plugin/issues/8).
|
||||
|
||||
## Aperçu sur PC (Linux)
|
||||
Sans Freebox, l'application tourne avec `qmlscene` (Qt 5) et la bibliothèque [libfbxqml](https://github.com/fbx/libfbxqml) :
|
||||
|
||||
```bash
|
||||
sudo apt install qmlscene qml-module-qtmultimedia qtdeclarative5-dev-tools
|
||||
git clone https://github.com/fbx/libfbxqml.git ../libfbxqml
|
||||
tools/run-local.sh # fenêtre 1280x720
|
||||
tools/run-local.sh --fullscreen # plein écran, comme sur la box
|
||||
```
|
||||
|
||||
## Tester sur la Freebox
|
||||
Activer le mode développeur du Player (menu Réglages, avec la télécommande), puis :
|
||||
|
||||
```bash
|
||||
tools/deploy.py # trouve le Player sur le réseau et lance l'app
|
||||
tools/deploy.py --box 192.168.0.21 # ou en donnant son adresse
|
||||
```
|
||||
|
||||
Le script sert les fichiers du projet au Player et affiche les logs de l'application. Il doit rester ouvert pendant le test (Ctrl+C pour arrêter).
|
||||
Executable
+182
@@ -0,0 +1,182 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Lance l'application sur un Freebox Player en mode développeur.
|
||||
|
||||
Reproduit le « Run » du plugin QtCreator Freebox (github.com/fbx/freebox-qtcreator-plugin) :
|
||||
1. trouve le Player sur le réseau local (SSDP, type « fbx:devel ») ou utilise --box ;
|
||||
2. sert le dossier du projet en HTTP (le Player y télécharge manifest.json et les QML) ;
|
||||
3. appelle la méthode JSON-RPC « debug_qml_app » sur http://<box>/pub/devel ;
|
||||
4. affiche stdout/stderr de l'application jusqu'à sa fermeture (ou Ctrl+C).
|
||||
|
||||
Usage : tools/deploy.py [--box 192.168.0.21] [--entry main] [--verbose] [--log deploy.log]
|
||||
La sortie est aussi écrite dans deploy.log (racine du projet), écrasé à chaque lancement.
|
||||
"""
|
||||
import argparse
|
||||
import functools
|
||||
import http.server
|
||||
import json
|
||||
import os
|
||||
import selectors
|
||||
import socket
|
||||
import sys
|
||||
import threading
|
||||
import time
|
||||
import urllib.request
|
||||
|
||||
PROJECT_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
||||
SSDP_ADDR = ("239.255.255.250", 1900)
|
||||
SSDP_TYPE = "fbx:devel"
|
||||
|
||||
|
||||
def discover(timeout=3.0):
|
||||
"""Renvoie l'adresse IP du premier Player en mode développeur qui répond."""
|
||||
request = (
|
||||
"M-SEARCH * HTTP/1.1\r\n"
|
||||
"HOST: 239.255.255.250:1900\r\n"
|
||||
'MAN: "ssdp:discover"\r\n'
|
||||
"MX: 1\r\n"
|
||||
"ST: %s\r\n\r\n" % SSDP_TYPE
|
||||
).encode()
|
||||
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM, socket.IPPROTO_UDP)
|
||||
sock.setsockopt(socket.IPPROTO_IP, socket.IP_MULTICAST_TTL, 2)
|
||||
sock.settimeout(timeout)
|
||||
try:
|
||||
sock.sendto(request, SSDP_ADDR)
|
||||
while True:
|
||||
data, (addr, _) = sock.recvfrom(4096)
|
||||
headers = data.decode(errors="replace").lower()
|
||||
if "st: %s" % SSDP_TYPE in headers or "nt: %s" % SSDP_TYPE in headers:
|
||||
return addr
|
||||
except socket.timeout:
|
||||
return None
|
||||
finally:
|
||||
sock.close()
|
||||
|
||||
|
||||
def local_ip_towards(box):
|
||||
"""Adresse de ce PC vue depuis le Player (interface utilisée pour le joindre)."""
|
||||
with socket.create_connection((box, 80), timeout=3) as sock:
|
||||
return sock.getsockname()[0]
|
||||
|
||||
|
||||
class QuietHandler(http.server.SimpleHTTPRequestHandler):
|
||||
verbose = False
|
||||
|
||||
def log_message(self, fmt, *args):
|
||||
if self.verbose:
|
||||
sys.stderr.write("[http] %s\n" % (fmt % args))
|
||||
|
||||
|
||||
def serve_project(bind_ip, verbose):
|
||||
QuietHandler.verbose = verbose
|
||||
handler = functools.partial(QuietHandler, directory=PROJECT_DIR)
|
||||
server = http.server.ThreadingHTTPServer((bind_ip, 0), handler)
|
||||
threading.Thread(target=server.serve_forever, daemon=True).start()
|
||||
return server
|
||||
|
||||
|
||||
def json_rpc(box, method, params):
|
||||
body = json.dumps({"jsonrpc": "2.0", "method": method, "params": params, "id": "0"}).encode()
|
||||
request = urllib.request.Request(
|
||||
"http://%s/pub/devel" % box, data=body, headers={"Content-Type": "application/json"}
|
||||
)
|
||||
with urllib.request.urlopen(request, timeout=15) as reply:
|
||||
answer = json.load(reply)
|
||||
if "error" in answer:
|
||||
raise RuntimeError(answer["error"].get("message", answer["error"]))
|
||||
return answer.get("result", {})
|
||||
|
||||
|
||||
def stream_output(box, stdout_port, stderr_port):
|
||||
"""Affiche la sortie de l'app ; se termine quand le Player ferme stdout (app quittée)."""
|
||||
selector = selectors.DefaultSelector()
|
||||
streams = {}
|
||||
for port, target in ((stdout_port, sys.stdout), (stderr_port, sys.stderr)):
|
||||
if port:
|
||||
sock = socket.create_connection((box, port), timeout=5)
|
||||
sock.settimeout(None)
|
||||
selector.register(sock, selectors.EVENT_READ)
|
||||
streams[sock] = target
|
||||
while streams:
|
||||
for key, _ in selector.select():
|
||||
sock = key.fileobj
|
||||
data = sock.recv(4096)
|
||||
if not data:
|
||||
selector.unregister(sock)
|
||||
sock.close()
|
||||
if streams.pop(sock) is sys.stdout:
|
||||
return
|
||||
continue
|
||||
streams[sock].write(data.decode(errors="replace"))
|
||||
streams[sock].flush()
|
||||
|
||||
|
||||
class Tee:
|
||||
"""Duplique un flux (stdout/stderr) dans le fichier de log."""
|
||||
|
||||
def __init__(self, stream, log):
|
||||
self.stream = stream
|
||||
self.log = log
|
||||
|
||||
def write(self, text):
|
||||
self.stream.write(text)
|
||||
self.stream.flush()
|
||||
self.log.write(text)
|
||||
self.log.flush()
|
||||
|
||||
def flush(self):
|
||||
self.stream.flush()
|
||||
self.log.flush()
|
||||
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(description=__doc__.splitlines()[0])
|
||||
parser.add_argument("--box", help="adresse IP du Player (sinon découverte SSDP)")
|
||||
parser.add_argument("--entry", default="main", help="entry point du manifest.json (défaut : main)")
|
||||
parser.add_argument("--verbose", action="store_true", help="affiche les fichiers téléchargés par le Player")
|
||||
parser.add_argument("--log", default=os.path.join(PROJECT_DIR, "deploy.log"),
|
||||
help="fichier de log, écrasé à chaque lancement (défaut : deploy.log ; vide pour désactiver)")
|
||||
args = parser.parse_args()
|
||||
|
||||
if args.log:
|
||||
log = open(args.log, "w", encoding="utf-8")
|
||||
log.write("# deploy.py %s\n" % time.strftime("%Y-%m-%d %H:%M:%S"))
|
||||
sys.stdout = Tee(sys.stdout, log)
|
||||
sys.stderr = Tee(sys.stderr, log)
|
||||
|
||||
box = args.box
|
||||
if not box:
|
||||
print("Recherche d'un Freebox Player en mode développeur…")
|
||||
box = discover()
|
||||
if not box:
|
||||
sys.exit("Aucun Player trouvé. Vérifiez le mode développeur, ou passez --box <IP>.")
|
||||
print("Player : %s" % box)
|
||||
|
||||
try:
|
||||
me = local_ip_towards(box)
|
||||
except OSError as error:
|
||||
sys.exit("Impossible de joindre %s:80 (%s)." % (box, error))
|
||||
|
||||
server = serve_project(me, args.verbose)
|
||||
port = server.server_address[1]
|
||||
manifest_url = "http://%s:%d/manifest.json" % (me, port)
|
||||
print("Projet servi sur %s" % manifest_url)
|
||||
|
||||
try:
|
||||
result = json_rpc(box, "debug_qml_app", {
|
||||
"manifest_url": manifest_url,
|
||||
"entry_point": args.entry,
|
||||
"wait": False,
|
||||
})
|
||||
print("Application lancée. Ctrl+C pour arrêter.\n")
|
||||
stream_output(box, result.get("stdout_port"), result.get("stderr_port"))
|
||||
print("\nApplication fermée sur le Player.")
|
||||
except KeyboardInterrupt:
|
||||
print("\nArrêt.")
|
||||
except Exception as error: # erreurs réseau ou JSON-RPC : message lisible
|
||||
sys.exit("Échec du lancement : %s" % error)
|
||||
finally:
|
||||
server.shutdown()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -0,0 +1,23 @@
|
||||
import QtQuick 2.5
|
||||
import QtQuick.Window 2.2
|
||||
|
||||
// Aperçu sur PC : charge Jellyfin.qml puis repasse la fenêtre en 1280x720
|
||||
// (fbx.application.Application force le plein écran au démarrage).
|
||||
QtObject {
|
||||
property var app: null
|
||||
|
||||
Component.onCompleted: {
|
||||
var component = Qt.createComponent("../Jellyfin.qml");
|
||||
if (component.status === Component.Error) {
|
||||
console.error(component.errorString());
|
||||
Qt.quit();
|
||||
return;
|
||||
}
|
||||
app = component.createObject(null);
|
||||
app.visibility = Window.Windowed;
|
||||
app.width = 1280;
|
||||
app.height = 720;
|
||||
app.color = "black";
|
||||
app.title = "Jellyfin (aperçu)";
|
||||
}
|
||||
}
|
||||
Executable
+17
@@ -0,0 +1,17 @@
|
||||
#!/usr/bin/env bash
|
||||
# Lance l'application sur le PC avec qmlscene (Qt 5) et libfbxqml.
|
||||
# Usage : tools/run-local.sh [--fullscreen]
|
||||
set -euo pipefail
|
||||
ROOT="$(cd "$(dirname "$0")/.." && pwd)"
|
||||
LIBFBXQML="${LIBFBXQML:-$ROOT/../libfbxqml}"
|
||||
QMLSCENE="${QMLSCENE:-$(command -v qmlscene || echo /usr/lib/qt5/bin/qmlscene)}"
|
||||
|
||||
if [ ! -d "$LIBFBXQML/fbx" ]; then
|
||||
echo "libfbxqml introuvable : git clone https://github.com/fbx/libfbxqml.git \"$LIBFBXQML\"" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ "${1:-}" = "--fullscreen" ]; then
|
||||
exec "$QMLSCENE" -I "$LIBFBXQML" "$ROOT/Jellyfin.qml"
|
||||
fi
|
||||
exec "$QMLSCENE" -I "$LIBFBXQML" "$ROOT/tools/preview.qml"
|
||||
Reference in new issue
Block a user