35 lines
1.1 KiB
C++
35 lines
1.1 KiB
C++
#pragma once
|
|
|
|
#include <QMutex>
|
|
#include <QSize>
|
|
#include <QString>
|
|
|
|
#include "backend/IImageLoader.h"
|
|
#include "backend/IImageProvider.h"
|
|
|
|
class WebImageProvider : public IImageProvider, public IImageLoader {
|
|
public:
|
|
QQuickImageResponse *requestImageResponse(const QString &id,
|
|
const QSize &requestedSize) override;
|
|
|
|
void setFilePath(const QString &) override {}
|
|
void setDisplayWidth(int width) override;
|
|
void clear() override {}
|
|
QString coverImageUrl(const QString &) const override { return {}; }
|
|
QString scheme() const override;
|
|
|
|
QImage load(const QUrl &url, int maxWidth) const override;
|
|
std::unique_ptr<IImageLoader> clone() const override;
|
|
|
|
// Download (or load from disk cache) a web image. Thread-safe, may block.
|
|
static QImage loadWebImage(const QString &urlString, int displayWidth,
|
|
const QSize &requestedSize);
|
|
|
|
static QString cacheDir();
|
|
static QString cacheFilePath(const QString &urlString);
|
|
|
|
private:
|
|
mutable QMutex m_mutex;
|
|
int m_displayWidth = 0;
|
|
};
|