2020-09-27 18:38:33 +00:00
|
|
|
/*
|
|
|
|
Sailfin: a Jellyfin client written using Qt
|
2024-01-02 20:43:45 +00:00
|
|
|
Copyright (C) 2020-2024 Chris Josten
|
2020-09-27 18:38:33 +00:00
|
|
|
|
|
|
|
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-27 14:54:45 +00:00
|
|
|
import QtQuick 2.6
|
|
|
|
import Sailfish.Silica 1.0
|
|
|
|
|
2021-07-31 13:06:17 +00:00
|
|
|
import nl.netsoj.chris.Jellyfin 1.0 as J
|
2020-09-27 14:54:45 +00:00
|
|
|
|
Restructured the way item "details" are loaded
Previously, Items were displayed in one page, named DetailPage.qml.
This page then would load a qml component, based on the page type. It
also contained some components common for each detail page, like
displaying the name of the item. This construction had as downside that
modifying the page properties, adding a pulley menu or basing the page
around a SilicaListview was not possible. So I already had created some
other pages.
The new construction uses a base page, named BaseDetailPage which does
set some common properties and handle the loading of the items, so that
that part does not have to be duplicated. Displaying the name of an item
was a very trivial thing to do, so duplicating that part across files
was not a problem. Anyway, the rest of the pages are now seperate, but
all have BaseDetailsPage as the root, so they can use the common
functionality by that page. Those subpages now can be based around
GridViews, Carrousels, have pully menus and so on. To determine to which
page to go to, based on the content type, a function named getPageUrl
has been added to Utils.js, which takes a content type as argument and
gives the page url back.
2020-09-29 00:15:50 +00:00
|
|
|
import "../.."
|
|
|
|
import "../../components"
|
2020-09-27 14:54:45 +00:00
|
|
|
|
Restructured the way item "details" are loaded
Previously, Items were displayed in one page, named DetailPage.qml.
This page then would load a qml component, based on the page type. It
also contained some components common for each detail page, like
displaying the name of the item. This construction had as downside that
modifying the page properties, adding a pulley menu or basing the page
around a SilicaListview was not possible. So I already had created some
other pages.
The new construction uses a base page, named BaseDetailPage which does
set some common properties and handle the loading of the items, so that
that part does not have to be duplicated. Displaying the name of an item
was a very trivial thing to do, so duplicating that part across files
was not a problem. Anyway, the rest of the pages are now seperate, but
all have BaseDetailsPage as the root, so they can use the common
functionality by that page. Those subpages now can be based around
GridViews, Carrousels, have pully menus and so on. To determine to which
page to go to, based on the content type, a function named getPageUrl
has been added to Utils.js, which takes a content type as argument and
gives the page url back.
2020-09-29 00:15:50 +00:00
|
|
|
BaseDetailPage {
|
2020-09-27 14:54:45 +00:00
|
|
|
id: pageRoot
|
|
|
|
|
2021-09-10 03:18:05 +00:00
|
|
|
property bool _collectionModelLoaded: false
|
2022-07-28 17:55:33 +00:00
|
|
|
property bool allowSort: true
|
|
|
|
property var modelStatus: collectionModel.loader.modelStatus
|
|
|
|
property string pageTitle: itemData.name
|
|
|
|
property alias loader: collectionModel.loader
|
2021-09-10 03:18:05 +00:00
|
|
|
|
2021-07-31 13:06:17 +00:00
|
|
|
J.ItemModel {
|
2020-09-27 14:54:45 +00:00
|
|
|
id: collectionModel
|
2021-07-31 13:06:17 +00:00
|
|
|
loader: J.UserItemsLoader {
|
2021-08-11 21:35:33 +00:00
|
|
|
id: collectionLoader
|
|
|
|
apiClient: appWindow.apiClient
|
2021-07-31 13:06:17 +00:00
|
|
|
parentId: itemData.jellyfinId
|
2021-08-11 21:35:33 +00:00
|
|
|
sortBy: "SortName"
|
2022-07-28 17:55:33 +00:00
|
|
|
autoReload: itemData.jellyfinId.length > 0 && (pageRoot.status == PageStatus.Active || _collectionModelLoaded)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Binding {
|
|
|
|
target: collectionModel.loader
|
|
|
|
property: "autoReload"
|
|
|
|
value: (pageRoot.status == PageStatus.Active || pageRoot._collectionModelLoaded)
|
|
|
|
}
|
|
|
|
|
|
|
|
Connections {
|
|
|
|
target: collectionModel.loader
|
|
|
|
onStatusChanged: {
|
|
|
|
if (status === J.ModelStatus.Ready) {
|
|
|
|
_collectionModelLoaded = true
|
2021-09-10 03:18:05 +00:00
|
|
|
}
|
2021-07-31 13:06:17 +00:00
|
|
|
}
|
2020-09-27 14:54:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
SilicaGridView {
|
|
|
|
id: gridView
|
|
|
|
anchors.fill: parent
|
|
|
|
model: collectionModel
|
|
|
|
cellWidth: Constants.libraryDelegateWidth
|
2021-02-20 22:20:39 +00:00
|
|
|
cellHeight: Utils.usePortraitCover(itemData.collectionType) ? Constants.libraryDelegatePosterHeight
|
2020-09-27 14:54:45 +00:00
|
|
|
: Constants.libraryDelegateHeight
|
2024-01-02 20:43:45 +00:00
|
|
|
visible: itemData.status !== J.LoaderBase.Error
|
2020-10-10 13:56:04 +00:00
|
|
|
|
2020-09-27 14:54:45 +00:00
|
|
|
header: PageHeader {
|
2022-07-28 17:55:33 +00:00
|
|
|
title: pageTitle || qsTr("Loading")
|
2020-09-27 14:54:45 +00:00
|
|
|
}
|
|
|
|
PullDownMenu {
|
|
|
|
id: downMenu
|
2022-07-29 12:26:25 +00:00
|
|
|
visible: pageRoot.allowSort
|
2024-01-02 20:43:45 +00:00
|
|
|
MenuItem {
|
|
|
|
//: Pulley menu item: navigate to application settings page
|
|
|
|
text: qsTr("Settings")
|
|
|
|
onClicked: pageStack.push(Qt.resolvedUrl("../SettingsPage.qml"))
|
|
|
|
}
|
|
|
|
MenuItem {
|
|
|
|
//: Pulley menu item: shows controllable device page
|
|
|
|
text: qsTr("Remote control")
|
|
|
|
onClicked: pageStack.push(Qt.resolvedUrl("../ControllableDevicesPage.qml"))
|
|
|
|
}
|
2020-09-27 14:54:45 +00:00
|
|
|
MenuItem {
|
2022-07-28 17:55:33 +00:00
|
|
|
id: sortMenuItem
|
2020-09-27 14:54:45 +00:00
|
|
|
//: Menu item for selecting the sort order of a collection
|
|
|
|
text: qsTr("Sort by")
|
|
|
|
onClicked: pageStack.push(sortPageComponent)
|
|
|
|
}
|
2022-07-28 17:55:33 +00:00
|
|
|
busy: modelStatus === J.ModelStatus.Loading
|
2021-09-10 03:18:05 +00:00
|
|
|
}
|
|
|
|
add: Transition {
|
|
|
|
id: trans
|
|
|
|
SequentialAnimation {
|
|
|
|
|
|
|
|
PropertyAction {
|
|
|
|
property: "opacity"; value: 0 }
|
|
|
|
PauseAnimation { duration: trans.ViewTransition.index * 3;}
|
|
|
|
NumberAnimation { properties: "opacity"; from: 0; to: 1.0; }
|
|
|
|
} // properties: "opacity"; from: 0; to: 1.0; }
|
2020-09-27 14:54:45 +00:00
|
|
|
}
|
|
|
|
delegate: GridItem {
|
|
|
|
RemoteImage {
|
|
|
|
id: itemImage
|
|
|
|
anchors.fill: parent
|
2021-08-11 21:35:33 +00:00
|
|
|
source: Utils.itemModelImageUrl(apiClient.baseUrl, model.jellyfinId, model.imageTags.Primary, "Primary", {"maxWidth": width})
|
2021-02-20 22:20:39 +00:00
|
|
|
blurhash: model.imageBlurHashes.Primary[model.imageTags.Primary]
|
2020-10-01 10:55:11 +00:00
|
|
|
fallbackColor: Utils.colorFromString(model.name)
|
2020-09-27 14:54:45 +00:00
|
|
|
fillMode: Image.PreserveAspectCrop
|
|
|
|
clip: true
|
|
|
|
}
|
2020-10-01 09:56:02 +00:00
|
|
|
Shim {
|
2020-09-27 14:54:45 +00:00
|
|
|
anchors {
|
|
|
|
left: parent.left
|
|
|
|
bottom: parent.bottom
|
|
|
|
right: parent.right
|
|
|
|
}
|
2020-10-01 10:55:11 +00:00
|
|
|
height: itemName.height + Theme.paddingMedium * 2
|
2020-09-27 14:54:45 +00:00
|
|
|
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
|
|
|
|
}
|
2021-09-10 01:08:40 +00:00
|
|
|
onClicked: appWindow.navigateToItem(model.jellyfinId, model.mediaType, model.type, model.isFolder);
|
2020-09-27 14:54:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
ViewPlaceholder {
|
2021-09-10 03:18:05 +00:00
|
|
|
enabled: gridView.count == 0 && !pageRoot._loading && collectionModel.status === J.ModelStatus.Ready
|
2020-09-27 14:54:45 +00:00
|
|
|
text: qsTr("Empty collection")
|
|
|
|
hintText: qsTr("Add some items to this collection!")
|
|
|
|
}
|
|
|
|
|
|
|
|
VerticalScrollDecorator {}
|
|
|
|
}
|
|
|
|
|
2020-10-01 09:56:02 +00:00
|
|
|
// The page for selecting a sort order
|
|
|
|
|
2020-09-27 14:54:45 +00:00
|
|
|
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
|
|
|
|
}
|
2020-10-01 09:56:02 +00:00
|
|
|
menu: ContextMenu {
|
|
|
|
MenuItem {
|
|
|
|
//: Sort order
|
|
|
|
text: qsTr("Ascending")
|
2021-08-11 21:35:33 +00:00
|
|
|
onClicked: apply(model.value, "Ascending")
|
2020-10-01 09:56:02 +00:00
|
|
|
}
|
|
|
|
MenuItem {
|
|
|
|
//: Sort order
|
|
|
|
text: qsTr("Descending")
|
2021-08-11 21:35:33 +00:00
|
|
|
onClicked: apply(model.value, "Descending")
|
2020-10-01 09:56:02 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
onClicked: openMenu()
|
|
|
|
|
|
|
|
function apply(field, order) {
|
2022-07-28 17:55:33 +00:00
|
|
|
collectionModel.loader.sortBy = field;
|
|
|
|
collectionModel.loader.sortOrder = order;
|
|
|
|
collectionModel.loader.reload()
|
2020-09-27 14:54:45 +00:00
|
|
|
pageStack.pop()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|