1
0
Fork 0
mirror of https://github.com/HenkKalkwater/harbour-sailfin.git synced 2025-09-01 08:52:45 +00:00

Models get updated when userData changes at server

The websocket now notifies the ApiClient, on which several models and
items are listening, when the userData for an user has changed. The UI
on the qml side may automatically updates without any extra effort.

This also resolves a bug where videos didn't resume after +/- 3:40 due
to an integer overflow.
This commit is contained in:
Chris Josten 2020-10-09 02:33:08 +02:00
parent 1e80ceb697
commit d81fa50715
17 changed files with 304 additions and 44 deletions

View file

@ -86,5 +86,6 @@ BackgroundItem {
height: Theme.paddingSmall
color: Theme.highlightColor
width: root.progress * parent.width
Behavior on width { SmoothedAnimation {} }
}
}

View file

@ -24,6 +24,7 @@ Column {
property alias imageSource : playImage.source
property real imageAspectRatio: 1.0
property real playProgress: 0.0
property bool favourited: false
signal playPressed(bool startFromBeginning)
spacing: Theme.paddingLarge
@ -73,7 +74,8 @@ Column {
}
IconButton {
id: favouriteButton
icon.source: "image://theme/icon-m-favorite"
icon.source: favourited ? "image://theme/icon-m-favorite-selected"
: "image://theme/icon-m-favorite"
}
}

View file

@ -39,7 +39,7 @@ SilicaItem {
readonly property bool hudVisible: !hud.hidden || player.error !== MediaPlayer.NoError
property alias audioTrack: mediaSource.audioIndex
property alias subtitleTrack: mediaSource.subtitleIndex
property int startTicks: 0
property real startTicks: 0
// Force a Light on Dark theme since I doubt that there are persons who are willing to watch a Video
// on a white background.

View file

@ -198,12 +198,12 @@ Page {
delegate: LibraryItemDelegate {
property string id: model.id
title: model.name
poster: Utils.itemModelImageUrl(ApiClient.baseUrl, model.id, model.imageTags["Primary"], "Primary", {"maxHeight": height})
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
progress: (typeof model.userData !== "undefined") ? model.userData.playedPercentage / 100 : 0.0
onClicked: {
pageStack.push(Utils.getPageUrl(model.mediaType, model.type), {"itemId": model.id})

View file

@ -33,7 +33,7 @@ Page {
property var itemData
property int audioTrack
property int subtitleTrack
property int startTicks: 0
property real startTicks: 0 // Why is this a real? Because an integer only goes to 3:44 when the ticks are converted to doubles
allowedOrientations: Orientation.All
showNavigationIndicator: videoPlayer.hudVisible
@ -43,7 +43,7 @@ Page {
anchors.fill: parent
itemId: videoPage.itemId
player: appWindow.mediaPlayer
title: itemData.Name
title: itemData.name
audioTrack: videoPage.audioTrack
subtitleTrack: videoPage.subtitleTrack
startTicks: videoPage.startTicks

View file

@ -53,7 +53,7 @@ BaseDetailPage {
}
width: Constants.libraryDelegateWidth
height: Constants.libraryDelegateHeight
source: Utils.itemModelImageUrl(ApiClient.baseUrl, model.id, model.imageTags["Primary"], "Primary", {"maxHeight": height})
source: Utils.itemModelImageUrl(ApiClient.baseUrl, model.id, model.imageTags.primary, "Primary", {"maxHeight": height})
fillMode: Image.PreserveAspectCrop
clip: true
@ -78,7 +78,7 @@ BaseDetailPage {
bottom: parent.bottom
}
height: Theme.paddingMedium
width: model.userData.PlayedPercentage * parent.width / 100
width: model.userData.playedPercentage * parent.width / 100
color: Theme.highlightColor
}
}

View file

@ -79,7 +79,7 @@ BaseDetailPage {
leftMargin: Theme.horizontalPageMargin
rightMargin: Theme.horizontalPageMargin
delegate: LibraryItemDelegate {
poster: Utils.itemModelImageUrl(ApiClient.baseUrl, model.id, model.imageTags["Primary"], "Primary", {"maxHeight": height})
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})
}

View file

@ -32,6 +32,7 @@ import "../.."
BaseDetailPage {
property alias subtitle: pageHeader.description
default property alias _data: content.data
property real _playbackProsition: itemData.userData.playbackPositionTicks
SilicaFlickable {
anchors.fill: parent
contentHeight: content.height + Theme.paddingLarge
@ -54,13 +55,14 @@ BaseDetailPage {
width: parent.width
imageSource: Utils.itemImageUrl(ApiClient.baseUrl, itemData, "Primary", {"maxWidth": parent.width})
imageAspectRatio: Constants.horizontalVideoAspectRatio
playProgress: itemData.UserData.PlayedPercentage / 100
favourited: itemData.userData.isFavorite
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 })
: _playbackProsition })
}
VideoTrackSelector {