Manga (CBZ) Support
This commit is contained in:
12 files changed
+937
-17
No files matched your search
@@ -0,0 +1,53 @@
|
||||
#ifndef CBZIMAGEPROVIDER_H
|
||||
#define CBZIMAGEPROVIDER_H
|
||||
|
||||
#include <QMutex>
|
||||
#include <QRunnable>
|
||||
#include <QString>
|
||||
|
||||
#include "backend/IImageLoader.h"
|
||||
#include "backend/IImageProvider.h"
|
||||
|
||||
class CbzImageResponse : public QQuickImageResponse, public QRunnable {
|
||||
// NO Q_OBJECT — already inherited from QQuickImageResponse
|
||||
public:
|
||||
CbzImageResponse(const QString &cbzPath, const QString &entryName,
|
||||
int displayWidth, const QSize &requestedSize);
|
||||
|
||||
QQuickTextureFactory *textureFactory() const override;
|
||||
void cancel() override;
|
||||
void run() override;
|
||||
|
||||
private:
|
||||
const QString m_cbzPath;
|
||||
const QString m_entryName;
|
||||
const int m_displayWidth;
|
||||
const QSize m_requestedSize;
|
||||
QAtomicInt m_cancelled{0};
|
||||
QImage m_image;
|
||||
};
|
||||
|
||||
class CbzImageProvider : public IImageProvider, public IImageLoader {
|
||||
public:
|
||||
QQuickImageResponse *requestImageResponse(const QString &id,
|
||||
const QSize &requestedSize) override;
|
||||
|
||||
void setFilePath(const QString &filePath) override;
|
||||
void setDisplayWidth(int width) override;
|
||||
void clear() override;
|
||||
QString coverImageUrl(const QString &coverPath) const override;
|
||||
QString scheme() const override;
|
||||
|
||||
QImage load(const QUrl &url, int maxWidth) const override;
|
||||
std::unique_ptr<IImageLoader> clone() const override;
|
||||
|
||||
static QImage loadImageFromCbz(const QString &cbzPath, const QString &entryName,
|
||||
int displayWidth, const QSize &requestedSize);
|
||||
|
||||
private:
|
||||
mutable QMutex m_mutex;
|
||||
QString m_cbzPath;
|
||||
int m_displayWidth = 0;
|
||||
};
|
||||
|
||||
#endif // CBZIMAGEPROVIDER_H
|
||||
Reference in new issue
Block a user