blob: f32bf64d932e389b61fc8261f644186d5f401db8 (
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
#ifndef PIXMAPLOADER_H
#define PIXMAPLOADER_H
#include <QThread>
#include <QMutex>
#include <QMap>
#include <QStringList>
#include <QPixmap>
#include <QWaitCondition>
class PixmapLoader;
class PixmapLoaderThread : public QThread
{
Q_OBJECT
public:
PixmapLoaderThread(PixmapLoader *loader);
signals:
void imageIsReady(const QString &name, QImage image);
protected:
void run();
private:
PixmapLoader * const m_loader;
};
class PixmapLoader : public QObject
{
Q_OBJECT
public:
static void load(const QString &name);
static void connectToOnIdleSignal(QObject *receiver, const char *method);
static void disconnectReceiver(QObject *receiver);
static QPixmap getPic(const QString &name);
signals:
void onIdle();
private:
friend class PixmapLoaderThread;
QMutex m_mutex;
QWaitCondition m_condition;
QStringList m_queue;
QStringList m_currentImages;
QMap<QString, QPixmap> m_store;
PixmapLoaderThread *m_thread;
PixmapLoader(QObject *parent = 0);
static PixmapLoader *instance();
void enqueue(const QString &name);
QString doDequeue();
QString dequeue();
private slots:
void imageIsReady(const QString &name, QImage image);
};
#endif // PIXMAPLOADER_H
|