2020-09-15 14:53:13 +00:00
|
|
|
import QtQuick 2.0
|
|
|
|
import Sailfish.Silica 1.0
|
|
|
|
|
|
|
|
import nl.netsoj.chris.Jellyfin 1.0
|
|
|
|
|
|
|
|
import "../components"
|
2020-09-26 00:51:37 +00:00
|
|
|
import "../"
|
|
|
|
import "../Utils.js" as Utils
|
2020-09-15 14:53:13 +00:00
|
|
|
|
2020-09-25 13:21:08 +00:00
|
|
|
/**
|
|
|
|
* Main page, which simply shows some content of every library, as well as next items.
|
|
|
|
*/
|
2020-09-15 14:53:13 +00:00
|
|
|
Page {
|
2020-09-25 13:21:08 +00:00
|
|
|
property bool _modelsLoaded: false
|
2020-09-15 14:53:13 +00:00
|
|
|
|
2020-09-25 13:21:08 +00:00
|
|
|
id: page
|
2020-09-15 14:53:13 +00:00
|
|
|
allowedOrientations: Orientation.All
|
|
|
|
|
|
|
|
SilicaFlickable {
|
|
|
|
anchors.fill: parent
|
|
|
|
|
|
|
|
// PullDownMenu and PushUpMenu must be declared in SilicaFlickable, SilicaListView or SilicaGridView
|
|
|
|
PullDownMenu {
|
|
|
|
MenuItem {
|
|
|
|
text: qsTr("About")
|
2020-09-26 00:51:37 +00:00
|
|
|
onClicked: pageStack.push(Qt.resolvedUrl("AboutPage.qml"))
|
2020-09-15 14:53:13 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// 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 {
|
|
|
|
id: column
|
|
|
|
|
|
|
|
width: page.width
|
|
|
|
//spacing: Theme.paddingLarge
|
|
|
|
UserViewModel {
|
|
|
|
id: mediaLibraryModel2
|
|
|
|
apiClient: ApiClient
|
|
|
|
}
|
|
|
|
|
|
|
|
MoreSection {
|
2020-09-26 00:51:37 +00:00
|
|
|
text: qsTr("Resume watching")
|
|
|
|
clickable: false
|
2020-09-15 14:53:13 +00:00
|
|
|
}
|
|
|
|
MoreSection {
|
2020-09-26 00:51:37 +00:00
|
|
|
text: qsTr("Next up")
|
|
|
|
clickable: false
|
2020-09-15 14:53:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
UserViewModel {
|
|
|
|
id: mediaLibraryModel
|
|
|
|
apiClient: ApiClient
|
|
|
|
}
|
|
|
|
Repeater {
|
|
|
|
model: mediaLibraryModel
|
|
|
|
MoreSection {
|
|
|
|
text: model.name
|
|
|
|
busy: userItemModel.status != ApiModel.Ready
|
2020-09-26 00:51:37 +00:00
|
|
|
property string collectionType: model.collectionType
|
|
|
|
|
|
|
|
onHeaderClicked: pageStack.push(Qt.resolvedUrl("DetailPage.qml"), {"itemId": model.id})
|
2020-09-15 14:53:13 +00:00
|
|
|
|
|
|
|
SilicaListView {
|
|
|
|
clip: true
|
2020-09-26 00:51:37 +00:00
|
|
|
height: {
|
|
|
|
if (count > 0) {
|
|
|
|
console.log(collectionType)
|
|
|
|
if (["tvshows", "movies"].indexOf(collectionType) == -1) {
|
|
|
|
Constants.libraryDelegateHeight
|
|
|
|
} else {
|
|
|
|
Constants.libraryDelegatePosterHeight
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
0
|
|
|
|
}
|
|
|
|
}
|
2020-09-15 14:53:13 +00:00
|
|
|
Behavior on height {
|
|
|
|
NumberAnimation { duration: 300 }
|
|
|
|
}
|
|
|
|
width: parent.width
|
|
|
|
model: userItemModel
|
|
|
|
orientation: ListView.Horizontal
|
2020-09-26 00:51:37 +00:00
|
|
|
leftMargin: Theme.horizontalPageMargin
|
|
|
|
rightMargin: Theme.horizontalPageMargin
|
|
|
|
spacing: Theme.paddingLarge
|
2020-09-15 14:53:13 +00:00
|
|
|
delegate: LibraryItemDelegate {
|
|
|
|
property string id: model.id
|
|
|
|
title: model.name
|
2020-09-26 00:51:37 +00:00
|
|
|
poster: Utils.itemModelImageUrl(ApiClient.baseUrl, model.id, model.imageTags["Primary"], "Primary", {"maxHeight": height})
|
|
|
|
/*model.imageTags["Primary"] ? ApiClient.baseUrl + "/Items/" + model.id
|
2020-09-25 12:46:39 +00:00
|
|
|
+ "/Images/Primary?maxHeight=" + height + "&tag=" + model.imageTags["Primary"]
|
2020-09-26 00:51:37 +00:00
|
|
|
: ""*/
|
|
|
|
landscape: ["Series", "Movie"].indexOf(model.type) == -1
|
2020-09-15 14:53:13 +00:00
|
|
|
|
|
|
|
onClicked: {
|
2020-09-25 12:46:39 +00:00
|
|
|
pageStack.push(Qt.resolvedUrl("DetailPage.qml"), {"itemId": model.id})
|
2020-09-15 14:53:13 +00:00
|
|
|
}
|
|
|
|
}
|
2020-09-25 15:14:44 +00:00
|
|
|
UserItemLatestModel {
|
2020-09-15 14:53:13 +00:00
|
|
|
id: userItemModel
|
|
|
|
apiClient: ApiClient
|
|
|
|
parentId: model.id
|
|
|
|
limit: 12
|
|
|
|
}
|
|
|
|
Connections {
|
|
|
|
target: mediaLibraryModel
|
|
|
|
onStatusChanged: {
|
|
|
|
if (status == ApiModel.Ready) {
|
|
|
|
userItemModel.reload()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-09-25 13:21:08 +00:00
|
|
|
|
2020-09-26 00:51:37 +00:00
|
|
|
onStatusChanged: {
|
|
|
|
if (status == PageStatus.Active) {
|
|
|
|
appWindow.itemData = null
|
2020-09-26 01:21:58 +00:00
|
|
|
if (!_modelsLoaded && ApiClient.authenticated) loadModels()
|
2020-09-26 00:51:37 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-09-25 13:21:08 +00:00
|
|
|
Connections {
|
|
|
|
target: ApiClient
|
|
|
|
onAuthenticatedChanged: {
|
2020-09-26 01:21:58 +00:00
|
|
|
if (authenticated /*&& !_modelsLoaded*/) loadModels();
|
2020-09-25 13:21:08 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Component.onCompleted: {
|
|
|
|
if (ApiClient.authenticated && _modelsLoaded) {
|
|
|
|
loadModels();
|
|
|
|
}
|
|
|
|
}
|
2020-09-15 14:53:13 +00:00
|
|
|
function loadModels() {
|
|
|
|
_modelsLoaded = true;
|
|
|
|
mediaLibraryModel.reload()
|
|
|
|
}
|
|
|
|
}
|