mirror of
https://github.com/HenkKalkwater/harbour-sailfin.git
synced 2025-09-05 18:22: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
91
sailfish/qml/components/videoplayer/VideoError.qml
Normal file
91
sailfish/qml/components/videoplayer/VideoError.qml
Normal file
|
@ -0,0 +1,91 @@
|
|||
/*
|
||||
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 QtMultimedia 5.6
|
||||
|
||||
Rectangle {
|
||||
id: videoError
|
||||
property MediaPlayer player
|
||||
color: pal.palette.overlayBackgroundColor
|
||||
opacity: player.error === MediaPlayer.NoError ? 0.0 : 1.0
|
||||
Behavior on opacity { FadeAnimator {} }
|
||||
|
||||
SilicaItem {
|
||||
id: pal
|
||||
}
|
||||
|
||||
Column {
|
||||
anchors.centerIn: parent
|
||||
anchors.margins: Theme.horizontalPageMargin
|
||||
|
||||
Label {
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
font.pixelSize: Theme.fontSizeExtraLarge
|
||||
color: Theme.errorColor
|
||||
text: {
|
||||
switch(player.error) {
|
||||
case MediaPlayer.NoError:
|
||||
//: Just to be complete if the application shows a video playback error when there's no error.
|
||||
qsTr("No error");
|
||||
break;
|
||||
case MediaPlayer.ResourceError:
|
||||
//: Video playback error: out of resources
|
||||
qsTr("Resource allocation error")
|
||||
break;
|
||||
case MediaPlayer.FormatError:
|
||||
//: Video playback error: unsupported format/codec
|
||||
qsTr("Video format unsupported")
|
||||
break;
|
||||
case MediaPlayer.NetworkError:
|
||||
//: Video playback error: network error
|
||||
qsTr("Network error")
|
||||
break;
|
||||
case MediaPlayer.AccessDenied:
|
||||
//: Video playback error: access denied
|
||||
qsTr("Access denied")
|
||||
break;
|
||||
case MediaPlayer.ServiceMissing:
|
||||
//: Video playback error: the media cannot be played because the media service could not be instantiated.
|
||||
qsTr("Media service missing")
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Label {
|
||||
wrapMode: Text.WordWrap
|
||||
text: player.errorString
|
||||
color: Theme.errorColor
|
||||
width: videoError.width - Theme.horizontalPageMargin * 2
|
||||
horizontalAlignment: Text.AlignHCenter
|
||||
}
|
||||
|
||||
Item { width: 1; height: Theme.paddingLarge; }
|
||||
|
||||
ButtonLayout {
|
||||
Button {
|
||||
//: Button to retry loading a video after a failure
|
||||
text: qsTr("Retry")
|
||||
onClicked: player.play()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
188
sailfish/qml/components/videoplayer/VideoHud.qml
Normal file
188
sailfish/qml/components/videoplayer/VideoHud.qml
Normal file
|
@ -0,0 +1,188 @@
|
|||
/*
|
||||
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 "../../Utils.js" as Utils
|
||||
|
||||
/**
|
||||
* The video "hud" or controls. This is the overlay displayed over a video player, which contains controls
|
||||
* and playback information.
|
||||
*/
|
||||
Item {
|
||||
id: videoHud
|
||||
property MediaPlayer player
|
||||
property string title
|
||||
property bool _manuallyActivated: false
|
||||
readonly property bool hidden: opacity == 0.0
|
||||
|
||||
Behavior on opacity { FadeAnimator {} }
|
||||
Rectangle {
|
||||
id: topBar
|
||||
anchors.top: parent.top
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
height: pageTitle.height
|
||||
|
||||
gradient: Gradient {
|
||||
GradientStop { position: 1.0; color: Theme.rgba(palette.overlayBackgroundColor, 0.15); }
|
||||
GradientStop { position: 0.0; color: Theme.rgba(palette.overlayBackgroundColor, 0.30); }
|
||||
}
|
||||
PageHeader {
|
||||
id: pageTitle
|
||||
title: videoHud.title
|
||||
anchors.fill: parent
|
||||
titleColor: palette.primaryColor
|
||||
}
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
anchors.top: topBar.bottom
|
||||
anchors.bottom: bottomBar.top
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
color: Theme.rgba(palette.overlayBackgroundColor, 0.15)
|
||||
}
|
||||
|
||||
MouseArea {
|
||||
id: wakeupArea
|
||||
enabled: true
|
||||
anchors.fill: parent
|
||||
onClicked: {
|
||||
hidden ? videoHud.show(true) : videoHud.hide(true)
|
||||
console.log("Trying")
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
BusyIndicator {
|
||||
id: busyIndicator
|
||||
anchors.centerIn: parent
|
||||
size: BusyIndicatorSize.Medium
|
||||
running: [MediaPlayer.Loading, MediaPlayer.Stalled].indexOf(player.status) >= 0
|
||||
}
|
||||
|
||||
IconButton {
|
||||
id: playPause
|
||||
enabled: !hidden
|
||||
anchors.centerIn: parent
|
||||
icon.source: player.playbackState == MediaPlayer.PausedState ? "image://theme/icon-l-play" : "image://theme/icon-l-pause"
|
||||
onClicked: {
|
||||
if (player.playbackState == MediaPlayer.PlayingState) {
|
||||
player.pause()
|
||||
} else {
|
||||
player.play()
|
||||
}
|
||||
}
|
||||
visible: !busyIndicator.running
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
id: bottomBar
|
||||
anchors.bottom: parent.bottom
|
||||
width: parent.width
|
||||
height: progress.height
|
||||
visible: [MediaPlayer.Unavailable, MediaPlayer.Loading, MediaPlayer.NoMedia].indexOf(player.status) == -1
|
||||
|
||||
gradient: Gradient {
|
||||
GradientStop { position: 0.0; color: Theme.rgba(palette.overlayBackgroundColor, 0.15); }
|
||||
GradientStop { position: 1.0; color: Theme.rgba(palette.overlayBackgroundColor, 0.30); }
|
||||
}
|
||||
|
||||
Item {
|
||||
id: progress
|
||||
height: progressSlider.height + 2 * Theme.paddingMedium
|
||||
width: parent.width
|
||||
|
||||
Label {
|
||||
id: playedTime
|
||||
anchors.left: parent.left
|
||||
anchors.leftMargin: Theme.horizontalPageMargin
|
||||
anchors.verticalCenter: progressSlider.verticalCenter
|
||||
text: Utils.timeToText(player.position)
|
||||
}
|
||||
|
||||
Slider {
|
||||
id: progressSlider
|
||||
enabled: player.seekable
|
||||
value: player.position
|
||||
maximumValue: player.duration
|
||||
stepSize: 1000
|
||||
anchors.left: playedTime.right
|
||||
anchors.right: totalTime.left
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
onDownChanged: if (!down) { player.seek(value) }
|
||||
}
|
||||
|
||||
Label {
|
||||
id: totalTime
|
||||
anchors.right: parent.right
|
||||
anchors.rightMargin: Theme.horizontalPageMargin
|
||||
anchors.verticalCenter: progress.verticalCenter
|
||||
text: Utils.timeToText(player.duration)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Connections {
|
||||
target: player
|
||||
onStatusChanged: {
|
||||
console.log("New mediaPlayer status: " + player.status)
|
||||
switch(player.status) {
|
||||
case MediaPlayer.Loaded:
|
||||
case MediaPlayer.Buffering:
|
||||
show(false)
|
||||
break;
|
||||
case MediaPlayer.Buffered:
|
||||
hide(false)
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function show(manual) {
|
||||
_manuallyActivated = manual
|
||||
if (manual) {
|
||||
inactivityTimer.restart()
|
||||
} else {
|
||||
inactivityTimer.stop()
|
||||
}
|
||||
opacity = 1
|
||||
}
|
||||
|
||||
function hide(manual) {
|
||||
// Don't hide if the user decided on their own to show the hud
|
||||
//if (!manual && _manuallyActivated) return;
|
||||
// Don't give in to the user if they want to hide the hud while it was forced upon them
|
||||
/*if (!_manuallyActivated && manual) return;
|
||||
_manuallyActivated = false;*/
|
||||
opacity = 0
|
||||
}
|
||||
|
||||
Timer {
|
||||
id: inactivityTimer
|
||||
interval: 5000
|
||||
onTriggered: {
|
||||
hide(true)
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue