summaryrefslogtreecommitdiffstats
path: root/src/skin/qml/asyncimageprovider.h
blob: 8b4fcd0fc1d24228bb4085581f3c96c4ab26593d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#include <QImage>
#include <QQuickAsyncImageProvider>
#include <QRunnable>
#include <QSize>
#include <QString>
#include <QThreadPool>

#include "library/coverart.h"

namespace mixxx {
namespace skin {
namespace qml {

class AsyncImageResponse : public QQuickImageResponse, public QRunnable {
  public:
    AsyncImageResponse(const QString& id, const QSize& requestedSize);
    QQuickTextureFactory* textureFactory() const override;
    void run() override;

    QString m_id;
    QSize m_requestedSize;
    QImage m_image;
};

class AsyncImageProvider : public QQuickAsyncImageProvider {
  public:
    QQuickImageResponse* requestImageResponse(
            const QString& id, const QSize& requestedSize) override;

    static const QString kProviderName;
    static QUrl trackLocationToCoverArtUrl(const QString& trackLocation);
    static QString coverArtUrlIdToTrackLocation(const QString& coverArtUrlId);

  private:
    QThreadPool pool;
};

} // namespace qml
} // namespace skin
} // namespace mixxx