From 1eb6a8fb5dbbde6b639879552adfe8a271473ebb Mon Sep 17 00:00:00 2001 From: Chris Josten Date: Fri, 25 Sep 2020 15:21:08 +0200 Subject: [PATCH] Added comments and general cleanup on qml files --- harbour-sailfin.pro | 2 + qml/components/GlassyBackground.qml | 5 ++- qml/components/LibraryItemDelegate.qml | 3 ++ qml/components/RemoteImage.qml | 3 ++ qml/components/VideoPlayer.qml | 17 +++++++- qml/components/itemdetails/EpisodeDetails.qml | 5 +++ qml/components/itemdetails/SeasonDetails.qml | 5 +++ qml/components/videoplayer/VideoHud.qml | 4 ++ qml/cover/VideoCover.qml | 1 + qml/harbour-sailfin.qml | 16 ++------ qml/pages/DetailPage.qml | 8 +++- qml/pages/LegalPage.qml | 8 +++- qml/pages/MainPage.qml | 41 ++++++++----------- qml/pages/VideoPage.qml | 17 ++++---- qml/pages/setup/AddServerConnectingPage.qml | 3 ++ qml/pages/setup/AddServerPage.qml | 5 +++ qml/pages/setup/LoginDialog.qml | 5 +++ 17 files changed, 101 insertions(+), 47 deletions(-) create mode 100644 qml/components/itemdetails/EpisodeDetails.qml create mode 100644 qml/components/itemdetails/SeasonDetails.qml diff --git a/harbour-sailfin.pro b/harbour-sailfin.pro index 4da3673..eb44f57 100644 --- a/harbour-sailfin.pro +++ b/harbour-sailfin.pro @@ -33,7 +33,9 @@ DISTFILES += \ qml/components/RemoteImage.qml \ qml/components/UserGridDelegate.qml \ qml/components/VideoPlayer.qml \ + qml/components/itemdetails/EpisodeDetails.qml \ qml/components/itemdetails/FilmDetails.qml \ + qml/components/itemdetails/SeasonDetails.qml \ qml/components/itemdetails/SeriesDetails.qml \ qml/components/videoplayer/VideoHud.qml \ qml/cover/CoverPage.qml \ diff --git a/qml/components/GlassyBackground.qml b/qml/components/GlassyBackground.qml index ae6fde4..cb2fcf8 100644 --- a/qml/components/GlassyBackground.qml +++ b/qml/components/GlassyBackground.qml @@ -2,6 +2,9 @@ import QtQuick 2.6 import Sailfish.Silica 1.0 import QtGraphicalEffects 1.0 +/** + * A silica-like background for displaying backdrops. + */ Rectangle { property alias source: backgroundImage.source property alias sourceSize: backgroundImage.sourceSize @@ -10,7 +13,7 @@ Rectangle { color: Theme.colorScheme == Theme.DarkOnLight ? "#fff" : "#000" z: -1 opacity: status == Image.Ready ? 1.0 : 0.0 - Behavior on opacity { NumberAnimation { duration: 300 } } + Behavior on opacity { FadeAnimator {} } Image { id: backgroundImage diff --git a/qml/components/LibraryItemDelegate.qml b/qml/components/LibraryItemDelegate.qml index a7a3e07..efa99d4 100644 --- a/qml/components/LibraryItemDelegate.qml +++ b/qml/components/LibraryItemDelegate.qml @@ -1,6 +1,9 @@ import QtQuick 2.6 import Sailfish.Silica 1.0 +/** + * Delegate for displaying an item in the library. + */ BackgroundItem { id: root property alias poster: posterImage.source diff --git a/qml/components/RemoteImage.qml b/qml/components/RemoteImage.qml index e3be379..255e212 100644 --- a/qml/components/RemoteImage.qml +++ b/qml/components/RemoteImage.qml @@ -1,6 +1,9 @@ import QtQuick 2.6 import Sailfish.Silica 1.0 +/** + * An image for "remote" images (loaded over e.g. http), with a spinner and a fallback image + */ Image { property string fallbackImage property bool usingFallbackImage diff --git a/qml/components/VideoPlayer.qml b/qml/components/VideoPlayer.qml index 311fb18..5ccd748 100644 --- a/qml/components/VideoPlayer.qml +++ b/qml/components/VideoPlayer.qml @@ -6,7 +6,11 @@ import nl.netsoj.chris.Jellyfin 1.0 import "videoplayer" -Item { +/** + * A videoPlayer for Jellyfin videos + */ + +SilicaItem { id: playerRoot property string itemId property string title @@ -15,6 +19,17 @@ Item { property MediaPlayer player readonly property bool hudVisible: !hud.hidden + // Force a Light on Dark theme since I doubt that there are persons who are willing to watch a Video + // on a white background. + palette.colorScheme: Theme.LightOnDark + + // Blackground to prevent the ambience from leaking through + Rectangle { + anchors.fill: parent + color: "black" + } + + MediaSource { id: mediaSource apiClient: ApiClient diff --git a/qml/components/itemdetails/EpisodeDetails.qml b/qml/components/itemdetails/EpisodeDetails.qml new file mode 100644 index 0000000..9c36e13 --- /dev/null +++ b/qml/components/itemdetails/EpisodeDetails.qml @@ -0,0 +1,5 @@ +import QtQuick 2.0 + +Item { + +} diff --git a/qml/components/itemdetails/SeasonDetails.qml b/qml/components/itemdetails/SeasonDetails.qml new file mode 100644 index 0000000..9c36e13 --- /dev/null +++ b/qml/components/itemdetails/SeasonDetails.qml @@ -0,0 +1,5 @@ +import QtQuick 2.0 + +Item { + +} diff --git a/qml/components/videoplayer/VideoHud.qml b/qml/components/videoplayer/VideoHud.qml index fa9bcdf..cf77b6c 100644 --- a/qml/components/videoplayer/VideoHud.qml +++ b/qml/components/videoplayer/VideoHud.qml @@ -2,6 +2,10 @@ import QtQuick 2.6 import QtMultimedia 5.6 import Sailfish.Silica 1.0 +/** + * The video "hud" or controls. This is the overlay displayed over a video player, which contains controls + * and playback information. + */ Item { id: videoHud property MediaPlayer player diff --git a/qml/cover/VideoCover.qml b/qml/cover/VideoCover.qml index 8530d9c..c34bf2b 100644 --- a/qml/cover/VideoCover.qml +++ b/qml/cover/VideoCover.qml @@ -9,6 +9,7 @@ CoverBackground { anchors.fill: parent color: "black" + // Wanted to display the currently running move on here, but it's hard :/ /*VideoOutput { id: coverOutput anchors.fill: parent diff --git a/qml/harbour-sailfin.qml b/qml/harbour-sailfin.qml index 9105ff3..a3691b3 100644 --- a/qml/harbour-sailfin.qml +++ b/qml/harbour-sailfin.qml @@ -11,10 +11,12 @@ ApplicationWindow { id: appWindow property bool isInSetup: false property bool _hasInitialized: false + // The global mediaPlayer instance readonly property MediaPlayer mediaPlayer: _mediaPlayer + // Data of the currently selected item. For use on the cover. property var itemData - //property alias backdrop: backdrop + //FIXME: proper error handling Connections { target: ApiClient onNetworkError: errorNotification.show("Network error: " + error) @@ -27,21 +29,11 @@ ApplicationWindow { autoPlay: true } - /*GlassyBackground { - id: backdrop - anchors.fill: parent - opacity: status == Image.Ready ? 1.0 : 0.0 - Behavior on opacity { NumberAnimation { duration: 300 } } - - function clear() { - source = "" - } - }*/ - initialPage: Component { MainPage { Connections { target: ApiClient + // Replace the MainPage if no server was set up. onSetupRequired: { if (!isInSetup) { isInSetup = true; diff --git a/qml/pages/DetailPage.qml b/qml/pages/DetailPage.qml index 7db26b4..c2c866f 100644 --- a/qml/pages/DetailPage.qml +++ b/qml/pages/DetailPage.qml @@ -4,8 +4,14 @@ import Sailfish.Silica 1.0 import nl.netsoj.chris.Jellyfin 1.0 import "../components" -import "../compontents/details" +import "../components/itemdetails" +/** + * This page displays details about a film, show, season, episode, and so on. + * + * It contains the common functionality for all items. Additional components are + * loaded in for every specific type of items, from ../components/itemdetails. + */ Page { id: pageRoot property string itemId: "" diff --git a/qml/pages/LegalPage.qml b/qml/pages/LegalPage.qml index 8e63de4..04aeed7 100644 --- a/qml/pages/LegalPage.qml +++ b/qml/pages/LegalPage.qml @@ -4,6 +4,12 @@ import Sailfish.Silica 1.0 import "../components" +/** + * This page contains legal information about snippets and 3rd party libraries. + * + * Displaying them is done by loading ../3rdparty.xml, which contains a list of all + * the included snippets/libraries and their licenses. + */ Page { allowedOrientations: Orientation.All @@ -32,7 +38,7 @@ Page { } PlainLabel { - text: qsTr("The Sailfin application contains some code from other projects. Without them, Sailfin would " + + text: qsTr("Sailfin contains code taken from other projects. Without them, Sailfin would " + "not be possible!") } diff --git a/qml/pages/MainPage.qml b/qml/pages/MainPage.qml index e67908b..f28f846 100644 --- a/qml/pages/MainPage.qml +++ b/qml/pages/MainPage.qml @@ -5,31 +5,15 @@ import nl.netsoj.chris.Jellyfin 1.0 import "../components" -// Test +/** + * Main page, which simply shows some content of every library, as well as next items. + */ Page { - id: page + property bool _modelsLoaded: false - // The effective value will be restricted by ApplicationWindow.allowedOrientations + id: page allowedOrientations: Orientation.All - property bool _modelsLoaded: false - - Connections { - target: ApiClient - onAuthenticatedChanged: { - if (authenticated && !_modelsLoaded) loadModels(); - } - - - } - - Component.onCompleted: { - if (ApiClient.authenticated && _modelsLoaded) { - loadModels(); - } - } - - // To enable PullDownMenu, place our content in a SilicaFlickable SilicaFlickable { anchors.fill: parent @@ -48,7 +32,6 @@ Page { // Tell SilicaFlickable the height of its content. contentHeight: column.height - // Place our content in a Column. The PageHeader is always placed at the top // of the page, followed by our content. Column { @@ -120,7 +103,19 @@ Page { } } } - + + Connections { + target: ApiClient + onAuthenticatedChanged: { + if (authenticated && !_modelsLoaded) loadModels(); + } + } + + Component.onCompleted: { + if (ApiClient.authenticated && _modelsLoaded) { + loadModels(); + } + } function loadModels() { _modelsLoaded = true; mediaLibraryModel.reload() diff --git a/qml/pages/VideoPage.qml b/qml/pages/VideoPage.qml index 8e7f2b9..d67b37d 100644 --- a/qml/pages/VideoPage.qml +++ b/qml/pages/VideoPage.qml @@ -3,30 +3,31 @@ import Sailfish.Silica 1.0 import "../components" +/** + * Page only containing a video player. + * + * On larger devices the video player could potentially be embedded somewhere else. + */ + Page { id: videoPage property string itemId property var itemData allowedOrientations: Orientation.All - palette.colorScheme: Theme.LightOnDark showNavigationIndicator: videoPlayer.hudVisible - Rectangle { - anchors.fill: parent - color: "black" - } - VideoPlayer { id: videoPlayer anchors.fill: parent itemId: videoPage.itemId + player: appWindow.mediaPlayer + title: itemData.Name + onLandscapeChanged: { console.log("Is landscape: " + landscape) //appWindow.orientation = landscape ? Orientation.Landscape : Orientation.Portrait videoPage.allowedOrientations = landscape ? Orientation.LandscapeMask : Orientation.PortraitMask } - player: appWindow.mediaPlayer - title: itemData.Name } onStatusChanged: { diff --git a/qml/pages/setup/AddServerConnectingPage.qml b/qml/pages/setup/AddServerConnectingPage.qml index 363f7f2..14112eb 100644 --- a/qml/pages/setup/AddServerConnectingPage.qml +++ b/qml/pages/setup/AddServerConnectingPage.qml @@ -2,6 +2,9 @@ import QtQuick 2.6 import Sailfish.Silica 1.0 import nl.netsoj.chris.Jellyfin 1.0 +/** + * Page to indicate that the application is connecting to a server. + */ Page { property string serverName property string serverAddress diff --git a/qml/pages/setup/AddServerPage.qml b/qml/pages/setup/AddServerPage.qml index 701ae92..de1368f 100644 --- a/qml/pages/setup/AddServerPage.qml +++ b/qml/pages/setup/AddServerPage.qml @@ -2,6 +2,11 @@ import QtQuick 2.6 import Sailfish.Silica 1.0 import nl.netsoj.chris.Jellyfin 1.0 +/** + * Dialog showed when the user has to connect to a Jellyfin server. + * + * This dialog allows manual address entry or use one of the addresses discovered via UDP broadcasts. + */ Dialog { id: dialogRoot allowedOrientations: Orientation.All diff --git a/qml/pages/setup/LoginDialog.qml b/qml/pages/setup/LoginDialog.qml index de4df34..ee9bc73 100644 --- a/qml/pages/setup/LoginDialog.qml +++ b/qml/pages/setup/LoginDialog.qml @@ -4,6 +4,11 @@ import nl.netsoj.chris.Jellyfin 1.0 import "../../components" +/** + * Page where the user can login on their server. Is displayed after the AddServerPage successfully connected + * to a Jellyfin server. This page also displays a login message and, if applicable, a list of public users. + */ + Dialog { property string loginMessage property Page firstPage