mirror of
https://github.com/HenkKalkwater/harbour-sailfin.git
synced 2025-09-05 10:12:46 +00:00
Deserialized a list! Restructured project!
I finally got deserializing lists working. Exposing them to QML was not a trivial task either. Note that I didn't do it the clean way. Nested lists are not supported. But it works! Because I got so frustarted at one point trying to implement things the right way, I restructured the project to seperate the Sailfish code from the Qt code and created a new, empty desktop project. The Qt code has been transformed into a happy little library, to which the Sailfish OS application links. Note that QMake doesn't seem to strip the library for some reason.
This commit is contained in:
parent
4e3395c4e5
commit
1e80ceb697
77 changed files with 507 additions and 213 deletions
169
sailfish/qml/cover/CoverPage.qml
Normal file
169
sailfish/qml/cover/CoverPage.qml
Normal file
|
@ -0,0 +1,169 @@
|
|||
/*
|
||||
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
|
||||
*/
|
||||
import QtQuick 2.0
|
||||
import Sailfish.Silica 1.0
|
||||
|
||||
import nl.netsoj.chris.Jellyfin 1.0
|
||||
|
||||
import "../components"
|
||||
import "../Utils.js" as Utils
|
||||
|
||||
CoverBackground {
|
||||
id: cover
|
||||
Label {
|
||||
id: label
|
||||
anchors.centerIn: parent
|
||||
text: qsTr("Sailfin")
|
||||
}
|
||||
property int rowCount: 8
|
||||
|
||||
UserItemModel {
|
||||
id: randomItems1
|
||||
apiClient: ApiClient
|
||||
limit: cover.rowCount
|
||||
imageTypes: ["Primary"]
|
||||
sortBy: ["IsFavoriteOrLiked", "Random"]
|
||||
recursive: true
|
||||
parentId: appWindow.collectionId
|
||||
Component.onCompleted: reload()
|
||||
}
|
||||
|
||||
UserItemModel {
|
||||
id: randomItems2
|
||||
apiClient: ApiClient
|
||||
limit: cover.rowCount
|
||||
imageTypes: ["Primary"]
|
||||
sortBy: ["IsFavoriteOrLiked", "Random"]
|
||||
recursive: true
|
||||
parentId: appWindow.collectionId
|
||||
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
|
||||
Repeater {
|
||||
model: randomItems1
|
||||
RemoteImage {
|
||||
clip: true
|
||||
height: row1.height
|
||||
width: height
|
||||
source: model.id ? Utils.itemModelImageUrl(ApiClient.baseUrl, model.id, model.imageTags["Primary"], "Primary", {"maxHeight": row1.height})
|
||||
: ""
|
||||
fillMode: Image.PreserveAspectCrop
|
||||
}
|
||||
}
|
||||
|
||||
function move() {
|
||||
if (movingRight) {
|
||||
row1Translate.x -= row1.height
|
||||
moveCount++;
|
||||
} 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(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 {
|
||||
target: appWindow
|
||||
onCollectionIdChanged: {
|
||||
randomItems1.parentId = collectionId
|
||||
randomItems2.parentId = collectionId
|
||||
randomItems1.reload()
|
||||
randomItems2.reload()
|
||||
}
|
||||
}
|
||||
|
||||
Timer {
|
||||
property bool odd: false
|
||||
running: true
|
||||
interval: 5000
|
||||
repeat: true
|
||||
onTriggered: {
|
||||
if (odd) {
|
||||
row1.move()
|
||||
} else {
|
||||
row2.move()
|
||||
}
|
||||
odd = !odd
|
||||
}
|
||||
}
|
||||
|
||||
}
|
86
sailfish/qml/cover/PosterCover.qml
Normal file
86
sailfish/qml/cover/PosterCover.qml
Normal file
|
@ -0,0 +1,86 @@
|
|||
/*
|
||||
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
|
||||
*/
|
||||
|
||||
import QtQuick 2.6
|
||||
import Sailfish.Silica 1.0
|
||||
|
||||
import nl.netsoj.chris.Jellyfin 1.0
|
||||
|
||||
import "../components"
|
||||
import ".."
|
||||
|
||||
CoverBackground {
|
||||
property var mData: appWindow.itemData
|
||||
RemoteImage {
|
||||
anchors.fill: parent
|
||||
source: mData.ImageTags["Primary"] ? ApiClient.baseUrl + "/Items/" + mData.Id
|
||||
+ "/Images/Primary?maxHeight=" + height + "&tag=" + mData.ImageTags["Primary"]
|
||||
: ""
|
||||
fillMode: Image.PreserveAspectCrop
|
||||
}
|
||||
|
||||
Shim {
|
||||
// Movies usually show their name on the poster,
|
||||
// so showing it here as well is a bit double
|
||||
visible: itemData.Type !== "Movie"
|
||||
anchors {
|
||||
left: parent.left
|
||||
right: parent.right
|
||||
top: parent.top
|
||||
}
|
||||
upsideDown: true
|
||||
height: parent.height / 2
|
||||
|
||||
Rectangle {
|
||||
anchors {
|
||||
top: parent.top
|
||||
left: parent.left
|
||||
}
|
||||
width: itemData.UserData.PlayedPercentage / 100 * parent.width
|
||||
height: Theme.paddingSmall
|
||||
color: Theme.highlightColor
|
||||
}
|
||||
|
||||
Column {
|
||||
id: infoColumn
|
||||
anchors {
|
||||
top: parent.top
|
||||
left: parent.left
|
||||
right: parent.right
|
||||
}
|
||||
anchors.margins: Theme.paddingMedium
|
||||
Label {
|
||||
id: itemName
|
||||
anchors {
|
||||
left: parent.left
|
||||
right: parent.right
|
||||
}
|
||||
color: Theme.primaryColor
|
||||
text: itemData.Name
|
||||
truncationMode: TruncationMode.Fade
|
||||
}
|
||||
Label {
|
||||
visible: typeof itemData.RunTimeTicks !== "undefined"
|
||||
color: Theme.secondaryColor
|
||||
text: Utils.ticksToText(itemData.RunTimeTicks)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
77
sailfish/qml/cover/VideoCover.qml
Normal file
77
sailfish/qml/cover/VideoCover.qml
Normal file
|
@ -0,0 +1,77 @@
|
|||
/*
|
||||
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
|
||||
*/
|
||||
|
||||
import QtQuick 2.6
|
||||
import QtMultimedia 5.6
|
||||
import Sailfish.Silica 1.0
|
||||
|
||||
import nl.netsoj.chris.Jellyfin 1.0
|
||||
|
||||
import "../components"
|
||||
|
||||
CoverBackground {
|
||||
readonly property MediaPlayer player: appWindow.mediaPlayer
|
||||
property var mData: appWindow.itemData
|
||||
|
||||
Rectangle {
|
||||
anchors.fill: parent
|
||||
color: "black"
|
||||
|
||||
// Wanted to display the currently running move on here, but it's hard :/
|
||||
/*VideoOutput {
|
||||
id: coverOutput
|
||||
anchors.fill: parent
|
||||
source: player
|
||||
}*/
|
||||
|
||||
}
|
||||
// As a temporary fallback, use the poster image
|
||||
RemoteImage {
|
||||
anchors.fill: parent
|
||||
source: mData.ImageTags["Primary"] ? ApiClient.baseUrl + "/Items/" + mData.Id
|
||||
+ "/Images/Primary?maxHeight=" + height + "&tag=" + mData.ImageTags["Primary"]
|
||||
: ""
|
||||
fillMode: Image.PreserveAspectCrop
|
||||
}
|
||||
|
||||
Shim {
|
||||
anchors {
|
||||
left: parent.left
|
||||
bottom: parent.bottom
|
||||
right: parent.right
|
||||
}
|
||||
height: Theme.iconSizeLarge
|
||||
}
|
||||
|
||||
CoverActionList {
|
||||
CoverAction {
|
||||
id: playPause
|
||||
iconSource: player.playbackState === MediaPlayer.PlayingState ? "image://theme/icon-cover-pause"
|
||||
: "image://theme/icon-cover-play"
|
||||
onTriggered: {
|
||||
if (player.playbackState === MediaPlayer.PlayingState) {
|
||||
player.pause()
|
||||
} else {
|
||||
player.play()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue