Commit 513d3a69 authored by Kai Uwe Broulik's avatar Kai Uwe Broulik 🍇
Browse files

[Media Controller] Show track length if available even if seeking isn't possible

When seeking isn't possible but the track duration is known, show a progress bar instead of showing nothing.
A progress bar is also much nicer than a disabled slider here as it's then meant as an indicator instead.

Differential Revision: https://phabricator.kde.org/D11356
parent 892066b6
......@@ -38,6 +38,7 @@ Item {
property int position: mpris2Source.currentData.Position || 0
readonly property real rate: mpris2Source.currentData.Rate || 1
readonly property double length: currentMetadata ? currentMetadata["mpris:length"] || 0 : 0
readonly property bool canSeek: mpris2Source.currentData.CanSeek || false
// only show hours (the default for KFormat) when track is actually longer than an hour
readonly property int durationFormattingOptions: length >= 60*60*1000*1000 ? 0 : KCoreAddons.FormatTypes.FoldHours
......@@ -219,7 +220,7 @@ Item {
spacing: units.smallSpacing
// if there's no "mpris:length" in the metadata, we cannot seek, so hide it in that case
enabled: !root.noPlayer && root.track && seekSlider.maximumValue > 0 && mpris2Source.currentData.CanSeek ? true : false
enabled: !root.noPlayer && root.track && expandedRepresentation.length > 0 ? true : false
opacity: enabled ? 1 : 0
Behavior on opacity {
NumberAnimation { duration: units.longDuration }
......@@ -247,6 +248,7 @@ Item {
Layout.fillWidth: true
z: 999
value: 0
visible: canSeek
onValueChanged: {
if (!disablePositionUpdate) {
......@@ -276,6 +278,14 @@ Item {
}
}
PlasmaComponents.ProgressBar {
Layout.fillWidth: true
value: seekSlider.value
minimumValue: seekSlider.minimumValue
maximumValue: seekSlider.maximumValue
visible: !canSeek
}
PlasmaComponents.Label {
Layout.preferredWidth: timeMetrics.width
verticalAlignment: Text.AlignVCenter
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment