ClipThumbs.qml 4.17 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
11
    opacity: clipState == ClipState.Disabled ? 0.2 : 1
12
    property bool fixedThumbs: clipRoot.itemType == ProducerType.Image || clipRoot.itemType == ProducerType.Text || clipRoot.itemType == ProducerType.TextTemplate
13
    property int thumbWidth: container.height * root.dar
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
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
            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)
41
            horizontalAlignment: thumbRepeater.count < 3 ? (index == 0 ? Image.AlignLeft : Image.AlignRight) : Image.AlignLeft
42
            source: thumbRepeater.count < 3 ? (clipRoot.baseThumbPath + currentFrame) : (index * width < clipRoot.scrollStart - width || index * width > clipRoot.scrollStart + scrollView.width) ? '' : clipRoot.baseThumbPath + currentFrame
43
44
45
            onStatusChanged: {
                if (thumbRepeater.count < 3) {
                    if (status === Image.Ready) {
46
                        thumbPlaceholder.source = source
47
48
49
50
51
52
53
54
55
                    }
                }
            }
            BusyIndicator {
                running: parent.status != Image.Ready
                anchors.left: parent.left
                anchors.leftMargin: index < thumbRepeater.count - 1 ? 0 : parent.width - thumbRow.thumbWidth - 1
                implicitWidth: thumbRepeater.imageWidth
                implicitHeight: container.height
56
57
                hoverEnabled: false
                visible: running
58
59
60
61
                contentItem:
                Image {
                    id: thumbPlaceholder
                    visible: parent.running
62
63
64
65
                    width: parent.width
                    height: parent.height
                    sourceSize.width: width
                    sourceSize.height: height
66
67
68
69
70
71
72
73
                    horizontalAlignment: Image.AlignLeft
                    fillMode: Image.PreserveAspectFit
                    asynchronous: true
                }
            }
            Rectangle {
                visible: thumbRepeater.count < 3
                anchors.left: parent.left
74
                anchors.leftMargin: index == 0 ? thumbRow.thumbWidth : parent.width - thumbRow.thumbWidth - 1
75
76
77
78
79
                color: "#ffffff"
                opacity: 0.3
                width: 1
                height: parent.height
            }
80
81
82
        }
    }
}