Changeset View
Changeset View
Standalone View
Standalone View
applets/mediacontroller/contents/ui/ExpandedRepresentation.qml
Show All 32 Lines | 28 | Item { | |||
---|---|---|---|---|---|
33 | Layout.preferredWidth: Layout.minimumWidth * 1.5 | 33 | Layout.preferredWidth: Layout.minimumWidth * 1.5 | ||
34 | Layout.preferredHeight: Layout.minimumHeight * 1.5 | 34 | Layout.preferredHeight: Layout.minimumHeight * 1.5 | ||
35 | 35 | | |||
36 | readonly property int controlSize: units.iconSizes.large | 36 | readonly property int controlSize: units.iconSizes.large | ||
37 | 37 | | |||
38 | property int position: mpris2Source.currentData.Position || 0 | 38 | property int position: mpris2Source.currentData.Position || 0 | ||
39 | readonly property real rate: mpris2Source.currentData.Rate || 1 | 39 | readonly property real rate: mpris2Source.currentData.Rate || 1 | ||
40 | readonly property double length: currentMetadata ? currentMetadata["mpris:length"] || 0 : 0 | 40 | readonly property double length: currentMetadata ? currentMetadata["mpris:length"] || 0 : 0 | ||
41 | readonly property bool canSeek: mpris2Source.currentData.CanSeek || false | ||||
41 | 42 | | |||
42 | // only show hours (the default for KFormat) when track is actually longer than an hour | 43 | // only show hours (the default for KFormat) when track is actually longer than an hour | ||
43 | readonly property int durationFormattingOptions: length >= 60*60*1000*1000 ? 0 : KCoreAddons.FormatTypes.FoldHours | 44 | readonly property int durationFormattingOptions: length >= 60*60*1000*1000 ? 0 : KCoreAddons.FormatTypes.FoldHours | ||
44 | 45 | | |||
45 | property bool disablePositionUpdate: false | 46 | property bool disablePositionUpdate: false | ||
46 | property bool keyPressed: false | 47 | property bool keyPressed: false | ||
47 | 48 | | |||
48 | function retrievePosition() { | 49 | function retrievePosition() { | ||
▲ Show 20 Lines • Show All 165 Lines • ▼ Show 20 Line(s) | 214 | anchors { | |||
214 | left: parent.left | 215 | left: parent.left | ||
215 | right: parent.right | 216 | right: parent.right | ||
216 | margins: units.smallSpacing | 217 | margins: units.smallSpacing | ||
217 | } | 218 | } | ||
218 | 219 | | |||
219 | spacing: units.smallSpacing | 220 | spacing: units.smallSpacing | ||
220 | 221 | | |||
221 | // if there's no "mpris:length" in the metadata, we cannot seek, so hide it in that case | 222 | // if there's no "mpris:length" in the metadata, we cannot seek, so hide it in that case | ||
222 | enabled: !root.noPlayer && root.track && seekSlider.maximumValue > 0 && mpris2Source.currentData.CanSeek ? true : false | 223 | enabled: !root.noPlayer && root.track && expandedRepresentation.length > 0 ? true : false | ||
223 | opacity: enabled ? 1 : 0 | 224 | opacity: enabled ? 1 : 0 | ||
224 | Behavior on opacity { | 225 | Behavior on opacity { | ||
225 | NumberAnimation { duration: units.longDuration } | 226 | NumberAnimation { duration: units.longDuration } | ||
226 | } | 227 | } | ||
227 | 228 | | |||
228 | // ensure the layout doesn't shift as the numbers change and measure roughly the longest text that could occur with the current song | 229 | // ensure the layout doesn't shift as the numbers change and measure roughly the longest text that could occur with the current song | ||
229 | TextMetrics { | 230 | TextMetrics { | ||
230 | id: timeMetrics | 231 | id: timeMetrics | ||
Show All 11 Lines | 237 | PlasmaComponents.Label { | |||
242 | font: theme.smallestFont | 243 | font: theme.smallestFont | ||
243 | } | 244 | } | ||
244 | 245 | | |||
245 | PlasmaComponents.Slider { | 246 | PlasmaComponents.Slider { | ||
246 | id: seekSlider | 247 | id: seekSlider | ||
247 | Layout.fillWidth: true | 248 | Layout.fillWidth: true | ||
248 | z: 999 | 249 | z: 999 | ||
249 | value: 0 | 250 | value: 0 | ||
251 | visible: canSeek | ||||
250 | 252 | | |||
251 | onValueChanged: { | 253 | onValueChanged: { | ||
252 | if (!disablePositionUpdate) { | 254 | if (!disablePositionUpdate) { | ||
253 | // delay setting the position to avoid race conditions | 255 | // delay setting the position to avoid race conditions | ||
254 | queuedPositionUpdate.restart() | 256 | queuedPositionUpdate.restart() | ||
255 | } | 257 | } | ||
256 | } | 258 | } | ||
257 | 259 | | |||
Show All 13 Lines | 272 | } else { | |||
271 | seekSlider.value += 1000000 | 273 | seekSlider.value += 1000000 | ||
272 | } | 274 | } | ||
273 | disablePositionUpdate = false | 275 | disablePositionUpdate = false | ||
274 | } | 276 | } | ||
275 | } | 277 | } | ||
276 | } | 278 | } | ||
277 | } | 279 | } | ||
278 | 280 | | |||
281 | PlasmaComponents.ProgressBar { | ||||
282 | Layout.fillWidth: true | ||||
283 | value: seekSlider.value | ||||
284 | minimumValue: seekSlider.minimumValue | ||||
285 | maximumValue: seekSlider.maximumValue | ||||
286 | visible: !canSeek | ||||
287 | } | ||||
288 | | ||||
279 | PlasmaComponents.Label { | 289 | PlasmaComponents.Label { | ||
280 | Layout.preferredWidth: timeMetrics.width | 290 | Layout.preferredWidth: timeMetrics.width | ||
281 | verticalAlignment: Text.AlignVCenter | 291 | verticalAlignment: Text.AlignVCenter | ||
282 | horizontalAlignment: Text.AlignLeft | 292 | horizontalAlignment: Text.AlignLeft | ||
283 | text: i18nc("Remaining time for song e.g -5:42", "-%1", | 293 | text: i18nc("Remaining time for song e.g -5:42", "-%1", | ||
284 | KCoreAddons.Format.formatDuration((seekSlider.maximumValue - seekSlider.value) / 1000, expandedRepresentation.durationFormattingOptions)) | 294 | KCoreAddons.Format.formatDuration((seekSlider.maximumValue - seekSlider.value) / 1000, expandedRepresentation.durationFormattingOptions)) | ||
285 | opacity: 0.9 | 295 | opacity: 0.9 | ||
286 | font: theme.smallestFont | 296 | font: theme.smallestFont | ||
▲ Show 20 Lines • Show All 130 Lines • Show Last 20 Lines |