ClipThumbs.qml 3.86 KB
Newer Older
1
2
3
import QtQuick 2.11
import QtQuick.Controls 2.4
import QtQml.Models 2.11
4
5
6
7
8
9
import com.enums 1.0


Row {
    id: thumbRow
    anchors.fill: parent
10
    visible: !isAudio
Vincent Pinon's avatar
Vincent Pinon committed
11
12
    opacity: clipState === ClipState.Disabled ? 0.2 : 1
    property bool fixedThumbs: clipRoot.itemType === ProducerType.Image || clipRoot.itemType === ProducerType.Text || clipRoot.itemType === ProducerType.TextTemplate
13
    property int thumbWidth: container.height * root.dar
Vincent Pinon's avatar
Vincent Pinon committed
14
    property bool enableCache: clipRoot.itemType === ProducerType.Video || clipRoot.itemType === ProducerType.AV
15
16
    function reload(reset) {
        //console.log('+++++\n\ntriggered ML thumb reload\n\n++++++++++++++')
17
        clipRoot.baseThumbPath = clipRoot.variableThumbs ? '' : 'image://thumbnail/' + clipRoot.binId + '/' + Math.random() + '/#'
18
    }
19

20
21
    Repeater {
        id: thumbRepeater
22
        // switching the model allows one to have different view modes:
23
24
        // 2: will display start / end thumbs
        // container.width / thumbRow.thumbWidth will display all frames showThumbnails
25
        // 1: only show first thumbnail
26
        // 0: will disable thumbnails
Vincent Pinon's avatar
Vincent Pinon committed
27
        model: parentTrack.trackThumbsFormat === 0 ? 2 : parentTrack.trackThumbsFormat === 1 ? Math.ceil(container.width / thumbRow.thumbWidth) : parentTrack.trackThumbsFormat === 2 ? 1 : 0
28
29
        property int startFrame: clipRoot.inPoint
        property int endFrame: clipRoot.outPoint
30
        property real imageWidth: Math.max(thumbRow.thumbWidth, container.width / thumbRepeater.count)
31
32
        property int thumbStartFrame: fixedThumbs ? 0 : (clipRoot.speed >= 0) ? Math.round(clipRoot.inPoint * clipRoot.speed) : Math.round((clipRoot.maxDuration - clipRoot.inPoint) * -clipRoot.speed - 1)
        property int thumbEndFrame: fixedThumbs ? 0 : (clipRoot.speed >= 0) ? Math.round(clipRoot.outPoint * clipRoot.speed) : Math.round((clipRoot.maxDuration - clipRoot.outPoint) * -clipRoot.speed - 1)
33

34
35
36
37
38
        Image {
            width: thumbRepeater.imageWidth
            height: container.height
            fillMode: Image.PreserveAspectFit
            asynchronous: true
39
            cache: enableCache
40
41
            //sourceSize.width: width
            //sourceSize.height: height
42
            property int currentFrame: fixedThumbs ? 0 : thumbRepeater.count < 3 ? (index == 0 ? thumbRepeater.thumbStartFrame : thumbRepeater.thumbEndFrame) : Math.floor(clipRoot.inPoint + Math.round((index) * width / timeline.scaleFactor)* clipRoot.speed)
43
            horizontalAlignment: thumbRepeater.count < 3 ? (index == 0 ? Image.AlignLeft : Image.AlignRight) : Image.AlignLeft
44
            source: thumbRepeater.count < 3 ? (clipRoot.baseThumbPath + currentFrame) : (index * width < clipRoot.scrollStart - width || index * width > clipRoot.scrollStart + scrollView.width) ? '' : clipRoot.baseThumbPath + currentFrame
45
46
47
            onStatusChanged: {
                if (thumbRepeater.count < 3) {
                    if (status === Image.Ready) {
48
                        thumbPlaceholder.source = source
49
50
51
                    }
                }
            }
52
53
54
            Image {
                id: thumbPlaceholder
                visible: parent.status != Image.Ready
55
56
                anchors.left: parent.left
                anchors.leftMargin: index < thumbRepeater.count - 1 ? 0 : parent.width - thumbRow.thumbWidth - 1
57
58
59
60
61
                width: parent.width
                height: parent.height
                horizontalAlignment: Image.AlignLeft
                fillMode: Image.PreserveAspectFit
                asynchronous: true
62
63
64
65
            }
            Rectangle {
                visible: thumbRepeater.count < 3
                anchors.left: parent.left
66
                anchors.leftMargin: index == 0 ? thumbRow.thumbWidth : parent.width - thumbRow.thumbWidth - 1
67
68
69
70
71
                color: "#ffffff"
                opacity: 0.3
                width: 1
                height: parent.height
            }
72
73
74
        }
    }
}