1
0
Fork 0
mirror of https://github.com/HenkKalkwater/harbour-sailfin.git synced 2024-12-23 14:35:17 +00:00
harbour-sailfin/qtquick/qml/pages/MainPage.qml

119 lines
3.8 KiB
QML
Raw Normal View History

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
import "../components"
import "../.."
2021-03-26 20:27:35 +00:00
import ".."
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 {
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
}
}
ScrollView {
anchors.fill: parent
contentHeight: content.height
2021-03-29 21:48:16 +00:00
contentWidth: availableWidth
Column {
id: content
width: parent.width
CheckBox {
checked: ApiClient.settings.allowTranscoding
text: "allow transcoding"
onCheckedChanged: ApiClient.settings.allowTranscoding = checked
}
Repeater {
model: mediaLibraryModel
Column {
width: parent.width
2021-03-29 21:48:16 +00:00
J.ItemModel{
id: userItemModel
2021-03-29 21:48:16 +00:00
loader: J.LatestMediaLoader {
id: latestMediaLoader
apiClient: ApiClient
parentId: model.jellyfinId
//limit: 16
}
}
Label {
text: model.name ? model.name : "<Model without name>"
}
ListView {
width: parent.width
height: SailfinStyle.unit * 20
orientation: ListView.Horizontal
2021-03-29 21:48:16 +00:00
model: userItemModel
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
}
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
})
}
}
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-29 21:48:16 +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
mediaLibraryModel.reload()
}
}
Connections {
target: ApiClient
onAuthenticatedChanged: {
if (authenticated) {
loadModels(false)
}
}
}
}