Warning, /multimedia/kdenlive/src/timeline2/view/qml/ClipThumbs.qml is written in an unsupported language. File is not indexed.
0001 /*
0002 SPDX-FileCopyrightText: 2018 Jean-Baptiste Mardelle <jb@kdenlive.org>
0003 SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
0004 */
0005
0006 import QtQuick 2.15
0007 import QtQuick.Controls 2.15
0008 import QtQml.Models 2.15
0009 import com.enums 1.0
0010
0011
0012 Row {
0013 id: thumbRow
0014 anchors.fill: parent
0015 visible: !isAudio
0016 clip: true
0017 property real initialSpeed: 1
0018 opacity: clipState === ClipState.Disabled ? 0.2 : 1
0019 property bool fixedThumbs: clipRoot.itemType === ProducerType.Image || clipRoot.itemType === ProducerType.Text || clipRoot.itemType === ProducerType.TextTemplate
0020 property int thumbWidth: container.height * root.dar
0021 property bool enableCache: clipRoot.itemType === ProducerType.Video || clipRoot.itemType === ProducerType.AV
0022
0023 Repeater {
0024 id: thumbRepeater
0025 // switching the model allows one to have different view modes.
0026 // We set the model to the number of frames we want to show
0027 model: switch (parentTrack.trackThumbsFormat) {
0028 case 0:
0029 // in/out
0030 if (parent.width > thumbRow.thumbWidth) {
0031 2 // 2: will display start / end thumbs
0032 } else {
0033 1 // 1: if the width of the container is to small, only show first thumbnail
0034 }
0035 break;
0036 case 1:
0037 // All frames
0038 // display as many thumbnails as can fit into the container
0039 Math.ceil(parent.width / thumbRow.thumbWidth)
0040 break;
0041 case 2:
0042 // In frame only
0043 1 // 1: only show first thumbnail
0044 break;
0045 case 3:
0046 default:
0047 // No thumbs
0048 0 // 0: will disable thumbnails
0049 }
0050 property int startFrame: clipRoot.inPoint
0051 property int endFrame: clipRoot.outPoint
0052 property real imageWidth: Math.max(thumbRow.thumbWidth, parent.width / thumbRepeater.count)
0053 property int thumbStartFrame: fixedThumbs ? 0 :
0054 (clipRoot.speed >= 0)
0055 ? Math.round(clipRoot.inPoint * thumbRow.initialSpeed)
0056 : Math.round((clipRoot.maxDuration - clipRoot.inPoint) * -thumbRow.initialSpeed - 1)
0057 property int thumbEndFrame: fixedThumbs ? 0 :
0058 (clipRoot.speed >= 0)
0059 ? Math.round(clipRoot.outPoint * thumbRow.initialSpeed)
0060 : Math.round((clipRoot.maxDuration - clipRoot.outPoint) * -thumbRow.initialSpeed - 1)
0061
0062 Image {
0063 width: thumbRepeater.imageWidth
0064 height: container.height
0065 fillMode: Image.PreserveAspectFit
0066 asynchronous: true
0067 cache: enableCache
0068 //sourceSize.width: width
0069 //sourceSize.height: height
0070 property int currentFrame: fixedThumbs
0071 ? 0
0072 : thumbRepeater.count < 3
0073 ? (index == 0 ? thumbRepeater.thumbStartFrame : thumbRepeater.thumbEndFrame)
0074 : Math.floor(clipRoot.inPoint * thumbRow.initialSpeed + Math.round((index) * width / timeline.scaleFactor)* clipRoot.speed)
0075 horizontalAlignment: thumbRepeater.count < 3
0076 ? (index == 0 ? Image.AlignLeft : Image.AlignRight)
0077 : Image.AlignLeft
0078 source: thumbRepeater.count < 3
0079 ? (clipRoot.baseThumbPath + currentFrame)
0080 : (index * width < clipRoot.scrollStart - width || index * width > clipRoot.scrollStart + scrollView.width) ? '' : clipRoot.baseThumbPath + currentFrame
0081 onStatusChanged: {
0082 if (status === Image.Ready && (index == 0 || index == thumbRepeater.count - 1)) {
0083 thumbPlaceholder.source = source
0084 }
0085 }
0086 Image {
0087 id: thumbPlaceholder
0088 visible: parent.status != Image.Ready && (index == 0 || index == thumbRepeater.count - 1)
0089 anchors.left: parent.left
0090 anchors.leftMargin: index < thumbRepeater.count - 1 ? 0 : parent.width - thumbRow.thumbWidth - 1
0091 width: parent.width
0092 height: parent.height
0093 horizontalAlignment: Image.AlignLeft
0094 fillMode: Image.PreserveAspectFit
0095 asynchronous: true
0096 }
0097 Rectangle {
0098 visible: thumbRepeater.count < 3
0099 anchors.left: parent.left
0100 anchors.leftMargin: index == 0 ? thumbRow.thumbWidth : parent.width - thumbRow.thumbWidth - 1
0101 color: "#ffffff"
0102 opacity: 0.3
0103 width: 1
0104 height: parent.height
0105 }
0106 }
0107 }
0108 }