From e838fcc8a1552d6797c8597b5c38c6ef1f92c922 Mon Sep 17 00:00:00 2001 From: Chris Josten Date: Sat, 10 Oct 2020 17:28:13 +0200 Subject: [PATCH] Added very simple photo viewer --- core/include/jellyfinapiclient.h | 1 + core/src/jellyfinapiclient.cpp | 4 +++ harbour-sailfin.pro | 3 ++ sailfish/qml/Utils.js | 2 ++ sailfish/qml/components/VideoPlayer.qml | 6 +--- sailfish/qml/pages/itemdetails/PhotoPage.qml | 35 ++++++++++++++++++++ 6 files changed, 46 insertions(+), 5 deletions(-) create mode 100644 sailfish/qml/pages/itemdetails/PhotoPage.qml diff --git a/core/include/jellyfinapiclient.h b/core/include/jellyfinapiclient.h index 23da369..5dcb5a0 100644 --- a/core/include/jellyfinapiclient.h +++ b/core/include/jellyfinapiclient.h @@ -179,6 +179,7 @@ public slots: * @brief Shares the capabilities of this device to the server. */ void postCapabilities(); + QString downloadUrl(const QString &itemId) const; protected slots: void defaultNetworkErrorHandler(QNetworkReply::NetworkError error); diff --git a/core/src/jellyfinapiclient.cpp b/core/src/jellyfinapiclient.cpp index b3f6c47..d993600 100644 --- a/core/src/jellyfinapiclient.cpp +++ b/core/src/jellyfinapiclient.cpp @@ -248,6 +248,10 @@ void ApiClient::postCapabilities() { setDefaultErrorHandler(rep); } +QString ApiClient::downloadUrl(const QString &itemId) const { + return m_baseUrl + "/Items/" + itemId + "/Download?api_key=" + this->m_token; +} + void ApiClient::generateDeviceProfile() { QJsonObject root = DeviceProfile::generateProfile(); m_playbackDeviceProfile = QJsonObject(root); diff --git a/harbour-sailfin.pro b/harbour-sailfin.pro index 785d1ad..3578948 100644 --- a/harbour-sailfin.pro +++ b/harbour-sailfin.pro @@ -22,4 +22,7 @@ message($$SUBDIRS) # modify the localized app name in the the .desktop file. # TRANSLATIONS += \ +DISTFILES += \ + sailfish/qml/pages/itemdetails/PhotoPage.qml + diff --git a/sailfish/qml/Utils.js b/sailfish/qml/Utils.js index 229e81d..060bda1 100644 --- a/sailfish/qml/Utils.js +++ b/sailfish/qml/Utils.js @@ -86,6 +86,8 @@ function getPageUrl(mediaType, itemType) { return Qt.resolvedUrl("pages/itemdetails/CollectionPage.qml") case "video": return Qt.resolvedUrl("pages/itemdetails/VideoPage.qml") + case "photo": + return Qt.resolvedUrl("pages/itemdetails/PhotoPage.qml") default: return Qt.resolvedUrl("pages/itemdetails/UnsupportedPage.qml") } diff --git a/sailfish/qml/components/VideoPlayer.qml b/sailfish/qml/components/VideoPlayer.qml index 5029075..146bda4 100644 --- a/sailfish/qml/components/VideoPlayer.qml +++ b/sailfish/qml/components/VideoPlayer.qml @@ -41,14 +41,10 @@ SilicaItem { property alias subtitleTrack: mediaSource.subtitleIndex property real startTicks: 0 - // 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" + color: Theme.overlayBackgroundColor } PlaybackManager { diff --git a/sailfish/qml/pages/itemdetails/PhotoPage.qml b/sailfish/qml/pages/itemdetails/PhotoPage.qml new file mode 100644 index 0000000..581ce7d --- /dev/null +++ b/sailfish/qml/pages/itemdetails/PhotoPage.qml @@ -0,0 +1,35 @@ +import QtQuick 2.6 +import Sailfish.Silica 1.0 + +import nl.netsoj.chris.Jellyfin 1.0 + +BaseDetailPage { + id: pageRoot + navigationStyle: PageNavigation.Vertical + + Rectangle { + anchors.fill: parent + color: Theme.overlayBackgroundColor + } + + PageHeader { + title: itemData.name + titleColor: Theme.primaryColor + } + + Image { + id: image + source: ApiClient.downloadUrl(itemId) + fillMode: Image.PreserveAspectFit + anchors.fill: parent + + opacity: status == Image.Ready ? 1.0 : 0.0 + Behavior on opacity { FadeAnimator {}} + } + + BusyIndicator { + running: image.status == Image.Loading + size: BusyIndicatorSize.Large + anchors.centerIn: parent + } +}