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
118
sailfish/qml/pages/AboutPage.qml
Normal file
118
sailfish/qml/pages/AboutPage.qml
Normal file
|
@ -0,0 +1,118 @@
|
|||
/*
|
||||
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"
|
||||
|
||||
Page {
|
||||
id: page
|
||||
|
||||
// The effective value will be restricted by ApplicationWindow.allowedOrientations
|
||||
allowedOrientations: Orientation.All
|
||||
|
||||
SilicaFlickable {
|
||||
anchors.fill: parent
|
||||
contentHeight: content.height
|
||||
Column {
|
||||
id: content
|
||||
width: parent.width
|
||||
PageHeader {
|
||||
title: qsTr("About Sailfin")
|
||||
}
|
||||
Image {
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
source: Qt.resolvedUrl("../icon.png")
|
||||
}
|
||||
|
||||
Item { width: 1; height: Theme.paddingLarge }
|
||||
|
||||
Label {
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
anchors.leftMargin: Theme.horizontalPageMargin
|
||||
anchors.rightMargin: Theme.horizontalPageMargin
|
||||
wrapMode: Text.WordWrap
|
||||
text: qsTr("<p><b>Sailfin version %1</b><br/>" +
|
||||
"Copyright © Chris Josten 2020</p>" +
|
||||
"<p>Sailfin is Free Software licensed under the <a href='lgpl'>LGPL-v2.1</a> or later, at your choice. " +
|
||||
"Parts of the code of Sailfin are from other libraries. <a href='3rdparty'>View their licenses here</a>.</p>")
|
||||
.arg(ApiClient.version)
|
||||
textFormat: Text.StyledText
|
||||
color: Theme.secondaryHighlightColor
|
||||
linkColor: Theme.primaryColor
|
||||
onLinkActivated: {
|
||||
switch(link) {
|
||||
case "lgpl":
|
||||
pageStack.push(licensePage)
|
||||
break;
|
||||
case "3rdparty":
|
||||
pageStack.push(Qt.resolvedUrl("LegalPage.qml"))
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
VerticalScrollDecorator {}
|
||||
}
|
||||
|
||||
Component {
|
||||
id: licensePage
|
||||
|
||||
Page {
|
||||
allowedOrientations: Orientation.All
|
||||
SilicaFlickable {
|
||||
anchors.fill: parent
|
||||
contentHeight: content.height
|
||||
PullDownMenu {
|
||||
MenuItem {
|
||||
text: qsTr("Open externally")
|
||||
onClicked: Qt.openUrlExternally(Qt.resolvedUrl("../licenses/lgpl-2.1.html"))
|
||||
}
|
||||
}
|
||||
VerticalScrollDecorator {}
|
||||
Column {
|
||||
id: content
|
||||
width: parent.width
|
||||
PageHeader {
|
||||
title: qsTr("LGPL 2.1 License")
|
||||
}
|
||||
PlainLabel {
|
||||
id: licenseLabel
|
||||
|
||||
Component.onCompleted: {
|
||||
var xhr = new XMLHttpRequest;
|
||||
xhr.open("GET", Qt.resolvedUrl("../licenses/lgpl-2.1.html")); // set Method and File
|
||||
xhr.onreadystatechange = function () {
|
||||
if (xhr.readyState === XMLHttpRequest.DONE){ // if request_status == DONE
|
||||
licenseLabel.text = xhr.responseText;
|
||||
}
|
||||
}
|
||||
xhr.send(); // begin the request
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
128
sailfish/qml/pages/LegalPage.qml
Normal file
128
sailfish/qml/pages/LegalPage.qml
Normal file
|
@ -0,0 +1,128 @@
|
|||
/*
|
||||
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 QtQuick.XmlListModel 2.0
|
||||
import Sailfish.Silica 1.0
|
||||
|
||||
import "../components"
|
||||
|
||||
/**
|
||||
* This page contains legal information about snippets and 3rd party libraries.
|
||||
*
|
||||
* Displaying them is done by loading ../3rdparty.xml, which contains a list of all
|
||||
* the included snippets/libraries and their licenses.
|
||||
*/
|
||||
Page {
|
||||
allowedOrientations: Orientation.All
|
||||
|
||||
SilicaFlickable {
|
||||
anchors.fill: parent
|
||||
contentHeight: content.height
|
||||
|
||||
Column {
|
||||
id: content
|
||||
width: parent.width
|
||||
|
||||
XmlListModel {
|
||||
id: licencesModel
|
||||
source: Qt.resolvedUrl("../3rdparty.xml")
|
||||
query: "/includes/include"
|
||||
XmlRole { name: "name"; query: "name/string()" }
|
||||
XmlRole { name: "type"; query: "type/string()" }
|
||||
XmlRole { name: "url"; query: "url/string()" }
|
||||
XmlRole { name: "copyright"; query: "license/copyright/string()" }
|
||||
XmlRole { name: "licenseUrl"; query: "license/text/string()" }
|
||||
XmlRole { name: "licenseType"; query: "license/type/string()" }
|
||||
}
|
||||
|
||||
PageHeader {
|
||||
title: qsTr("Legal")
|
||||
}
|
||||
|
||||
PlainLabel {
|
||||
text: qsTr("Sailfin contains code taken from other projects. Without them, Sailfin would " +
|
||||
"not be possible!")
|
||||
}
|
||||
|
||||
Repeater {
|
||||
model: licencesModel
|
||||
Column {
|
||||
width: parent.width
|
||||
SectionHeader {
|
||||
text: name
|
||||
}
|
||||
|
||||
PlainLabel {
|
||||
color: Theme.secondaryHighlightColor
|
||||
text: {
|
||||
switch(type) {
|
||||
case "SNIPPET":
|
||||
return qsTr("This program contains small snippets of code taken from <a href=\"%1\">%2</a>, which " +
|
||||
"is licensed under the %3 license:")
|
||||
.arg(model.url).arg(model.name).arg(model.licenseType);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Item {
|
||||
width: 1
|
||||
height: Theme.paddingLarge
|
||||
}
|
||||
|
||||
SilicaFlickable {
|
||||
anchors {
|
||||
left: parent.left
|
||||
right: parent.right
|
||||
leftMargin: Theme.horizontalPageMargin
|
||||
rightMargin: Theme.horizontalPageMargin
|
||||
}
|
||||
height: licenseLabel.contentHeight
|
||||
contentWidth: licenseLabel.contentWidth
|
||||
clip: true
|
||||
|
||||
Label {
|
||||
id: licenseLabel
|
||||
color: Theme.secondaryHighlightColor
|
||||
font.family: "monospace"
|
||||
font.pixelSize: Theme.fontSizeExtraSmall
|
||||
wrapMode: Text.NoWrap
|
||||
|
||||
Component.onCompleted: {
|
||||
var xhr = new XMLHttpRequest;
|
||||
xhr.open("GET", Qt.resolvedUrl("../" + model.licenseUrl)); // set Method and File
|
||||
console.log(Qt.resolvedUrl("../" + model.licenseUrl))
|
||||
xhr.onreadystatechange = function () {
|
||||
if (xhr.readyState === XMLHttpRequest.DONE){ // if request_status == DONE
|
||||
var response = model.copyright + "\n\n" + xhr.responseText;
|
||||
console.log(response);
|
||||
licenseLabel.text = response
|
||||
}
|
||||
}
|
||||
xhr.send(); // begin the request
|
||||
}
|
||||
}
|
||||
HorizontalScrollDecorator {}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
VerticalScrollDecorator {}
|
||||
}
|
||||
}
|
||||
}
|
214
sailfish/qml/pages/MainPage.qml
Normal file
214
sailfish/qml/pages/MainPage.qml
Normal file
|
@ -0,0 +1,214 @@
|
|||
/*
|
||||
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 "../"
|
||||
import "../Utils.js" as Utils
|
||||
|
||||
/**
|
||||
* Main page, which simply shows some content of every library, as well as next items.
|
||||
*/
|
||||
Page {
|
||||
property bool _modelsLoaded: false
|
||||
|
||||
id: page
|
||||
allowedOrientations: Orientation.All
|
||||
|
||||
SilicaFlickable {
|
||||
anchors.fill: parent
|
||||
|
||||
// PullDownMenu and PushUpMenu must be declared in SilicaFlickable, SilicaListView or SilicaGridView
|
||||
PullDownMenu {
|
||||
MenuItem {
|
||||
text: qsTr("Settings")
|
||||
onClicked: pageStack.push(Qt.resolvedUrl("SettingsPage.qml"))
|
||||
}
|
||||
MenuItem {
|
||||
text: qsTr("Refresh")
|
||||
onClicked: loadModels(true)
|
||||
}
|
||||
busy: mediaLibraryModel.status == ApiModel.Loading
|
||||
}
|
||||
|
||||
// Tell SilicaFlickable the height of its content.
|
||||
contentHeight: column.height
|
||||
|
||||
// Place our content in a Column. The PageHeader is always placed at the top
|
||||
// of the page, followed by our content.
|
||||
Column {
|
||||
id: column
|
||||
|
||||
width: page.width
|
||||
//spacing: Theme.paddingLarge
|
||||
UserViewModel {
|
||||
id: mediaLibraryModel2
|
||||
apiClient: ApiClient
|
||||
}
|
||||
|
||||
MoreSection {
|
||||
text: qsTr("Resume watching")
|
||||
clickable: false
|
||||
busy: userResumeModel.status == ApiModel.Loading
|
||||
Loader {
|
||||
width: parent.width
|
||||
sourceComponent: carrouselView
|
||||
property alias itemModel: userResumeModel
|
||||
property string collectionType: "series"
|
||||
|
||||
UserItemResumeModel {
|
||||
id: userResumeModel
|
||||
apiClient: ApiClient
|
||||
limit: 12
|
||||
recursive: true
|
||||
}
|
||||
}
|
||||
}
|
||||
MoreSection {
|
||||
text: qsTr("Next up")
|
||||
clickable: false
|
||||
}
|
||||
|
||||
UserViewModel {
|
||||
id: mediaLibraryModel
|
||||
apiClient: ApiClient
|
||||
}
|
||||
Repeater {
|
||||
model: mediaLibraryModel
|
||||
MoreSection {
|
||||
text: model.name
|
||||
busy: userItemModel.status != ApiModel.Ready
|
||||
|
||||
onHeaderClicked: pageStack.push(Qt.resolvedUrl("itemdetails/CollectionPage.qml"), {"itemId": model.id})
|
||||
Loader {
|
||||
width: parent.width
|
||||
sourceComponent: carrouselView
|
||||
property alias itemModel: userItemModel
|
||||
property string collectionType: model.collectionType || ""
|
||||
|
||||
UserItemLatestModel {
|
||||
id: userItemModel
|
||||
apiClient: ApiClient
|
||||
parentId: model.id
|
||||
limit: 12
|
||||
}
|
||||
Connections {
|
||||
target: mediaLibraryModel
|
||||
onStatusChanged: {
|
||||
console.log("MediaLibraryModel status " + status)
|
||||
if (status == ApiModel.Ready) {
|
||||
userItemModel.reload()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Column {
|
||||
width: parent.width
|
||||
visible: mediaLibraryModel.status == ApiModel.Error
|
||||
PageHeader {
|
||||
title: qsTr("Network error")
|
||||
//clickable: false
|
||||
}
|
||||
|
||||
PlainLabel {
|
||||
text: qsTr("An error has occurred. Please try again.")
|
||||
}
|
||||
Item { width: 1; height: Theme.paddingLarge }
|
||||
Button {
|
||||
text: qsTr("Retry")
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
onClicked: loadModels(true)
|
||||
}
|
||||
Item { width: 1; height: Theme.paddingLarge }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
onStatusChanged: {
|
||||
if (status == PageStatus.Active) {
|
||||
appWindow.itemData = null
|
||||
loadModels(false)
|
||||
}
|
||||
}
|
||||
|
||||
Connections {
|
||||
target: ApiClient
|
||||
onAuthenticatedChanged: loadModels(false)
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Loads models if not laoded. Set force to true to reload models
|
||||
* even if loaded.
|
||||
*/
|
||||
function loadModels(force) {
|
||||
if (force || (ApiClient.authenticated && !_modelsLoaded)) {
|
||||
_modelsLoaded = true;
|
||||
mediaLibraryModel.reload()
|
||||
userResumeModel.reload()
|
||||
}
|
||||
}
|
||||
|
||||
Component {
|
||||
id: carrouselView
|
||||
SilicaListView {
|
||||
id: list
|
||||
clip: true
|
||||
height: {
|
||||
if (count > 0) {
|
||||
if (["tvshows", "movies"].indexOf(collectionType) == -1) {
|
||||
Constants.libraryDelegateHeight
|
||||
} else {
|
||||
Constants.libraryDelegatePosterHeight
|
||||
}
|
||||
} else {
|
||||
0
|
||||
}
|
||||
}
|
||||
Behavior on height {
|
||||
NumberAnimation { duration: 300 }
|
||||
}
|
||||
model: itemModel
|
||||
width: parent.width
|
||||
orientation: ListView.Horizontal
|
||||
leftMargin: Theme.horizontalPageMargin
|
||||
rightMargin: Theme.horizontalPageMargin
|
||||
spacing: Theme.paddingLarge
|
||||
delegate: LibraryItemDelegate {
|
||||
property string id: model.id
|
||||
title: model.name
|
||||
poster: Utils.itemModelImageUrl(ApiClient.baseUrl, model.id, model.imageTags["Primary"], "Primary", {"maxHeight": height})
|
||||
/*model.imageTags["Primary"] ? ApiClient.baseUrl + "/Items/" + model.id
|
||||
+ "/Images/Primary?maxHeight=" + height + "&tag=" + model.imageTags["Primary"]
|
||||
: ""*/
|
||||
landscape: !Utils.usePortraitCover(collectionType)
|
||||
progress: (typeof model.userData !== "undefined") ? model.userData.PlayedPercentage / 100 : 0.0
|
||||
|
||||
onClicked: {
|
||||
pageStack.push(Utils.getPageUrl(model.mediaType, model.type), {"itemId": model.id})
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
93
sailfish/qml/pages/SettingsPage.qml
Normal file
93
sailfish/qml/pages/SettingsPage.qml
Normal file
|
@ -0,0 +1,93 @@
|
|||
/*
|
||||
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"
|
||||
|
||||
Page {
|
||||
id: settingsPage
|
||||
|
||||
SilicaFlickable {
|
||||
anchors.fill: parent
|
||||
contentHeight: content.height
|
||||
|
||||
Column {
|
||||
id: content
|
||||
width: parent.width
|
||||
|
||||
RemorsePopup {
|
||||
id: remorse
|
||||
}
|
||||
|
||||
PageHeader {
|
||||
//: Header of Settings page
|
||||
title: qsTr("Settings")
|
||||
}
|
||||
|
||||
|
||||
SectionHeader {
|
||||
text: qsTr("Session")
|
||||
}
|
||||
|
||||
PlainLabel {
|
||||
text: qsTr("Server")
|
||||
}
|
||||
|
||||
PlainLabel {
|
||||
text: ApiClient.baseUrl
|
||||
color: Theme.secondaryHighlightColor
|
||||
}
|
||||
|
||||
Item { width: 1; height: Theme.paddingMedium; }
|
||||
|
||||
PlainLabel {
|
||||
text: qsTr("User id")
|
||||
}
|
||||
|
||||
PlainLabel {
|
||||
text: ApiClient.userId
|
||||
color: Theme.secondaryHighlightColor
|
||||
}
|
||||
|
||||
Item { width: 1; height: Theme.paddingLarge; }
|
||||
|
||||
ButtonLayout {
|
||||
Button {
|
||||
text: qsTr("Log out")
|
||||
onClicked: remorse.execute(qsTr("Logging out"), ApiClient.deleteSession)
|
||||
}
|
||||
}
|
||||
|
||||
SectionHeader {
|
||||
//: Other settings
|
||||
text: qsTr("Other")
|
||||
}
|
||||
|
||||
IconListItem {
|
||||
text: qsTr("About Sailfin")
|
||||
iconSource: "image://theme/icon-m-about"
|
||||
onClicked: pageStack.push(Qt.resolvedUrl("AboutPage.qml"))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
68
sailfish/qml/pages/VideoPage.qml
Normal file
68
sailfish/qml/pages/VideoPage.qml
Normal file
|
@ -0,0 +1,68 @@
|
|||
/*
|
||||
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 "../components"
|
||||
|
||||
/**
|
||||
* Page only containing a video player.
|
||||
*
|
||||
* On larger devices the video player could potentially be embedded somewhere else.
|
||||
*/
|
||||
|
||||
Page {
|
||||
id: videoPage
|
||||
property string itemId
|
||||
property var itemData
|
||||
property int audioTrack
|
||||
property int subtitleTrack
|
||||
property int startTicks: 0
|
||||
|
||||
allowedOrientations: Orientation.All
|
||||
showNavigationIndicator: videoPlayer.hudVisible
|
||||
|
||||
VideoPlayer {
|
||||
id: videoPlayer
|
||||
anchors.fill: parent
|
||||
itemId: videoPage.itemId
|
||||
player: appWindow.mediaPlayer
|
||||
title: itemData.Name
|
||||
audioTrack: videoPage.audioTrack
|
||||
subtitleTrack: videoPage.subtitleTrack
|
||||
startTicks: videoPage.startTicks
|
||||
|
||||
onLandscapeChanged: {
|
||||
console.log("Is landscape: " + landscape)
|
||||
//appWindow.orientation = landscape ? Orientation.Landscape : Orientation.Portrait
|
||||
videoPage.allowedOrientations = landscape ? Orientation.LandscapeMask : Orientation.PortraitMask
|
||||
}
|
||||
}
|
||||
|
||||
onStatusChanged: {
|
||||
switch(status) {
|
||||
case PageStatus.Inactive:
|
||||
videoPlayer.stop()
|
||||
break;
|
||||
case PageStatus.Active:
|
||||
appWindow.itemData = videoPage.itemData
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
89
sailfish/qml/pages/itemdetails/BaseDetailPage.qml
Normal file
89
sailfish/qml/pages/itemdetails/BaseDetailPage.qml
Normal file
|
@ -0,0 +1,89 @@
|
|||
/*
|
||||
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"
|
||||
|
||||
/**
|
||||
* This page displays details about a film, show, season, episode, and so on.
|
||||
*
|
||||
* It contains the common functionality for all items. Additional components are
|
||||
* loaded in for every specific type of items, from ../components/itemdetails.
|
||||
*/
|
||||
Page {
|
||||
id: pageRoot
|
||||
property alias itemId: jItem.jellyfinId
|
||||
property alias itemData: jItem
|
||||
//property string itemId: ""
|
||||
//property var itemData: ({})
|
||||
property bool _loading: jItem.status === "Loading"
|
||||
readonly property bool hasLogo: (typeof itemData.ImageTags !== "undefined") && (typeof itemData.ImageTags["Logo"] !== "undefined")
|
||||
readonly property var _backdropImages: itemData.BackdropImageTags
|
||||
readonly property var _parentBackdropImages: itemData.ParentBackdropImageTags
|
||||
readonly property string parentId: itemData.ParentId || ""
|
||||
property alias backdrop: backdrop
|
||||
|
||||
on_BackdropImagesChanged: updateBackdrop()
|
||||
on_ParentBackdropImagesChanged: updateBackdrop()
|
||||
|
||||
function updateBackdrop() {
|
||||
return;
|
||||
if (_backdropImages && _backdropImages.length > 0) {
|
||||
var rand = Math.floor(Math.random() * (_backdropImages.length - 0.001))
|
||||
console.log("Random: ", rand)
|
||||
backdrop.source = ApiClient.baseUrl + "/Items/" + itemId + "/Images/Backdrop/" + rand + "?tag=" + _backdropImages[rand] + "&maxHeight" + height
|
||||
} else if (_parentBackdropImages && _parentBackdropImages.length > 0) {
|
||||
console.log(parentId)
|
||||
backdrop.source = ApiClient.baseUrl + "/Items/" + itemData.ParentBackdropItemId + "/Images/Backdrop/0?tag=" + _parentBackdropImages[0]
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
allowedOrientations: Orientation.All
|
||||
GlassyBackground {
|
||||
id: backdrop
|
||||
anchors.fill: parent
|
||||
}
|
||||
|
||||
PageBusyIndicator {
|
||||
running: pageRoot._loading
|
||||
}
|
||||
|
||||
JellyfinItem {
|
||||
id: jItem
|
||||
apiClient: ApiClient
|
||||
onStatusChanged: {
|
||||
console.log("Status changed: " + newStatus, JSON.stringify(jItem))
|
||||
console.log(jItem.mediaStreams)
|
||||
}
|
||||
}
|
||||
|
||||
onStatusChanged: {
|
||||
if (status == PageStatus.Deactivating) {
|
||||
backdrop.clear()
|
||||
//appWindow.itemData = ({})
|
||||
}
|
||||
if (status == PageStatus.Active) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
158
sailfish/qml/pages/itemdetails/CollectionPage.qml
Normal file
158
sailfish/qml/pages/itemdetails/CollectionPage.qml
Normal file
|
@ -0,0 +1,158 @@
|
|||
/*
|
||||
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 "../.."
|
||||
import "../../components"
|
||||
|
||||
BaseDetailPage {
|
||||
id: pageRoot
|
||||
|
||||
UserItemModel {
|
||||
id: collectionModel
|
||||
apiClient: ApiClient
|
||||
parentId: itemData.jellyfinId
|
||||
sortBy: ["SortName"]
|
||||
onParentIdChanged: reload()
|
||||
}
|
||||
|
||||
SilicaGridView {
|
||||
id: gridView
|
||||
anchors.fill: parent
|
||||
model: collectionModel
|
||||
cellWidth: Constants.libraryDelegateWidth
|
||||
cellHeight: Utils.usePortraitCover(itemData.CollectionType) ? Constants.libraryDelegatePosterHeight
|
||||
: Constants.libraryDelegateHeight
|
||||
header: PageHeader {
|
||||
title: itemData.Name || qsTr("Loading")
|
||||
}
|
||||
PullDownMenu {
|
||||
id: downMenu
|
||||
MenuItem {
|
||||
//: Menu item for selecting the sort order of a collection
|
||||
text: qsTr("Sort by")
|
||||
onClicked: pageStack.push(sortPageComponent)
|
||||
}
|
||||
busy: collectionModel.status == ApiModel.Loading
|
||||
}
|
||||
delegate: GridItem {
|
||||
RemoteImage {
|
||||
id: itemImage
|
||||
anchors.fill: parent
|
||||
source: Utils.itemModelImageUrl(ApiClient.baseUrl, model.id, model.imageTags["Primary"], "Primary", {"maxWidth": width})
|
||||
fallbackColor: Utils.colorFromString(model.name)
|
||||
fillMode: Image.PreserveAspectCrop
|
||||
clip: true
|
||||
}
|
||||
Shim {
|
||||
anchors {
|
||||
left: parent.left
|
||||
bottom: parent.bottom
|
||||
right: parent.right
|
||||
}
|
||||
height: itemName.height + Theme.paddingMedium * 2
|
||||
visible: itemImage.status !== Image.Null
|
||||
}
|
||||
Label {
|
||||
id: itemName
|
||||
anchors {
|
||||
left: parent.left
|
||||
leftMargin: Theme.paddingMedium
|
||||
right: parent.right
|
||||
rightMargin: Theme.paddingMedium
|
||||
bottom: parent.bottom
|
||||
bottomMargin: Theme.paddingSmall
|
||||
}
|
||||
text: model.name
|
||||
truncationMode: TruncationMode.Fade
|
||||
horizontalAlignment: Text.AlignLeft
|
||||
font.pixelSize: Theme.fontSizeSmall
|
||||
}
|
||||
onClicked: pageStack.push(Utils.getPageUrl(model.mediaType, model.type), {"itemId": model.id})
|
||||
}
|
||||
|
||||
ViewPlaceholder {
|
||||
enabled: gridView.count == 0 && !pageRoot._loading
|
||||
text: qsTr("Empty collection")
|
||||
hintText: qsTr("Add some items to this collection!")
|
||||
}
|
||||
|
||||
VerticalScrollDecorator {}
|
||||
}
|
||||
|
||||
// The page for selecting a sort order
|
||||
|
||||
Component {
|
||||
id: sortPageComponent
|
||||
Page {
|
||||
id: sortPage
|
||||
|
||||
ListModel {
|
||||
id: sortOptions
|
||||
ListElement { name: qsTr("Name"); value: "SortName"; }
|
||||
ListElement { name: qsTr("Play count"); value: "PlayCount"; }
|
||||
ListElement { name: qsTr("Date added"); value: "DateCreated"; }
|
||||
}
|
||||
|
||||
SilicaListView {
|
||||
anchors.fill: parent
|
||||
model: sortOptions
|
||||
header: PageHeader {
|
||||
title: qsTr("Sort by")
|
||||
}
|
||||
delegate: ListItem {
|
||||
Label {
|
||||
anchors {
|
||||
left: parent.left
|
||||
leftMargin: Theme.horizontalPageMargin
|
||||
right: parent.right
|
||||
rightMargin: Theme.horizontalPageMargin
|
||||
verticalCenter: parent.verticalCenter
|
||||
}
|
||||
text: model.name
|
||||
}
|
||||
menu: ContextMenu {
|
||||
MenuItem {
|
||||
//: Sort order
|
||||
text: qsTr("Ascending")
|
||||
onClicked: apply(model.value, ApiModel.Ascending)
|
||||
}
|
||||
MenuItem {
|
||||
//: Sort order
|
||||
text: qsTr("Descending")
|
||||
onClicked: apply(model.value, ApiModel.Descending)
|
||||
}
|
||||
}
|
||||
onClicked: openMenu()
|
||||
|
||||
function apply(field, order) {
|
||||
collectionModel.sortBy = [field];
|
||||
collectionModel.sortOrder = order;
|
||||
collectionModel.reload()
|
||||
pageStack.pop()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
48
sailfish/qml/pages/itemdetails/EpisodePage.qml
Normal file
48
sailfish/qml/pages/itemdetails/EpisodePage.qml
Normal file
|
@ -0,0 +1,48 @@
|
|||
/*
|
||||
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 "../../"
|
||||
|
||||
VideoPage {
|
||||
subtitle: {
|
||||
if (itemData.indexNumberEnd >= 0) {
|
||||
qsTr("Episode %1–%2 | %3").arg(itemData.indexNumber)
|
||||
.arg(itemData.indexNumberEnd)
|
||||
.arg(itemData.seasonName)
|
||||
} else {
|
||||
qsTr("Episode %1 | %2").arg(itemData.indexNumber).arg(itemData.seasonName)
|
||||
}
|
||||
}
|
||||
|
||||
SectionHeader {
|
||||
text: qsTr("Overview")
|
||||
}
|
||||
|
||||
PlainLabel {
|
||||
id: overviewText
|
||||
text: itemData.overview || qsTr("No overview available")
|
||||
font.pixelSize: Theme.fontSizeSmall
|
||||
color: Theme.secondaryHighlightColor
|
||||
}
|
||||
}
|
41
sailfish/qml/pages/itemdetails/FilmPage.qml
Normal file
41
sailfish/qml/pages/itemdetails/FilmPage.qml
Normal file
|
@ -0,0 +1,41 @@
|
|||
/*
|
||||
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 "../.."
|
||||
|
||||
VideoPage {
|
||||
subtitle: qsTr("Released: %1 — Run time: %2").arg(itemData.productionYear).arg(Utils.ticksToText(itemData.runTimeTicks))
|
||||
|
||||
SectionHeader {
|
||||
text: qsTr("Overview")
|
||||
}
|
||||
|
||||
PlainLabel {
|
||||
id: overviewText
|
||||
text: itemData.overview
|
||||
font.pixelSize: Theme.fontSizeSmall
|
||||
color: Theme.secondaryHighlightColor
|
||||
}
|
||||
}
|
5
sailfish/qml/pages/itemdetails/MusicAlbumPage.qml
Normal file
5
sailfish/qml/pages/itemdetails/MusicAlbumPage.qml
Normal file
|
@ -0,0 +1,5 @@
|
|||
import QtQuick 2.0
|
||||
|
||||
Item {
|
||||
|
||||
}
|
137
sailfish/qml/pages/itemdetails/SeasonPage.qml
Normal file
137
sailfish/qml/pages/itemdetails/SeasonPage.qml
Normal file
|
@ -0,0 +1,137 @@
|
|||
/*
|
||||
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 "../.."
|
||||
import "../../components"
|
||||
import ".."
|
||||
|
||||
BaseDetailPage {
|
||||
ShowEpisodesModel {
|
||||
id: episodeModel
|
||||
apiClient: ApiClient
|
||||
show: itemData.seriesId
|
||||
seasonId: itemData.jellyfinId
|
||||
fields: ["Overview"]
|
||||
}
|
||||
|
||||
SilicaListView {
|
||||
anchors.fill: parent
|
||||
contentHeight: content.height
|
||||
header: PageHeader {
|
||||
title: itemData.name
|
||||
description: itemData.seriesName
|
||||
}
|
||||
model: episodeModel
|
||||
delegate: BackgroundItem {
|
||||
height: Constants.libraryDelegateHeight
|
||||
RemoteImage {
|
||||
id: episodeImage
|
||||
anchors {
|
||||
top: parent.top
|
||||
left: parent.left
|
||||
bottom: parent.bottom
|
||||
}
|
||||
width: Constants.libraryDelegateWidth
|
||||
height: Constants.libraryDelegateHeight
|
||||
source: Utils.itemModelImageUrl(ApiClient.baseUrl, model.id, model.imageTags["Primary"], "Primary", {"maxHeight": height})
|
||||
fillMode: Image.PreserveAspectCrop
|
||||
clip: true
|
||||
|
||||
// Makes the progress bar stand out more
|
||||
Shim {
|
||||
anchors {
|
||||
left: parent.left
|
||||
bottom: parent.bottom
|
||||
right: parent.right
|
||||
}
|
||||
height: parent.height / 3
|
||||
shimColor: Theme.overlayBackgroundColor
|
||||
shimOpacity: Theme.opacityOverlay
|
||||
//width: model.userData.PlayedPercentage * parent.width / 100
|
||||
visible: episodeProgress.width > 0 // It doesn't look nice when it's visible on every image
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
id: episodeProgress
|
||||
anchors {
|
||||
left: parent.left
|
||||
bottom: parent.bottom
|
||||
}
|
||||
height: Theme.paddingMedium
|
||||
width: model.userData.PlayedPercentage * parent.width / 100
|
||||
color: Theme.highlightColor
|
||||
}
|
||||
}
|
||||
|
||||
Label {
|
||||
id: episodeTitle
|
||||
anchors {
|
||||
left: episodeImage.right
|
||||
leftMargin: Theme.paddingLarge
|
||||
top: parent.top
|
||||
right: parent.right
|
||||
rightMargin: Theme.horizontalPageMargin
|
||||
}
|
||||
text: model.name
|
||||
truncationMode: TruncationMode.Fade
|
||||
horizontalAlignment: Text.AlignLeft
|
||||
}
|
||||
|
||||
Label {
|
||||
id: episodeOverview
|
||||
anchors {
|
||||
left: episodeImage.right
|
||||
leftMargin: Theme.paddingLarge
|
||||
right: parent.right
|
||||
rightMargin: Theme.horizontalPageMargin
|
||||
top: episodeTitle.bottom
|
||||
bottom: parent.bottom
|
||||
}
|
||||
color: highlighted ? Theme.secondaryHighlightColor: Theme.secondaryColor
|
||||
font.pixelSize: Theme.fontSizeExtraSmall
|
||||
//: No overview/summary text of an episode available
|
||||
text: model.overview || qsTr("No overview available")
|
||||
wrapMode: Text.WordWrap
|
||||
elide: Text.ElideRight
|
||||
}
|
||||
onClicked: pageStack.push(Utils.getPageUrl(model.mediaType, model.type), {"itemId": model.id})
|
||||
}
|
||||
|
||||
VerticalScrollDecorator {}
|
||||
}
|
||||
Connections {
|
||||
target: itemData
|
||||
onStatusChanged: {
|
||||
if (itemData.status == JellyfinItem.Ready) {
|
||||
episodeModel.reload()
|
||||
}
|
||||
}
|
||||
}
|
||||
onStatusChanged: {
|
||||
if (status == PageStatus.Active) {
|
||||
console.log(JSON.stringify(itemData))
|
||||
episodeModel.show = itemData.seriesId
|
||||
episodeModel.seasonId = itemData.jellyfinId
|
||||
}
|
||||
}
|
||||
}
|
103
sailfish/qml/pages/itemdetails/SeriesPage.qml
Normal file
103
sailfish/qml/pages/itemdetails/SeriesPage.qml
Normal file
|
@ -0,0 +1,103 @@
|
|||
/*
|
||||
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 "../.."
|
||||
|
||||
BaseDetailPage {
|
||||
SilicaFlickable {
|
||||
anchors.fill: parent
|
||||
contentHeight: content.height
|
||||
|
||||
Column {
|
||||
id: content
|
||||
width: parent.width
|
||||
|
||||
PageHeader {
|
||||
id: header
|
||||
title: itemData.name
|
||||
visible: !hasLogo
|
||||
}
|
||||
|
||||
Item {
|
||||
visible: hasLogo
|
||||
width: parent.width
|
||||
height: Math.max(logoImage.height, header.height) + 2 * Theme.paddingLarge
|
||||
RemoteImage {
|
||||
id: logoImage
|
||||
anchors.centerIn: parent
|
||||
source: Utils.itemImageUrl(ApiClient.baseUrl, itemData, "Logo")
|
||||
}
|
||||
}
|
||||
|
||||
PlainLabel {
|
||||
id: overviewText
|
||||
text: itemData.overview
|
||||
font.pixelSize: Theme.fontSizeSmall
|
||||
color: Theme.secondaryHighlightColor
|
||||
}
|
||||
|
||||
SectionHeader {
|
||||
//: Seasons of a (TV) show
|
||||
text: qsTr("Seasons")
|
||||
}
|
||||
|
||||
ShowSeasonsModel {
|
||||
id: showSeasonsModel
|
||||
apiClient: ApiClient
|
||||
show: itemData.jellyfinId
|
||||
onShowChanged: reload()
|
||||
}
|
||||
|
||||
SilicaListView {
|
||||
model: showSeasonsModel
|
||||
clip: true
|
||||
width: parent.width
|
||||
height: Screen.width / 2
|
||||
orientation: ListView.Horizontal
|
||||
spacing: Theme.paddingLarge
|
||||
leftMargin: Theme.horizontalPageMargin
|
||||
rightMargin: Theme.horizontalPageMargin
|
||||
delegate: LibraryItemDelegate {
|
||||
poster: Utils.itemModelImageUrl(ApiClient.baseUrl, model.id, model.imageTags["Primary"], "Primary", {"maxHeight": height})
|
||||
title: model.name
|
||||
onClicked: pageStack.push(Utils.getPageUrl(model.mediaType, model.type), {"itemId": model.id})
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/*onStatusChanged: {
|
||||
if (status == PageStatus.Active) {
|
||||
showSeasonsModel.reload()
|
||||
}
|
||||
}*/
|
||||
Connections {
|
||||
target: itemData
|
||||
onJellyfinIdChanged: {
|
||||
console.log("Item id changed")
|
||||
//showSeasonsModel.show = itemData.jellyfinId
|
||||
}
|
||||
}
|
||||
}
|
36
sailfish/qml/pages/itemdetails/UnsupportedPage.qml
Normal file
36
sailfish/qml/pages/itemdetails/UnsupportedPage.qml
Normal file
|
@ -0,0 +1,36 @@
|
|||
/*
|
||||
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
|
||||
|
||||
BaseDetailPage {
|
||||
SilicaFlickable {
|
||||
anchors.fill: parent
|
||||
PageHeader {
|
||||
title: itemData.name
|
||||
}
|
||||
ViewPlaceholder {
|
||||
|
||||
enabled: true
|
||||
text: qsTr("Item type (%1) unsupported").arg(itemData.type)
|
||||
hintText: qsTr("This is still an alpha version :)")
|
||||
}
|
||||
}
|
||||
}
|
82
sailfish/qml/pages/itemdetails/VideoPage.qml
Normal file
82
sailfish/qml/pages/itemdetails/VideoPage.qml
Normal file
|
@ -0,0 +1,82 @@
|
|||
/*
|
||||
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 "../.."
|
||||
|
||||
/**
|
||||
* Fallback page for everything that's a video, but we haven't a more specific page for, like
|
||||
* the FilmPage or EpisodePage.
|
||||
*/
|
||||
BaseDetailPage {
|
||||
property alias subtitle: pageHeader.description
|
||||
default property alias _data: content.data
|
||||
SilicaFlickable {
|
||||
anchors.fill: parent
|
||||
contentHeight: content.height + Theme.paddingLarge
|
||||
|
||||
VerticalScrollDecorator {}
|
||||
|
||||
Column {
|
||||
id: content
|
||||
width: parent.width
|
||||
spacing: Theme.paddingMedium
|
||||
|
||||
PageHeader {
|
||||
id: pageHeader
|
||||
title: itemData.name
|
||||
description: qsTr("Run time: %2").arg(Utils.ticksToText(itemData.runTimeTicks))
|
||||
}
|
||||
|
||||
PlayToolbar {
|
||||
id: toolbar
|
||||
width: parent.width
|
||||
imageSource: Utils.itemImageUrl(ApiClient.baseUrl, itemData, "Primary", {"maxWidth": parent.width})
|
||||
imageAspectRatio: Constants.horizontalVideoAspectRatio
|
||||
playProgress: itemData.UserData.PlayedPercentage / 100
|
||||
onPlayPressed: pageStack.push(Qt.resolvedUrl("../VideoPage.qml"),
|
||||
{"itemId": itemId, "itemData": itemData,
|
||||
"audioTrack": trackSelector.audioTrack,
|
||||
"subtitleTrack": trackSelector.subtitleTrack,
|
||||
"startTicks": startFromBeginning ? 0.0
|
||||
: itemData.UserData.PlaybackPositionTicks })
|
||||
}
|
||||
|
||||
VideoTrackSelector {
|
||||
id: trackSelector
|
||||
width: parent.width
|
||||
tracks: itemData.mediaStreams
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Connections {
|
||||
target: itemData
|
||||
onStatusChanged: {
|
||||
if (status == JellyfinItem.Ready) {
|
||||
console.log(itemData.mediaStreams)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
61
sailfish/qml/pages/setup/AddServerConnectingPage.qml
Normal file
61
sailfish/qml/pages/setup/AddServerConnectingPage.qml
Normal file
|
@ -0,0 +1,61 @@
|
|||
/*
|
||||
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
|
||||
|
||||
/**
|
||||
* Page to indicate that the application is connecting to a server.
|
||||
*/
|
||||
Page {
|
||||
property string serverName
|
||||
property string serverAddress
|
||||
property Page firstPage
|
||||
|
||||
allowedOrientations: Orientation.All
|
||||
|
||||
|
||||
BusyLabel {
|
||||
text: qsTr("Connecting to %1").arg(serverName)
|
||||
running: true
|
||||
}
|
||||
|
||||
onStatusChanged: {
|
||||
if (status == PageStatus.Active) {
|
||||
console.log("Connecting page active");
|
||||
ApiClient.setupConnection();
|
||||
}
|
||||
}
|
||||
|
||||
Connections {
|
||||
target: ApiClient
|
||||
onConnectionSuccess: {
|
||||
console.log("Login success: " + loginMessage);
|
||||
pageStack.replace(Qt.resolvedUrl("LoginDialog.qml"), {"loginMessage": loginMessage, "firstPage": firstPage});
|
||||
}
|
||||
onConnectionFailed: function(error) {
|
||||
console.log("Connection failed : " + error)
|
||||
pageStack.pop();
|
||||
}
|
||||
onNetworkError: {
|
||||
console.log("ConnectingPage: popping page!")
|
||||
pageStack.pop();
|
||||
}
|
||||
}
|
||||
}
|
113
sailfish/qml/pages/setup/AddServerPage.qml
Normal file
113
sailfish/qml/pages/setup/AddServerPage.qml
Normal file
|
@ -0,0 +1,113 @@
|
|||
/*
|
||||
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
|
||||
|
||||
/**
|
||||
* Dialog showed when the user has to connect to a Jellyfin server.
|
||||
*
|
||||
* This dialog allows manual address entry or use one of the addresses discovered via UDP broadcasts.
|
||||
*/
|
||||
Dialog {
|
||||
id: dialogRoot
|
||||
allowedOrientations: Orientation.All
|
||||
// Picks the address of the ComboBox if selected, otherwise the manual address entry
|
||||
readonly property string address: serverSelect.currentItem._address
|
||||
readonly property bool addressCorrect: serverSelect.currentIndex > 0 || manualAddress.acceptableInput
|
||||
readonly property string serverName: serverSelect.currentItem._name
|
||||
readonly property bool _isSetupPage: true
|
||||
|
||||
|
||||
acceptDestination: AddServerConnectingPage {
|
||||
id: connectingPage
|
||||
serverName: dialogRoot.serverName
|
||||
serverAddress: address
|
||||
firstPage: dialogRoot
|
||||
}
|
||||
|
||||
Column {
|
||||
width: parent.width
|
||||
DialogHeader {
|
||||
acceptText: qsTr("Connect")
|
||||
title: qsTr("Connect to Jellyfin")
|
||||
}
|
||||
|
||||
ServerDiscoveryModel {
|
||||
id: serverModel
|
||||
}
|
||||
|
||||
|
||||
ComboBox {
|
||||
id: serverSelect
|
||||
label: qsTr("Server")
|
||||
description: qsTr("Sailfin will try to search for Jellyfin servers on your local network automatically")
|
||||
|
||||
menu: ContextMenu {
|
||||
MenuItem {
|
||||
// Special values are cool, aren't they?
|
||||
readonly property string _address: manualAddress.text
|
||||
readonly property string _name: manualAddress.text
|
||||
text: qsTr("enter address manually")
|
||||
}
|
||||
Repeater {
|
||||
model: serverModel
|
||||
delegate: MenuItem {
|
||||
readonly property string _address: address
|
||||
readonly property string _name: name
|
||||
text: qsTr("%1 - %2").arg(name).arg(address)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
TextField {
|
||||
id: manualAddress
|
||||
width: parent.width
|
||||
clip: true
|
||||
|
||||
label: qsTr("Server address")
|
||||
placeholderText: qsTr("e.g. https://demo.jellyfin.org")
|
||||
|
||||
enabled: serverSelect.currentIndex == 0
|
||||
visible: enabled
|
||||
|
||||
inputMethodHints: Qt.ImhUrlCharactersOnly
|
||||
validator: RegExpValidator {
|
||||
regExp: /^https?:\/\/[a-zA-Z0-9-._~:/?#\[\]\@\!\$\&\'\(\)\*\+\,\;\=]+$/m
|
||||
}
|
||||
|
||||
EnterKey.enabled: addressCorrect
|
||||
EnterKey.iconSource: "image://theme/icon-m-enter-accept"
|
||||
EnterKey.onClicked: accept()
|
||||
}
|
||||
}
|
||||
|
||||
onOpened: serverModel.refresh()
|
||||
canAccept: addressCorrect
|
||||
|
||||
function tryConnect() {
|
||||
console.log("Hi there!")
|
||||
ApiClient.baseUrl = address;
|
||||
//ApiClient.setupConnection()
|
||||
//fakeTimer.start()
|
||||
}
|
||||
|
||||
onDone: tryConnect()
|
||||
}
|
172
sailfish/qml/pages/setup/LoginDialog.qml
Normal file
172
sailfish/qml/pages/setup/LoginDialog.qml
Normal file
|
@ -0,0 +1,172 @@
|
|||
/*
|
||||
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"
|
||||
|
||||
/**
|
||||
* Page where the user can login on their server. Is displayed after the AddServerPage successfully connected
|
||||
* to a Jellyfin server. This page also displays a login message and, if applicable, a list of public users.
|
||||
*/
|
||||
|
||||
Dialog {
|
||||
id: loginDialog
|
||||
property string loginMessage
|
||||
property Page firstPage
|
||||
|
||||
property string error
|
||||
|
||||
allowedOrientations: Orientation.All
|
||||
|
||||
|
||||
acceptDestination: Page {
|
||||
BusyLabel {
|
||||
text: qsTr("Logging in as %1").arg(username.text)
|
||||
running: true
|
||||
}
|
||||
onStatusChanged: {
|
||||
if(status == PageStatus.Active) {
|
||||
ApiClient.authenticate(username.text, password.text, true)
|
||||
}
|
||||
}
|
||||
|
||||
Connections {
|
||||
target: ApiClient
|
||||
onAuthenticatedChanged: {
|
||||
if (ApiClient.authenticated) {
|
||||
console.log("authenticated!")
|
||||
pageStack.replaceAbove(null, Qt.resolvedUrl("../MainPage.qml"))
|
||||
}
|
||||
}
|
||||
onAuthenticationError: {
|
||||
loginDialog.error = qsTr("Invalid username or password")
|
||||
pageStack.completeAnimation()
|
||||
pageStack.pop()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
PublicUserModel {
|
||||
id: userModel
|
||||
apiClient: ApiClient
|
||||
Component.onCompleted: reload();
|
||||
}
|
||||
|
||||
DialogHeader {
|
||||
id: dialogHeader
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
//: Dialog action
|
||||
acceptText: qsTr("Login");
|
||||
}
|
||||
SilicaFlickable {
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
anchors.top: dialogHeader.bottom
|
||||
anchors.bottom: parent.bottom
|
||||
contentHeight: column.height
|
||||
clip: true
|
||||
|
||||
VerticalScrollDecorator {}
|
||||
|
||||
Column {
|
||||
id: column
|
||||
width: parent.width
|
||||
|
||||
Flow {
|
||||
width: parent.width
|
||||
Repeater {
|
||||
model: userModel
|
||||
delegate: UserGridDelegate {
|
||||
name: model.name
|
||||
image: model.primaryImageTag ? "%1/Users/%2/Images/Primary?tag=%3".arg(ApiClient.baseUrl).arg(model.id).arg(model.primaryImageTag) : ""
|
||||
highlighted: model.name === username.text
|
||||
onClicked: {
|
||||
username.text = model.name
|
||||
password.focus = true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
SectionHeader {
|
||||
//: Section header for entering username and password
|
||||
text: qsTr("Credentials")
|
||||
}
|
||||
|
||||
TextField {
|
||||
id: username
|
||||
width: parent.width
|
||||
//: Label placeholder for username field
|
||||
placeholderText: qsTr("Username")
|
||||
label: placeholderText
|
||||
errorHighlight: error
|
||||
EnterKey.iconSource: "image://theme/icon-m-enter-next"
|
||||
EnterKey.onClicked: password.focus = true
|
||||
}
|
||||
|
||||
TextField {
|
||||
id: password
|
||||
width: parent.width
|
||||
|
||||
//: Label placeholder for password field
|
||||
placeholderText: qsTr("Password")
|
||||
label: placeholderText
|
||||
echoMode: TextInput.Password
|
||||
errorHighlight: error
|
||||
|
||||
EnterKey.iconSource: "image://theme/icon-m-enter-accept"
|
||||
EnterKey.onClicked: accept()
|
||||
}
|
||||
|
||||
Label {
|
||||
anchors {
|
||||
left: parent.left
|
||||
leftMargin: Theme.horizontalPageMargin
|
||||
right: parent.right
|
||||
rightMargin: Theme.horizontalPageMargin
|
||||
}
|
||||
text: error
|
||||
color: Theme.errorColor
|
||||
visible: error
|
||||
}
|
||||
|
||||
SectionHeader {
|
||||
//: Message shown on login, configured by the server owner. Some form of a MOTD
|
||||
text: qsTr("Login message")
|
||||
visible: loginMessage
|
||||
}
|
||||
Label {
|
||||
anchors {
|
||||
left: parent.left
|
||||
right: parent.right
|
||||
leftMargin: Theme.horizontalPageMargin
|
||||
rightMargin: Theme.horizontalPageMargin
|
||||
}
|
||||
visible: loginMessage
|
||||
text: loginMessage
|
||||
wrapMode: Text.WordWrap
|
||||
color: Theme.highlightColor
|
||||
}
|
||||
}
|
||||
}
|
||||
canAccept: username.text
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue