Cleanup timeline thumbnail mechanism on resize

parent d8fd5e44
Pipeline #12949 passed with stage
in 13 minutes and 27 seconds
......@@ -211,7 +211,6 @@ Rectangle {
property bool noThumbs: (isAudio || itemType == ProducerType.Color || mltService === '')
property bool isImage: itemType == ProducerType.Image
property string baseThumbPath: noThumbs ? '' : 'image://thumbnail/' + binId + '/' + documentId + '/' + (isImage ? '#0' : '#')
property string baseCacheThumbPath: noThumbs ? '' : 'image://thumbnailCache/' + binId + '/' + (isImage ? '#0' : '#')
DropArea { //Drop area for clips
anchors.fill: clipRoot
......
......@@ -38,13 +38,12 @@ Row {
asynchronous: true
cache: enableCache
property int currentFrame: thumbRepeater.count < 3 ? (index == 0 ? thumbRepeater.thumbStartFrame : thumbRepeater.thumbEndFrame) : Math.floor(clipRoot.inPoint + Math.round((index) * width / timeline.scaleFactor)* clipRoot.speed)
property int lastFrame: -1
horizontalAlignment: thumbRepeater.count < 3 ? (index == 0 ? Image.AlignLeft : Image.AlignRight) : Image.AlignLeft
source: thumbRepeater.count < 3 ? (clipRoot.baseThumbPath + currentFrame) : (index * width < clipRoot.scrollStart - width || index * width > clipRoot.scrollStart + scrollView.viewport.width) ? '' : clipRoot.baseThumbPath + currentFrame
onStatusChanged: {
if (thumbRepeater.count < 3) {
if (status === Image.Ready) {
lastFrame = currentFrame
thumbPlaceholder.source = source
}
}
}
......@@ -63,12 +62,6 @@ Row {
fillMode: Image.PreserveAspectFit
asynchronous: true
}
onRunningChanged: {
if (!running) {
thumbPlaceholder.source = clipRoot.baseCacheThumbPath + parent.lastFrame
console.log('Setting image lastframe: ', parent.lastFrame)
}
}
}
Rectangle {
visible: thumbRepeater.count < 3
......
......@@ -98,28 +98,3 @@ QImage ThumbnailProvider::makeThumbnail(const std::shared_ptr<Mlt::Producer> &pr
}
return QImage();
}
ThumbnailCacheProvider::ThumbnailCacheProvider()
: QQuickImageProvider(QQmlImageProviderBase::Image, QQmlImageProviderBase::ForceAsynchronousImageLoading)
{
}
ThumbnailCacheProvider::~ThumbnailCacheProvider() = default;
QImage ThumbnailCacheProvider::requestImage(const QString &id, QSize *size, const QSize &requestedSize)
{
QImage result;
// id is binID/#frameNumber
QString binId = id.section('/', 0, 0);
bool ok;
int frameNumber = id.section('#', -1).toInt(&ok);
if (ok) {
if (ThumbnailCache::get()->hasThumbnail(binId, frameNumber, false)) {
result = ThumbnailCache::get()->getThumbnail(binId, frameNumber);
*size = result.size();
return result;
}
}
if (size) *size = result.size();
return result;
}
......@@ -38,12 +38,4 @@ private:
QString cacheKey(Mlt::Properties &properties, const QString &service, const QString &resource, const QString &hash, int frameNumber);
};
class ThumbnailCacheProvider : public QQuickImageProvider
{
public:
explicit ThumbnailCacheProvider();
~ThumbnailCacheProvider() override;
QImage requestImage(const QString &id, QSize *size, const QSize &requestedSize) override;
};
#endif // THUMBNAILPROVIDER_H
......@@ -82,7 +82,6 @@ TimelineWidget::TimelineWidget(QWidget *parent)
connect(m_proxy, &TimelineController::ungrabHack, this, &TimelineWidget::slotUngrabHack);
setResizeMode(QQuickWidget::SizeRootObjectToView);
engine()->addImageProvider(QStringLiteral("thumbnail"), new ThumbnailProvider);
engine()->addImageProvider(QStringLiteral("thumbnailCache"), new ThumbnailCacheProvider);
setVisible(false);
setFont(QFontDatabase::systemFont(QFontDatabase::SmallestReadableFont));
setFocusPolicy(Qt::StrongFocus);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment