2021-03-19 19:57:04 +00:00
|
|
|
import QtQuick 2.12
|
|
|
|
import QtQuick.Controls 2.12
|
|
|
|
import QtQuick.Window 2.12
|
|
|
|
|
2021-03-24 19:04:03 +00:00
|
|
|
import nl.netsoj.chris.Jellyfin 1.0 as J
|
2021-03-19 19:57:04 +00:00
|
|
|
|
|
|
|
import "../components"
|
|
|
|
import "../.."
|
2021-03-26 20:27:35 +00:00
|
|
|
import ".."
|
2021-03-19 19:57:04 +00:00
|
|
|
|
|
|
|
Page {
|
|
|
|
property bool _modelsLoaded: false
|
|
|
|
property StackView stackView: StackView.view
|
|
|
|
header: ToolBar {
|
|
|
|
Label {
|
|
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
|
|
|
font.pixelSize: SailfinStyle.fontSizeLarge
|
|
|
|
text: qsTr("Main page")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-03-26 20:27:35 +00:00
|
|
|
J.ItemModel {
|
2021-03-19 19:57:04 +00:00
|
|
|
id: mediaLibraryModel
|
2021-03-29 21:48:16 +00:00
|
|
|
loader: J.UsersViewsLoader {
|
2021-03-26 20:27:35 +00:00
|
|
|
id: mediaLibraryModelLoader
|
|
|
|
apiClient: ApiClient
|
|
|
|
}
|
2021-03-19 19:57:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
ScrollView {
|
|
|
|
anchors.fill: parent
|
|
|
|
contentHeight: content.height
|
2021-03-29 21:48:16 +00:00
|
|
|
contentWidth: availableWidth
|
2021-03-19 19:57:04 +00:00
|
|
|
Column {
|
|
|
|
id: content
|
|
|
|
width: parent.width
|
2021-09-08 19:44:42 +00:00
|
|
|
CheckBox {
|
|
|
|
checked: ApiClient.settings.allowTranscoding
|
|
|
|
text: "allow transcoding"
|
|
|
|
onCheckedChanged: ApiClient.settings.allowTranscoding = checked
|
|
|
|
}
|
2021-03-19 19:57:04 +00:00
|
|
|
Repeater {
|
|
|
|
model: mediaLibraryModel
|
|
|
|
Column {
|
|
|
|
width: parent.width
|
2021-03-29 21:48:16 +00:00
|
|
|
J.ItemModel{
|
2021-03-19 19:57:04 +00:00
|
|
|
id: userItemModel
|
2021-03-29 21:48:16 +00:00
|
|
|
loader: J.LatestMediaLoader {
|
|
|
|
id: latestMediaLoader
|
|
|
|
apiClient: ApiClient
|
|
|
|
parentId: model.jellyfinId
|
|
|
|
//limit: 16
|
|
|
|
}
|
|
|
|
}
|
2021-03-19 19:57:04 +00:00
|
|
|
Label {
|
2021-03-29 15:10:25 +00:00
|
|
|
text: model.name ? model.name : "<Model without name>"
|
2021-03-19 19:57:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
ListView {
|
|
|
|
width: parent.width
|
|
|
|
height: SailfinStyle.unit * 20
|
|
|
|
orientation: ListView.Horizontal
|
2021-03-29 21:48:16 +00:00
|
|
|
model: userItemModel
|
2021-03-19 19:57:04 +00:00
|
|
|
delegate: ItemDelegate {
|
|
|
|
width: 12 * SailfinStyle.unit
|
|
|
|
height: 20 * SailfinStyle.unit
|
|
|
|
Image {
|
|
|
|
anchors.fill: parent
|
2021-03-29 21:48:16 +00:00
|
|
|
source: ApiClient.baseUrl + "/Items/" + model.jellyfinId
|
|
|
|
+ "/Images/Primary?tag=" + model.imageTags["Primary"] //model.tag
|
2021-03-19 19:57:04 +00:00
|
|
|
}
|
|
|
|
Label {
|
|
|
|
anchors.left: parent.left
|
|
|
|
anchors.top: parent.top
|
|
|
|
anchors.right: parent.right
|
|
|
|
text: model.name
|
|
|
|
}
|
2021-03-29 21:48:16 +00:00
|
|
|
onClicked: stackView.push(Qt.resolvedUrl(
|
|
|
|
"DetailPage.qml"), {
|
|
|
|
"itemId": model.jellyfinId
|
|
|
|
})
|
2021-03-19 19:57:04 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
Connections {
|
2021-03-26 20:27:35 +00:00
|
|
|
target: mediaLibraryModelLoader
|
|
|
|
onReady: {
|
|
|
|
if (mediaLibraryModelLoader.status === ModelStatus.Ready) {
|
2021-03-29 21:48:16 +00:00
|
|
|
|
|
|
|
latestMediaLoader.reload()
|
2021-03-19 19:57:04 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-03-29 21:48:16 +00:00
|
|
|
|
2021-03-19 19:57:04 +00:00
|
|
|
/**
|
|
|
|
* Loads models if not laoded. Set force to true to reload models
|
|
|
|
* even if loaded.
|
|
|
|
*/
|
|
|
|
function loadModels(force) {
|
|
|
|
if (force || (ApiClient.authenticated && !_modelsLoaded)) {
|
2021-03-29 21:48:16 +00:00
|
|
|
_modelsLoaded = true
|
2021-03-19 19:57:04 +00:00
|
|
|
mediaLibraryModel.reload()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Connections {
|
|
|
|
target: ApiClient
|
|
|
|
onAuthenticatedChanged: {
|
|
|
|
if (authenticated) {
|
|
|
|
loadModels(false)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|