blob: d8e9d2d7d373feab7c9e0f8be29e874900592500 (
plain) (
blame)
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
41
42
43
44
45
46
47
48
49
|
// SPDX-License-Identifier: GPL-2.0
#ifndef IMAGEDOWNLOADER_H
#define IMAGEDOWNLOADER_H
#include <QImage>
#include <QFuture>
#include <QNetworkReply>
#include <QThreadPool>
class ImageDownloader : public QObject {
Q_OBJECT
public:
ImageDownloader(const QString &filename);
void load(bool fromHash);
private:
bool loadFromUrl(const QUrl &); // return true on success
void saveImage(QNetworkReply *reply, bool &success);
QString filename;
};
class PictureEntry;
class Thumbnailer : public QObject {
Q_OBJECT
public:
static Thumbnailer *instance();
// Schedule a thumbnail for fetching or calculation.
// Returns a placehlder thumbnail. The actual thumbnail will be sent
// via a signal later.
QImage fetchThumbnail(PictureEntry &entry, int size);
// If we change dive, clear all unfinished thumbnail creations
void clearWorkQueue();
signals:
void thumbnailChanged(QString filename, QImage thumbnail);
private:
Thumbnailer();
void processItem(QString filename, int size);
mutable QMutex lock;
QThreadPool pool;
QMap<QString,QFuture<void>> workingOn;
};
QImage getHashedImage(const QString &filename);
#endif // IMAGEDOWNLOADER_H
|