2020-09-27 18:38:33 +00:00
|
|
|
/*
|
|
|
|
Sailfin: a Jellyfin client written using Qt
|
|
|
|
Copyright (C) 2020 Chris Josten
|
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or
|
|
|
|
modify it under the terms of the GNU Lesser General Public
|
|
|
|
License as published by the Free Software Foundation; either
|
|
|
|
version 2.1 of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
This library is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
Lesser General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU Lesser General Public
|
|
|
|
License along with this library; if not, write to the Free Software
|
|
|
|
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
|
*/
|
2020-09-15 14:53:13 +00:00
|
|
|
import QtQuick 2.0
|
|
|
|
import Sailfish.Silica 1.0
|
|
|
|
|
2021-08-21 22:29:44 +00:00
|
|
|
import nl.netsoj.chris.Jellyfin 1.0 as J
|
2020-09-26 00:51:37 +00:00
|
|
|
|
|
|
|
import "../components"
|
|
|
|
import "../Utils.js" as Utils
|
|
|
|
|
2020-09-15 14:53:13 +00:00
|
|
|
CoverBackground {
|
2020-09-26 00:51:37 +00:00
|
|
|
id: cover
|
2021-08-22 23:53:20 +00:00
|
|
|
readonly property int rowCount: 8
|
|
|
|
readonly property real rowOffset: ((rowCount - 1) * 0.5)
|
|
|
|
readonly property real rowHeight: height / 2
|
|
|
|
readonly property real bottomOffset: width - rowHeight
|
|
|
|
readonly property bool onMainScreen: appWindow.itemData === null
|
2021-09-09 03:57:41 +00:00
|
|
|
readonly property string itemId: appWindow.pageStack.currentPage.itemId
|
2021-08-22 23:53:20 +00:00
|
|
|
readonly property bool hasParent: !appWindow.itemData !== null && appWindow.itemData.jellyfinId.length !== 0
|
2020-09-15 14:53:13 +00:00
|
|
|
|
2021-08-21 22:29:44 +00:00
|
|
|
J.ItemModel {
|
2021-08-22 23:53:20 +00:00
|
|
|
id: randomItems
|
|
|
|
loader: J.UserItemsLoader {
|
|
|
|
id: randomItemsLoader
|
2021-08-21 22:29:44 +00:00
|
|
|
apiClient: appWindow.apiClient
|
2021-09-09 03:57:41 +00:00
|
|
|
limit: cover.rowCount * 2 - 2
|
2021-08-22 23:53:20 +00:00
|
|
|
imageTypes: [J.ImageType.Primary]
|
|
|
|
sortBy: "IsFavoriteOrLiked,Random"
|
2021-09-10 03:18:05 +00:00
|
|
|
recursive: true
|
2021-09-09 03:57:41 +00:00
|
|
|
parentId: itemId
|
2021-08-22 23:53:20 +00:00
|
|
|
autoReload: false
|
|
|
|
onParentIdChanged: {
|
2021-09-09 03:57:41 +00:00
|
|
|
reload()
|
2021-08-22 23:53:20 +00:00
|
|
|
}
|
|
|
|
}
|
2020-09-26 00:51:37 +00:00
|
|
|
}
|
2021-08-22 23:53:20 +00:00
|
|
|
PathView {
|
|
|
|
id: pathView
|
|
|
|
model: randomItems
|
2021-09-10 03:18:05 +00:00
|
|
|
visible: count === randomItemsLoader.limit
|
2021-08-22 23:53:20 +00:00
|
|
|
path: Path {
|
|
|
|
startX: -rowHeight * rowOffset
|
|
|
|
startY: rowHeight * 0.5
|
|
|
|
|
|
|
|
PathLine {
|
|
|
|
x: rowHeight * rowOffset
|
|
|
|
y: rowHeight * 0.5
|
2020-09-26 00:51:37 +00:00
|
|
|
}
|
2021-08-22 23:53:20 +00:00
|
|
|
PathPercent {
|
|
|
|
value: 0.5
|
2020-09-26 00:51:37 +00:00
|
|
|
}
|
2021-08-22 23:53:20 +00:00
|
|
|
PathLine {
|
|
|
|
x: rowHeight * rowOffset + bottomOffset
|
|
|
|
y: rowHeight * 1.5
|
|
|
|
}
|
|
|
|
PathPercent {
|
|
|
|
value: 0.5
|
|
|
|
}
|
|
|
|
PathLine {
|
|
|
|
x: -rowHeight * rowOffset + bottomOffset
|
|
|
|
y: rowHeight * 1.5
|
|
|
|
}
|
|
|
|
PathPercent {
|
|
|
|
value: 1
|
|
|
|
}
|
|
|
|
PathLine {
|
|
|
|
x: -rowHeight * rowOffset
|
|
|
|
y: rowHeight * 0.5
|
2020-09-26 00:51:37 +00:00
|
|
|
}
|
2021-09-09 03:57:41 +00:00
|
|
|
PathPercent {
|
|
|
|
value: 1
|
|
|
|
}
|
2020-09-15 14:53:13 +00:00
|
|
|
}
|
2021-08-22 23:53:20 +00:00
|
|
|
delegate: RemoteImage {
|
|
|
|
height: rowHeight
|
|
|
|
width: height
|
|
|
|
source: model.jellyfinId
|
2021-09-09 03:57:41 +00:00
|
|
|
? Utils.itemModelImageUrl(appWindow.apiClient.baseUrl, model.jellyfinId, model.imageTags["Primary"], "Primary", {"maxHeight": rowHeight})
|
2021-08-22 23:53:20 +00:00
|
|
|
: ""
|
|
|
|
blurhash: model.jellyfinId
|
|
|
|
? model.imageBlurHashes["Primary"][model.imageTags["Primary"]]
|
|
|
|
: ""
|
|
|
|
fillMode: Image.PreserveAspectCrop
|
|
|
|
}
|
2020-09-15 14:53:13 +00:00
|
|
|
}
|
2020-09-26 00:51:37 +00:00
|
|
|
|
2021-09-09 03:57:41 +00:00
|
|
|
/*Rectangle {
|
2021-08-22 23:53:20 +00:00
|
|
|
anchors.fill: parent
|
|
|
|
color: Theme.rgba(Theme.overlayBackgroundColor, Theme.opacityHigh)
|
2021-09-09 03:57:41 +00:00
|
|
|
}*/
|
2020-09-26 00:51:37 +00:00
|
|
|
|
2021-08-22 23:53:20 +00:00
|
|
|
Column {
|
|
|
|
anchors.centerIn: parent
|
2020-09-26 00:51:37 +00:00
|
|
|
width: parent.width
|
2021-09-10 03:18:05 +00:00
|
|
|
opacity: randomItemsLoader.status === J.ModelStatus.Ready && pathView.visible ? 0.0 : 1.0
|
2021-09-09 03:57:41 +00:00
|
|
|
Behavior on opacity {
|
|
|
|
NumberAnimation {}
|
|
|
|
}
|
2021-08-22 23:53:20 +00:00
|
|
|
Image {
|
|
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
|
|
|
source: Qt.resolvedUrl("../icon.png")
|
|
|
|
width: parent.width / 3
|
|
|
|
height: width
|
2020-09-26 00:51:37 +00:00
|
|
|
}
|
|
|
|
|
2021-08-22 23:53:20 +00:00
|
|
|
Label {
|
|
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
|
|
|
text: qsTr("Sailfin")
|
|
|
|
font.bold: true
|
2020-09-26 00:51:37 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-09-27 14:54:45 +00:00
|
|
|
Connections {
|
2021-08-22 23:53:20 +00:00
|
|
|
target: appWindow.pageStack
|
|
|
|
onCurrentPageChanged: {
|
|
|
|
console.log("Reloading cover collection")
|
2020-09-27 14:54:45 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-09-09 03:57:41 +00:00
|
|
|
|
|
|
|
Component.onCompleted: randomItems.reload()
|
|
|
|
|
2020-09-26 00:51:37 +00:00
|
|
|
Timer {
|
|
|
|
running: true
|
2021-09-10 03:18:05 +00:00
|
|
|
interval: 10000
|
2020-09-26 00:51:37 +00:00
|
|
|
repeat: true
|
|
|
|
onTriggered: {
|
2021-08-22 23:53:20 +00:00
|
|
|
pathView.incrementCurrentIndex()
|
2020-09-26 00:51:37 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-09-15 14:53:13 +00:00
|
|
|
}
|