1
0
Fork 0
mirror of https://github.com/HenkKalkwater/harbour-sailfin.git synced 2025-09-05 18:22:46 +00:00

Rewire more of Sailfish frontend into new backend

This should encompass most simple things, besides some larger, trickier
things, like the video streams and the now-broken userdata
This commit is contained in:
Chris Josten 2021-08-11 23:35:33 +02:00
parent df1e134821
commit 7b6c272aa9
47 changed files with 620 additions and 291 deletions

View file

@ -22,7 +22,7 @@ import Sailfish.Silica 1.0
import nl.netsoj.chris.Jellyfin 1.0 as J
import "../../components"
import "../.."
import "../../"
/**
* This page displays details about a film, show, season, episode, and so on.
@ -34,8 +34,6 @@ Page {
id: pageRoot
property string itemId: ""
property alias itemData: jItemLoader.data
//property string itemId: ""
//property var itemData: ({})
property bool _loading: jItemLoader.status === J.ItemLoader.Loading
readonly property bool hasLogo: (typeof itemData.imageTags !== "undefined") && (typeof itemData.imageTags["Logo"] !== "undefined")
property string _chosenBackdropImage: ""
@ -46,10 +44,10 @@ Page {
if (itemData.backdropImageTags.length > 0) {
rand = Math.floor(Math.random() * (itemData.backdropImageTags.length - 0.001))
console.log("Random: ", rand)
_chosenBackdropImage = ApiClient.baseUrl + "/Items/" + itemId + "/Images/Backdrop/" + rand + "?tag=" +itemData.backdropImageTags[rand] + "&maxHeight" + height
_chosenBackdropImage = apiClient.baseUrl + "/Items/" + itemId + "/Images/Backdrop/" + rand + "?tag=" +itemData.backdropImageTags[rand] + "&maxHeight" + height
} else if (itemData.parentBackdropImageTags.length > 0) {
rand = Math.floor(Math.random() * (itemData.parentBackdropImageTags.length - 0.001))
_chosenBackdropImage = ApiClient.baseUrl + "/Items/" + itemData.parentBackdropItemId + "/Images/Backdrop/" + rand + "?tag=" + itemData.parentBackdropImageTags[0]
_chosenBackdropImage = apiClient.baseUrl + "/Items/" + itemData.parentBackdropItemId + "/Images/Backdrop/" + rand + "?tag=" + itemData.parentBackdropImageTags[0]
}
}
@ -86,8 +84,9 @@ Page {
J.ItemLoader {
id: jItemLoader
apiClient: ApiClient
apiClient: appWindow.apiClient
itemId: pageRoot.itemId
autoReload: false
onStatusChanged: {
console.log("Status changed: " + newStatus, JSON.stringify(jItemLoader.data))
if (status === J.ItemLoader.Ready) {
@ -96,15 +95,13 @@ Page {
}
}
Label {
text: "ItemLoader status=%1, \nitemId=%2\nitemData=%3".arg(jItemLoader.status).arg(jItemLoader.itemId).arg(jItemLoader.data)
}
onStatusChanged: {
if (status == PageStatus.Deactivating) {
if (status === PageStatus.Deactivating) {
//appWindow.itemData = ({})
}
if (status == PageStatus.Active) {
if (status === PageStatus.Active) {
console.log("Page ready, ItemID: ", itemId, ", UserID: ", apiClient.userId)
jItemLoader.autoReload = true
//appWindow.itemData = jItemLoader.data
}
}

View file

@ -29,10 +29,13 @@ BaseDetailPage {
J.ItemModel {
id: collectionModel
//sortBy: ["SortName"]
loader: J.UserItemsLoader {
apiClient: ApiClient
id: collectionLoader
apiClient: appWindow.apiClient
parentId: itemData.jellyfinId
autoReload: itemData.jellyfinId.length > 0
onParentIdChanged: if (parentId.length > 0) reload()
sortBy: "SortName"
}
}
@ -61,7 +64,7 @@ BaseDetailPage {
RemoteImage {
id: itemImage
anchors.fill: parent
source: Utils.itemModelImageUrl(ApiClient.baseUrl, model.jellyfinId, model.imageTags.Primary, "Primary", {"maxWidth": width})
source: Utils.itemModelImageUrl(apiClient.baseUrl, model.jellyfinId, model.imageTags.Primary, "Primary", {"maxWidth": width})
blurhash: model.imageBlurHashes.Primary[model.imageTags.Primary]
fallbackColor: Utils.colorFromString(model.name)
fillMode: Image.PreserveAspectCrop
@ -138,20 +141,20 @@ BaseDetailPage {
MenuItem {
//: Sort order
text: qsTr("Ascending")
onClicked: apply(model.value, ApiModel.Ascending)
onClicked: apply(model.value, "Ascending")
}
MenuItem {
//: Sort order
text: qsTr("Descending")
onClicked: apply(model.value, ApiModel.Descending)
onClicked: apply(model.value, "Descending")
}
}
onClicked: openMenu()
function apply(field, order) {
collectionModel.sortBy = [field];
collectionModel.sortOrder = order;
collectionModel.reload()
collectionLoader.sortBy = field;
collectionLoader.sortOrder = order;
collectionLoader.reload()
pageStack.pop()
}
}

View file

@ -36,11 +36,12 @@ BaseDetailPage {
J.ItemModel {
id: collectionModel
loader: J.UserItemsLoader {
apiClient: ApiClient
//sortBy: ["SortName"]
apiClient: appWindow.apiClient
sortBy: "SortName"
//fields: ["ItemCounts","PrimaryImageAspectRatio","BasicSyncInfo","CanDelete","MediaSourceCount"]
parentId: itemData.jellyfinId
onParentIdChanged: reload()
autoReload: itemData.jellyfinId.length > 0
onParentIdChanged: if (parentId.length > 0) reload()
}
}
RowLayout {
@ -52,9 +53,9 @@ BaseDetailPage {
visible: _twoColumns
Layout.minimumWidth: 1000 / Theme.pixelRatio
Layout.fillHeight: true
/*source: visible
source: visible
? "../../components/music/WideAlbumCover.qml" : ""
onLoaded: bindAlbum(item)*/
onLoaded: bindAlbum(item)
}
Item {height: 1; width: Theme.horizontalPageMargin; visible: wideAlbumCover.visible; }
SilicaListView {
@ -64,8 +65,8 @@ BaseDetailPage {
model: collectionModel
header: Loader {
width: parent.width
/*source: "../../components/music/NarrowAlbumCover.qml"
onLoaded: bindAlbum(item)*/
source: "../../components/music/NarrowAlbumCover.qml"
onLoaded: bindAlbum(item)
}
section {
property: "parentIndexNumber"
@ -79,7 +80,7 @@ BaseDetailPage {
artists: model.artists
duration: model.runTimeTicks
indexNumber: model.indexNumber
onClicked: window.playbackManager.playItem(model.jellyfinId)
onClicked: window.playbackManager.playItemInList(collectionModel, model.index)
}
VerticalScrollDecorator {}
@ -87,7 +88,7 @@ BaseDetailPage {
}
function bindAlbum(item) {
//item.albumArt = Qt.binding(function(){ return Utils.itemImageUrl(ApiClient.baseUrl, itemData, "Primary", {"maxWidth": parent.width})})
item.albumArt = Qt.binding(function(){ return Utils.itemImageUrl(apiClient.baseUrl, itemData, "Primary", {"maxWidth": parent.width})})
item.name = Qt.binding(function(){ return itemData.name})
item.releaseYear = Qt.binding(function() { return itemData.productionYear})
item.albumArtist = Qt.binding(function() { return itemData.albumArtist})

View file

@ -1,7 +1,7 @@
import QtQuick 2.6
import Sailfish.Silica 1.0
import nl.netsoj.chris.Jellyfin 1.0
import nl.netsoj.chris.Jellyfin 1.0 as J
import "../../components"
@ -21,7 +21,7 @@ BaseDetailPage {
RemoteImage {
id: image
source: ApiClient.downloadUrl(itemId)
source: apiClient.downloadUrl(itemId)
fillMode: Image.PreserveAspectFit
anchors.fill: parent

View file

@ -19,19 +19,22 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
import QtQuick 2.6
import Sailfish.Silica 1.0
import nl.netsoj.chris.Jellyfin 1.0
import nl.netsoj.chris.Jellyfin 1.0 as J
import "../.."
import "../../components"
import ".."
BaseDetailPage {
ShowEpisodesModel {
J.ItemModel {
id: episodeModel
apiClient: ApiClient
show: itemData.seriesId
seasonId: itemData.jellyfinId
fields: ["Overview"]
loader: J.ShowEpisodesLoader {
apiClient: appWindow.apiClient
seriesId: itemData.seriesId
seasonId: itemData.jellyfinId
fields: [J.ItemFields.Overview]
autoReload: itemData.jellyfinId.length > 0
}
}
Connections {
@ -42,7 +45,7 @@ BaseDetailPage {
SilicaListView {
anchors.fill: parent
contentHeight: content.height
visible: itemData.status !== JellyfinItem.Error
//visible: itemData.status !== JellyfinItem.Error
header: PageHeader {
title: itemData.name
@ -60,7 +63,7 @@ BaseDetailPage {
}
width: Constants.libraryDelegateWidth
height: Constants.libraryDelegateHeight
source: Utils.itemModelImageUrl(ApiClient.baseUrl, model.jellyfinId, model.imageTags.Primary, "Primary", {"maxHeight": height})
source: Utils.itemModelImageUrl(apiClient.baseUrl, model.jellyfinId, model.imageTags.Primary, "Primary", {"maxHeight": height})
blurhash: model.imageBlurHashes.Primary[model.imageTags.Primary]
fillMode: Image.PreserveAspectCrop
clip: true
@ -157,8 +160,8 @@ BaseDetailPage {
onStatusChanged: {
if (status == PageStatus.Active) {
//console.log(JSON.stringify(itemData))
episodeModel.show = itemData.seriesId
episodeModel.seasonId = itemData.jellyfinId
//episodeModel.show = itemData.seriesId
//episodeModel.seasonId = itemData.jellyfinId
}
}
}

View file

@ -19,7 +19,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
import QtQuick 2.6
import Sailfish.Silica 1.0
import nl.netsoj.chris.Jellyfin 1.0
import nl.netsoj.chris.Jellyfin 1.0 as J
import "../../components"
import "../.."
@ -28,7 +28,7 @@ BaseDetailPage {
SilicaFlickable {
anchors.fill: parent
contentHeight: content.height
visible: itemData.status !== JellyfinItem.Error
//visible: itemData.status !== JellyfinItem.Error
Column {
id: content
@ -47,7 +47,7 @@ BaseDetailPage {
RemoteImage {
id: logoImage
anchors.centerIn: parent
source: Utils.itemImageUrl(ApiClient.baseUrl, itemData, "Logo")
source: Utils.itemImageUrl(apiClient.baseUrl, itemData, "Logo")
}
}
@ -63,11 +63,14 @@ BaseDetailPage {
text: qsTr("Seasons")
}
ShowSeasonsModel {
J.ItemModel {
id: showSeasonsModel
apiClient: ApiClient
show: itemData.jellyfinId
onShowChanged: reload()
loader: J.ShowSeasonsLoader {
id: showSeasonLoader
apiClient: appWindow.apiClient
seriesId: itemData.jellyfinId
autoReload: itemData.jellyfinId.length > 0
}
}
Connections {
target: itemData
@ -84,7 +87,7 @@ BaseDetailPage {
leftMargin: Theme.horizontalPageMargin
rightMargin: Theme.horizontalPageMargin
delegate: LibraryItemDelegate {
poster: Utils.itemModelImageUrl(ApiClient.baseUrl, model.jellyfinId, model.imageTags.Primary, "Primary", {"maxHeight": height})
poster: Utils.itemModelImageUrl(apiClient.baseUrl, model.jellyfinId, model.imageTags.Primary, "Primary", {"maxHeight": height})
blurhash: model.imageBlurHashes["Primary"][model.imageTags.Primary]
title: model.name
onClicked: pageStack.push(Utils.getPageUrl(model.mediaType, model.type), {"itemId": model.jellyfinId})

View file

@ -31,7 +31,7 @@ BaseDetailPage {
enabled: true
text: qsTr("Item type (%1) unsupported").arg(itemData.type)
hintText: qsTr("This is still an alpha version :)")
hintText: qsTr("Fallback page for %2 not found either\nThis is still an alpha version :)").arg(itemData.mediaType)
}
}
}

View file

@ -55,7 +55,7 @@ BaseDetailPage {
PlayToolbar {
id: toolbar
width: parent.width
imageSource: Utils.itemImageUrl(ApiClient.baseUrl, itemData, "Primary", {"maxWidth": parent.width})
imageSource: Utils.itemImageUrl(apiClient.baseUrl, itemData, "Primary", {"maxWidth": parent.width})
imageAspectRatio: Constants.horizontalVideoAspectRatio
imageBlurhash: itemData.imageBlurHashes["Primary"][itemData.imageTags["Primary"]]
Binding on favourited {