mirror of
https://github.com/HenkKalkwater/harbour-sailfin.git
synced 2024-11-22 09:15:18 +00:00
AN attempt to get covers to work again
Covers should now work when at least the playbackManager is playing. Covers based on the currently displayed item on the page does not work yet. The CoverPage has been revamped to use 1 model and 1 PathView to animate the items for cleaner code.
This commit is contained in:
parent
5ee2869db9
commit
757327ceac
|
@ -26,149 +26,115 @@ import "../Utils.js" as Utils
|
||||||
|
|
||||||
CoverBackground {
|
CoverBackground {
|
||||||
id: cover
|
id: cover
|
||||||
Label {
|
readonly property int rowCount: 8
|
||||||
id: label
|
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
|
||||||
|
readonly property bool itemId: appWindow.itemData.jellyfinId || appWindow.pageStack.currentPage.itemId
|
||||||
|
readonly property bool hasParent: !appWindow.itemData !== null && appWindow.itemData.jellyfinId.length !== 0
|
||||||
|
|
||||||
|
J.ItemModel {
|
||||||
|
id: randomItems
|
||||||
|
loader: J.UserItemsLoader {
|
||||||
|
id: randomItemsLoader
|
||||||
|
apiClient: appWindow.apiClient
|
||||||
|
limit: cover.rowCount * 2
|
||||||
|
imageTypes: [J.ImageType.Primary]
|
||||||
|
sortBy: "IsFavoriteOrLiked,Random"
|
||||||
|
recursive: false
|
||||||
|
parentId: hasParent ? itemId : ""
|
||||||
|
autoReload: false
|
||||||
|
onParentIdChanged: {
|
||||||
|
if (parentId.length > 0) reload()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
PathView {
|
||||||
|
id: pathView
|
||||||
|
model: randomItems
|
||||||
|
path: Path {
|
||||||
|
startX: -rowHeight * rowOffset
|
||||||
|
startY: rowHeight * 0.5
|
||||||
|
|
||||||
|
PathLine {
|
||||||
|
x: rowHeight * rowOffset
|
||||||
|
y: rowHeight * 0.5
|
||||||
|
}
|
||||||
|
PathPercent {
|
||||||
|
value: 0.5
|
||||||
|
}
|
||||||
|
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
|
||||||
|
}
|
||||||
|
}
|
||||||
|
delegate: RemoteImage {
|
||||||
|
height: rowHeight
|
||||||
|
width: height
|
||||||
|
source: model.jellyfinId
|
||||||
|
? Utils.itemModelImageUrl(appWindow.apiClient.baseUrl, model.jellyfinId, model.imageTags["Primary"], "Primary", {"maxHeight": row1.height})
|
||||||
|
: ""
|
||||||
|
blurhash: model.jellyfinId
|
||||||
|
? model.imageBlurHashes["Primary"][model.imageTags["Primary"]]
|
||||||
|
: ""
|
||||||
|
fillMode: Image.PreserveAspectCrop
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Rectangle {
|
||||||
|
anchors.fill: parent
|
||||||
|
color: Theme.rgba(Theme.overlayBackgroundColor, Theme.opacityHigh)
|
||||||
|
}
|
||||||
|
|
||||||
|
Column {
|
||||||
anchors.centerIn: parent
|
anchors.centerIn: parent
|
||||||
text: qsTr("Sailfin")
|
|
||||||
}
|
|
||||||
property int rowCount: 8
|
|
||||||
|
|
||||||
J.ItemModel {
|
|
||||||
id: randomItems1
|
|
||||||
/*loader: J.UserItemsLoader {
|
|
||||||
apiClient: appWindow.apiClient
|
|
||||||
limit: cover.rowCount
|
|
||||||
imageTypes: ["Primary"]
|
|
||||||
sortBy: ["IsFavoriteOrLiked", "Random"]
|
|
||||||
recursive: true
|
|
||||||
parentId: appWindow.collectionId
|
|
||||||
autoReload: false
|
|
||||||
}*/
|
|
||||||
//Component.onCompleted: reload()
|
|
||||||
}
|
|
||||||
|
|
||||||
J.ItemModel {
|
|
||||||
id: randomItems2
|
|
||||||
/*loader: J.UserItemsLoader {
|
|
||||||
apiClient: appWindow.apiClient
|
|
||||||
limit: cover.rowCount
|
|
||||||
imageTypes: ["Primary"]
|
|
||||||
sortBy: ["IsFavoriteOrLiked", "Random"]
|
|
||||||
recursive: true
|
|
||||||
parentId: appWindow.collectionId
|
|
||||||
autoReload: false
|
|
||||||
}*/
|
|
||||||
//Component.onCompleted: reload()
|
|
||||||
}
|
|
||||||
|
|
||||||
Row {
|
|
||||||
id: row1
|
|
||||||
property bool movingRight: true
|
|
||||||
property int moveCount: 0
|
|
||||||
anchors.top: parent.top
|
|
||||||
anchors.left: parent.left
|
|
||||||
anchors.right: parent.right
|
|
||||||
transform: [
|
|
||||||
Translate {
|
|
||||||
x: -row1.height// + (row1.width - row1.height) / 2;
|
|
||||||
},
|
|
||||||
Translate {
|
|
||||||
id: row1Translate;
|
|
||||||
Behavior on x { NumberAnimation { duration: 500; easing.type: Easing.InOutQuad }}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
height: parent.height / 2
|
|
||||||
width: parent.width
|
width: parent.width
|
||||||
Repeater {
|
Image {
|
||||||
model: randomItems1
|
anchors.horizontalCenter: parent.horizontalCenter
|
||||||
RemoteImage {
|
source: Qt.resolvedUrl("../icon.png")
|
||||||
clip: true
|
width: parent.width / 3
|
||||||
height: row1.height
|
height: width
|
||||||
width: height
|
|
||||||
source: model.id ? Utils.itemModelImageUrl(appWindow.apiClient.baseUrl, model.id, model.imageTags.primary, "Primary", {"maxHeight": row1.height})
|
|
||||||
: ""
|
|
||||||
fillMode: Image.PreserveAspectCrop
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function move() {
|
Label {
|
||||||
if (movingRight) {
|
anchors.horizontalCenter: parent.horizontalCenter
|
||||||
row1Translate.x -= row1.height
|
text: qsTr("Sailfin")
|
||||||
moveCount++;
|
font.bold: true
|
||||||
} else {
|
|
||||||
row1Translate.x += row1.height
|
|
||||||
moveCount--;
|
|
||||||
}
|
|
||||||
if (moveCount == 0) movingRight = true;
|
|
||||||
if (moveCount == rowCount - 3) movingRight = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Row {
|
|
||||||
id: row2
|
|
||||||
property bool movingRight: false
|
|
||||||
property int moveCount: rowCount - 3
|
|
||||||
anchors.bottom: parent.bottom
|
|
||||||
|
|
||||||
anchors.left: parent.left
|
|
||||||
anchors.right: parent.right
|
|
||||||
transform: [
|
|
||||||
Translate {
|
|
||||||
x: -row2.height * (rowCount - 2) + (row2.width - row2.height);
|
|
||||||
},
|
|
||||||
Translate {
|
|
||||||
id: row2Translate;
|
|
||||||
Behavior on x { NumberAnimation { duration: 500; easing.type: Easing.InOutQuad }}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
height: parent.height / 2
|
|
||||||
width: parent.width
|
|
||||||
Repeater {
|
|
||||||
model: randomItems2
|
|
||||||
RemoteImage {
|
|
||||||
clip: true
|
|
||||||
height: row2.height
|
|
||||||
width: height
|
|
||||||
source: Utils.itemModelImageUrl(appWindow.apiClient.baseUrl, model.id, model.imageTags.primary, "Primary", {"maxHeight": row1.height})
|
|
||||||
fillMode: Image.PreserveAspectCrop
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function move() {
|
|
||||||
if (movingRight) {
|
|
||||||
row2Translate.x -= row1.height
|
|
||||||
moveCount++;
|
|
||||||
} else {
|
|
||||||
row2Translate.x += row1.height
|
|
||||||
moveCount--;
|
|
||||||
}
|
|
||||||
if (moveCount == 0) movingRight = true;
|
|
||||||
if (moveCount == rowCount - 3) movingRight = false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Connections {
|
Connections {
|
||||||
target: appWindow
|
target: appWindow.pageStack
|
||||||
onCollectionIdChanged: {
|
onCurrentPageChanged: {
|
||||||
randomItems1.parentId = collectionId
|
console.log("Reloading cover collection")
|
||||||
randomItems2.parentId = collectionId
|
/*randomItems1Loader.parentId = Qt.binding(function() { return onMainScreen ? "" : appWindow.itemData.jellyfinId; })
|
||||||
randomItems1.reload()
|
randomItems2Loader.parentId = Qt.binding(function() { return onMainScreen ? "" : appWindow.itemData.jellyfinId; })*/
|
||||||
randomItems2.reload()
|
//randomItems1.reload()
|
||||||
|
//randomItems2.reload()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Timer {
|
Timer {
|
||||||
property bool odd: false
|
|
||||||
running: true
|
running: true
|
||||||
interval: 5000
|
interval: 5000
|
||||||
repeat: true
|
repeat: true
|
||||||
onTriggered: {
|
onTriggered: {
|
||||||
if (odd) {
|
pathView.incrementCurrentIndex()
|
||||||
row1.move()
|
|
||||||
} else {
|
|
||||||
row2.move()
|
|
||||||
}
|
|
||||||
odd = !odd
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,16 +20,17 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
import QtQuick 2.6
|
import QtQuick 2.6
|
||||||
import Sailfish.Silica 1.0
|
import Sailfish.Silica 1.0
|
||||||
|
|
||||||
import nl.netsoj.chris.Jellyfin 1.0
|
import nl.netsoj.chris.Jellyfin 1.0 as J
|
||||||
|
|
||||||
import "../components"
|
import "../components"
|
||||||
import ".."
|
import ".."
|
||||||
|
|
||||||
CoverBackground {
|
CoverBackground {
|
||||||
property JellyfinItem mData: appWindow.itemData
|
// Due QTBUG-10822, declarartions such as `property J.Item foo` are not possible.
|
||||||
|
property var mData: appWindow.itemData
|
||||||
RemoteImage {
|
RemoteImage {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
source: mData == null ? "" : Utils.itemImageUrl(ApiClient.baseUrl, mData, "Primary", {"maxWidth": parent.width})
|
source: mData === null ? "" : Utils.itemImageUrl(appWindow.apiClient.baseUrl, mData, "Primary", {"maxWidth": parent.width})
|
||||||
fillMode: Image.PreserveAspectCrop
|
fillMode: Image.PreserveAspectCrop
|
||||||
onSourceChanged: console.log(source)
|
onSourceChanged: console.log(source)
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,8 +26,7 @@ import nl.netsoj.chris.Jellyfin 1.0
|
||||||
import "../components"
|
import "../components"
|
||||||
|
|
||||||
PosterCover {
|
PosterCover {
|
||||||
readonly property MediaPlayer player: appWindow.mediaPlayer
|
readonly property var player: appWindow.playbackManager
|
||||||
property var mData: appWindow.itemData
|
|
||||||
|
|
||||||
// Wanted to display the currently running move on here, but it's hard :/
|
// Wanted to display the currently running move on here, but it's hard :/
|
||||||
/*Rectangle {
|
/*Rectangle {
|
||||||
|
|
|
@ -38,9 +38,7 @@ ApplicationWindow {
|
||||||
readonly property ApiClient apiClient: _apiClient
|
readonly property ApiClient apiClient: _apiClient
|
||||||
|
|
||||||
// Due QTBUG-10822, declarartions such as `property J.Item foo` are not possible.
|
// Due QTBUG-10822, declarartions such as `property J.Item foo` are not possible.
|
||||||
property var itemData
|
property var itemData: pageStack.currentPage.itemData
|
||||||
// Id of the collection currently browsing. For use on the cover.
|
|
||||||
property string collectionId
|
|
||||||
|
|
||||||
// Bad way to implement settings, but it'll do for now.
|
// Bad way to implement settings, but it'll do for now.
|
||||||
property bool showDebugInfo: true
|
property bool showDebugInfo: true
|
||||||
|
@ -68,19 +66,17 @@ ApplicationWindow {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
cover: CoverBackground {CoverPlaceholder { icon.source: "icon.png"; text: "Sailfin"}}
|
//cover: CoverBackground {CoverPlaceholder { icon.source: "icon.png"; text: "Sailfin"}}
|
||||||
/*{
|
cover: {
|
||||||
// Disabled due to buggy Loader behaviour
|
// Disabled due to buggy Loader behaviour
|
||||||
if ([MediaPlayer.NoMedia, MediaPlayer.InvalidMedia, MediaPlayer.UnknownStatus].indexOf(_playbackManager.mediaStatus) >= 0) {
|
if ([MediaPlayer.NoMedia, MediaPlayer.InvalidMedia, MediaPlayer.UnknownStatus].indexOf(_playbackManager.mediaStatus) >= 0) {
|
||||||
if (itemData) {
|
return Qt.resolvedUrl("cover/CoverPage.qml")
|
||||||
return Qt.resolvedUrl("cover/PosterCover.qml")
|
|
||||||
} else {
|
|
||||||
return Qt.resolvedUrl("cover/CoverPage.qml")
|
|
||||||
}
|
|
||||||
} else if (playbackManager.hasVideo){
|
} else if (playbackManager.hasVideo){
|
||||||
return Qt.resolvedUrl("cover/VideoCover.qml")
|
return Qt.resolvedUrl("cover/VideoCover.qml")
|
||||||
|
} else {
|
||||||
|
return Qt.resolvedUrl("cover/CoverPage.qml")
|
||||||
}
|
}
|
||||||
}*/
|
}
|
||||||
|
|
||||||
Notification {
|
Notification {
|
||||||
id: errorNotification
|
id: errorNotification
|
||||||
|
@ -100,6 +96,17 @@ ApplicationWindow {
|
||||||
autoOpen: true
|
autoOpen: true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Connections {
|
||||||
|
target: pageStack
|
||||||
|
onCurrentPageChanged: {
|
||||||
|
if ("itemData" in pageStack.currentPage) {
|
||||||
|
appWindow.itemData = pageStack.currentPage.itemData
|
||||||
|
} else {
|
||||||
|
appWindow.itemData = null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Keep the sytem alive while playing media
|
// Keep the sytem alive while playing media
|
||||||
KeepAlive {
|
KeepAlive {
|
||||||
enabled: playbackManager.playbackState === MediaPlayer.PlayingState
|
enabled: playbackManager.playbackState === MediaPlayer.PlayingState
|
||||||
|
|
|
@ -138,7 +138,7 @@ Page {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Connections {
|
Connections {
|
||||||
target: mediaLibraryModel
|
target: mediaLibraryLoader
|
||||||
onReady: userItemModel.reload()
|
onReady: userItemModel.reload()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -103,7 +103,7 @@ Page {
|
||||||
if (status === PageStatus.Active) {
|
if (status === PageStatus.Active) {
|
||||||
console.log("Page ready, ItemID: ", itemId, ", UserID: ", apiClient.userId)
|
console.log("Page ready, ItemID: ", itemId, ", UserID: ", apiClient.userId)
|
||||||
jItemLoader.autoReload = true
|
jItemLoader.autoReload = true
|
||||||
appWindow.itemData = jItemLoader.data
|
//appWindow.itemData = jItemLoader.data
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue