@@ -35,11 +35,30 @@ FocusScope {
3535 onFocusedIndexChanged: if (focusedIndex >= 0 )
3636 lastFocusedIndex = focusedIndex
3737 readonly property var preview: snapshot .preview || null
38- readonly property int previewFrame: preview ? Math .min (preview .count - 1 , Math .max (0 , Math .floor (editedValue * 1000
39- / preview .intervalMs ))) :
40- 0
41- readonly property int previewSheet: preview ? Math .floor (previewFrame / (preview .columns * preview .rows )) : 0
42- readonly property int previewTile: preview ? previewFrame % (preview .columns * preview .rows ) : 0
38+ readonly property bool previewActive: visible && ! customContext && editingKey === " seek" && preview !== null
39+ && remote .trickplayAvailable
40+ property var previewFrame: ({})
41+ property bool previewSelectionPending: previewActive
42+ onPreviewActiveChanged: {
43+ previewSelectionPending = previewActive
44+ if (! previewActive)
45+ previewFrame = ({})
46+ }
47+ onEditedValueChanged: if (previewActive)
48+ previewSelectionPending = true
49+ onRemoteChanged: {
50+ previewFrame = ({})
51+ previewSelectionPending = previewActive
52+ }
53+
54+ // Selection belongs to the page, not the image-ready item below.
55+ FrameAnimation {
56+ running: root .previewActive && root .previewSelectionPending
57+ onTriggered: {
58+ root .previewSelectionPending = false
59+ root .previewFrame = root .remote .trickplayForSeconds (root .editedValue )
60+ }
61+ }
4362
4463 function supports (action ) {
4564 return attached && commands .indexOf (action) >= 0
@@ -237,6 +256,12 @@ FocusScope {
237256 }
238257 Connections {
239258 target: root .remote
259+ ignoreUnknownSignals: true
260+ function onTrickplayChanged () {
261+ if (! root .previewActive )
262+ root .previewFrame = ({})
263+ root .previewSelectionPending = root .previewActive
264+ }
240265 function onSelectionChanged () {
241266 root .editingKey = " "
242267 root .customContext = null
@@ -462,20 +487,29 @@ FocusScope {
462487 color: Theme .textSecondary
463488 wrapMode: Text .WordWrap
464489 }
465- Image {
466- visible: root .editingKey === " seek" && root .preview !== null
490+ Item {
491+ id: seekPreview
492+ readonly property bool ready: root .previewFrame .available === true
493+ readonly property real imageScale: ready && root .previewFrame .width > 0 ? width / root .previewFrame .width :
494+ 0
495+
496+ visible: ready && seekPreviewImage .status === Image .Ready
467497 Layout .alignment : Qt .AlignHCenter
468498 Layout .preferredWidth : Metrics .scaled (240 )
469- Layout .preferredHeight : root .preview ? width * root .preview .height / root .preview .width : 0
470- source: visible ? " image://artwork/" + encodeURIComponent (root .preview .urlTemplate .replace (" {index}" , String (
471- root .previewSheet ))) :
472- " "
473- sourceClipRect: root .preview ? Qt .rect ((root .previewTile % root .preview .columns ) * root .preview .width ,
474- Math .floor (root .previewTile / root .preview .columns )
475- * root .preview .height , root .preview .width , root .preview .height ) :
476- Qt .rect (0 , 0 , 0 , 0 )
477- fillMode: Image .PreserveAspectFit
478- asynchronous: true
499+ Layout .preferredHeight : ready ? root .previewFrame .height * imageScale : 0
500+ clip: true
501+
502+ Image {
503+ id: seekPreviewImage
504+ source: seekPreview .ready ? root .previewFrame .url : " "
505+ x: seekPreview .ready ? root .previewFrame .offsetX * seekPreview .imageScale : 0
506+ y: seekPreview .ready ? root .previewFrame .offsetY * seekPreview .imageScale : 0
507+ width: seekPreview .ready ? root .previewFrame .sheetWidth * seekPreview .imageScale : 0
508+ height: seekPreview .ready ? root .previewFrame .sheetHeight * seekPreview .imageScale : 0
509+ fillMode: Image .Stretch
510+ cache: false
511+ asynchronous: true
512+ }
479513 }
480514 ListView {
481515 id: list
0 commit comments