summaryrefslogtreecommitdiffstats
path: root/src/qml/asyncimageprovider.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/qml/asyncimageprovider.h')
-rw-r--r--src/qml/asyncimageprovider.h40
1 files changed, 40 insertions, 0 deletions
diff --git a/src/qml/asyncimageprovider.h b/src/qml/asyncimageprovider.h
new file mode 100644
index 0000000000..8b4fcd0fc1
--- /dev/null
+++ b/src/qml/asyncimageprovider.h
@@ -0,0 +1,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