-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathiconengine.h
72 lines (60 loc) · 1.84 KB
/
iconengine.h
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
61
62
63
64
65
66
67
68
69
70
71
72
#ifndef ICONENGINE_H
#define ICONENGINE_H
#include <QIconEngine>
#include <QPainter>
#include <QIcon>
#include <QDir>
#include <QDirIterator>
#include <QDebug>
#include <QApplication>
#include <QImage>
#include <QPalette>
#include <QtConcurrent>
#include <QFutureWatcher>
#include <QSvgRenderer>
#include <QSharedMemory>
#include <QBuffer>
class IconEngine : public QIconEngine
{
public:
IconEngine(QString iconName);
struct iconInfo {
QString fileName;
int size;
QSharedMemory* iconData = NULL;
bool operator==(const iconInfo& other) const {
if ((this->fileName == other.fileName) && (this->size == other.size)) {
return true;
} else {
return false;
}
}
bool operator<(const iconInfo& other) const {
return this->size < other.size;
}
bool operator>(const iconInfo& other) const {
return this->size > other.size;
}
};
struct cacheIcon {
QString name;
int size;
QPixmap pm;
};
QString iconName() const;
QIconEngine* clone() const;
void paint(QPainter *painter, const QRect &rect, QIcon::Mode mode, QIcon::State state);
QPixmap pixmap(const QSize &size, QIcon::Mode mode, QIcon::State state);
QList<iconInfo> getMatchingIcon(QString searchPath, QString icName, bool subdirectories = true);
QList<QSize> availableSizes(QIcon::Mode mode, QIcon::State state) const;
bool isNull();
QList<IconEngine::iconInfo> load(QString icName);
QImage extractImage(QSharedMemory* sharedMemory);
private:
QString icName;
QList<iconInfo> listOfIcons;
void tintImage(QImage &image, QColor tint) const;
QFuture<QList<IconEngine::iconInfo>> pendingIcons;
static QList<IconEngine::cacheIcon> memorySizes;
};
#endif // ICONENGINE_H