10436
|
1 |
#include <QByteArray>
|
|
2 |
#include <QDebug>
|
|
3 |
|
|
4 |
#include "themeiconprovider.h"
|
|
5 |
#include "flib.h"
|
|
6 |
|
|
7 |
ThemeIconProvider::ThemeIconProvider()
|
|
8 |
: QQuickImageProvider(QQuickImageProvider::Image)
|
|
9 |
{
|
|
10 |
getThemeIcon = 0;
|
|
11 |
}
|
|
12 |
|
|
13 |
void ThemeIconProvider::setFileContentsFunction(getThemeIcon_t *f)
|
|
14 |
{
|
|
15 |
getThemeIcon = f;
|
|
16 |
}
|
|
17 |
|
|
18 |
QImage ThemeIconProvider::requestImage(const QString &id, QSize *size, const QSize &requestedSize)
|
|
19 |
{
|
|
20 |
Q_UNUSED(requestedSize);
|
|
21 |
|
|
22 |
if(!getThemeIcon)
|
|
23 |
return QImage();
|
|
24 |
|
|
25 |
QByteArray buf;
|
|
26 |
buf.resize(65536);
|
|
27 |
|
10440
|
28 |
char * bufptr = buf.data();
|
|
29 |
uint32_t fileSize = getThemeIcon(id.toUtf8().data(), bufptr, buf.size());
|
10436
|
30 |
buf.truncate(fileSize);
|
11432
|
31 |
//qDebug() << "ThemeIconProvider file size = " << fileSize;
|
10436
|
32 |
|
11432
|
33 |
QImage img = fileSize ? QImage::fromData(buf) : QImage(16, 16, QImage::Format_ARGB32);
|
10436
|
34 |
|
|
35 |
if (size)
|
|
36 |
*size = img.size();
|
|
37 |
return img;
|
|
38 |
}
|