qmlFrontend/themeiconprovider.cpp
author unc0rr
Sat, 21 Nov 2015 17:07:06 +0300
branchqmlfrontend
changeset 11423 e045dc60c37e
parent 10440 b74a7bbe224e
child 11432 97e3e62ea5f9
permissions -rw-r--r--
- Warnings/errors message box - Send JOIN_ROOM on double click on rooms list - Some small iprovements more

#include <QByteArray>
#include <QDebug>

#include "themeiconprovider.h"
#include "flib.h"

ThemeIconProvider::ThemeIconProvider()
    : QQuickImageProvider(QQuickImageProvider::Image)
{
    getThemeIcon = 0;
}

void ThemeIconProvider::setFileContentsFunction(getThemeIcon_t *f)
{
    getThemeIcon = f;
}

QImage ThemeIconProvider::requestImage(const QString &id, QSize *size, const QSize &requestedSize)
{
    Q_UNUSED(requestedSize);

    if(!getThemeIcon)
        return QImage();

    QByteArray buf;
    buf.resize(65536);

    char * bufptr = buf.data();
    uint32_t fileSize = getThemeIcon(id.toUtf8().data(), bufptr, buf.size());
    buf.truncate(fileSize);
    qDebug() << "ThemeIconProvider file size = " << fileSize;

    QImage img = QImage::fromData(buf);

    if (size)
        *size = img.size();
    return img;
}