File indexing completed on 2024-05-12 04:45:59

0001 #pragma once
0002 
0003 #include <QQuickImageProvider>
0004 #include <QCache>
0005 
0006 #include <utils/ffmpegthumbs/videothumbnailer.h>
0007 #include <utils/ffmpegthumbs/filmstripfilter.h>
0008 
0009 class Surface : public QObject
0010 {
0011     Q_OBJECT
0012 
0013     typedef QCache<QString, QImage> ThumbCache;
0014 
0015 public:
0016     Surface(QObject *p = nullptr);
0017     void request(const QString &path, int width, int);
0018 
0019 private:
0020     ffmpegthumbnailer::VideoThumbnailer m_Thumbnailer;
0021     ffmpegthumbnailer::FilmStripFilter  m_FilmStrip;
0022     ThumbCache m_thumbCache;
0023 
0024 Q_SIGNALS:
0025     void previewReady(QImage image);
0026     void error(QString error);
0027 };
0028 
0029 class AsyncImageResponse : public QQuickImageResponse
0030 {
0031 public:
0032     AsyncImageResponse(const QString &id, const QSize &requestedSize);
0033     QQuickTextureFactory *textureFactory() const override;
0034     QString errorString() const override;
0035 
0036 private:
0037     QString m_id;
0038     QSize m_requestedSize;
0039     QImage m_image;
0040     QString m_error;
0041 };
0042 
0043 class Thumbnailer : public QQuickAsyncImageProvider
0044 {
0045 public:
0046     QQuickImageResponse *requestImageResponse(const QString &id, const QSize &requestedSize) override;
0047 };