Commit b44cef3c authored by eekkelund's avatar eekkelund

[Icons] Add fontawesome icons to image provider Glacier#884

parent 3858cd52
...@@ -30,3 +30,8 @@ QImage NemoImageProvider::requestImage(const QString &id, QSize *size, const QSi ...@@ -30,3 +30,8 @@ QImage NemoImageProvider::requestImage(const QString &id, QSize *size, const QSi
Q_UNUSED(requestedSize); Q_UNUSED(requestedSize);
return m_client->readImage(id); return m_client->readImage(id);
} }
QPixmap NemoImageProvider::requestPixmap(const QString &id, QSize *size, const QSize &requestedSize)
{
Q_UNUSED(size);
return m_client->requestPixmap(id,requestedSize);
}
...@@ -27,6 +27,7 @@ class NemoImageProvider : public QQuickImageProvider ...@@ -27,6 +27,7 @@ class NemoImageProvider : public QQuickImageProvider
public: public:
explicit NemoImageProvider(); explicit NemoImageProvider();
QImage requestImage(const QString &id, QSize *size, const QSize &requestedSize); QImage requestImage(const QString &id, QSize *size, const QSize &requestedSize);
QPixmap requestPixmap(const QString &id, QSize *size, const QSize &requestedSize);
private: private:
MLocalThemeDaemonClient* m_client; MLocalThemeDaemonClient* m_client;
}; };
......
...@@ -48,9 +48,9 @@ MLocalThemeDaemonClient::MLocalThemeDaemonClient(const QString &testPath, QObjec ...@@ -48,9 +48,9 @@ MLocalThemeDaemonClient::MLocalThemeDaemonClient(const QString &testPath, QObjec
MAbstractThemeDaemonClient(parent), MAbstractThemeDaemonClient(parent),
m_pixmapCache(), m_pixmapCache(),
m_imageDirNodes() m_imageDirNodes()
#ifdef HAVE_MLITE #ifdef HAVE_MLITE
, themeItem("/meegotouch/theme/name") , themeItem("/meegotouch/theme/name")
#endif #endif
{ {
QStringList themeRoots; QStringList themeRoots;
QString themeRoot = testPath; QString themeRoot = testPath;
...@@ -111,6 +111,7 @@ MLocalThemeDaemonClient::MLocalThemeDaemonClient(const QString &testPath, QObjec ...@@ -111,6 +111,7 @@ MLocalThemeDaemonClient::MLocalThemeDaemonClient(const QString &testPath, QObjec
inheritanceChain.insert(nextTheme); inheritanceChain.insert(nextTheme);
// the paths should be stored in reverse order than in the inheritance chain // the paths should be stored in reverse order than in the inheritance chain
themeRoots.prepend(themeRoot + QDir::separator() + nextTheme + QDir::separator() + QLatin1String("meegotouch")); themeRoots.prepend(themeRoot + QDir::separator() + nextTheme + QDir::separator() + QLatin1String("meegotouch"));
themeRoots.prepend(themeRoot + QDir::separator() + nextTheme + QDir::separator() + QLatin1String("fontawesome"));
QString parentTheme = themeIndexFile.value("X-MeeGoTouch-Metatheme/X-Inherits", "").toString(); QString parentTheme = themeIndexFile.value("X-MeeGoTouch-Metatheme/X-Inherits", "").toString();
...@@ -148,7 +149,10 @@ MLocalThemeDaemonClient::~MLocalThemeDaemonClient() ...@@ -148,7 +149,10 @@ MLocalThemeDaemonClient::~MLocalThemeDaemonClient()
QPixmap MLocalThemeDaemonClient::requestPixmap(const QString &id, const QSize &requestedSize) QPixmap MLocalThemeDaemonClient::requestPixmap(const QString &id, const QSize &requestedSize)
{ {
QPixmap pixmap; QPixmap pixmap;
qDebug() << "ID requested: " << id;
QStringList parts = id.split('?');
qDebug() << "ID requested: " << parts.at(0);
QSize size = requestedSize; QSize size = requestedSize;
if (size.width() < 1) { if (size.width() < 1) {
...@@ -158,21 +162,31 @@ QPixmap MLocalThemeDaemonClient::requestPixmap(const QString &id, const QSize &r ...@@ -158,21 +162,31 @@ QPixmap MLocalThemeDaemonClient::requestPixmap(const QString &id, const QSize &r
size.rheight() = 0; size.rheight() = 0;
} }
const PixmapIdentifier pixmapId(id, size); const PixmapIdentifier pixmapId(parts.at(0), size);
pixmap = m_pixmapCache.value(pixmapId); pixmap = m_pixmapCache.value(pixmapId);
if (pixmap.isNull()) { if (pixmap.isNull()) {
// The pixmap is not cached yet. Decode the image and // The pixmap is not cached yet. Decode the image and
// store it into the cache as pixmap. // store it into the cache as pixmap.
const QImage image = readImage(id); const QImage image = readImage(parts.at(0));
if (!image.isNull()) { if (!image.isNull()) {
pixmap = QPixmap::fromImage(image); pixmap = QPixmap::fromImage(image);
if (requestedSize.isValid() && (pixmap.size() != requestedSize)) {
pixmap = pixmap.scaled(requestedSize);
} }
if (parts.length() > 1)
if (parts.length() > 1 && QColor::isValidColor(parts.at(1)))
{
QPainter painter(&pixmap);
painter.setCompositionMode(QPainter::CompositionMode_SourceIn);
painter.fillRect(pixmap.rect(), parts.at(1));
painter.end();
}
if (requestedSize.width() > 0 && requestedSize.height() > 0)
pixmap = pixmap.scaled(requestedSize.width(), requestedSize.height(), Qt::IgnoreAspectRatio);
else
pixmap = pixmap;
m_pixmapCache.insert(pixmapId, pixmap); m_pixmapCache.insert(pixmapId, pixmap);
} }
}
return pixmap; return pixmap;
} }
......
...@@ -45,6 +45,8 @@ ...@@ -45,6 +45,8 @@
#include <QHash> #include <QHash>
#include <QPixmap> #include <QPixmap>
#include <QString> #include <QString>
#include <QPainter>
#include <QColor>
#ifdef HAVE_MLITE #ifdef HAVE_MLITE
#include <mgconfitem.h> #include <mgconfitem.h>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment