Commit b479e47c authored by Frederik Schwarzer's avatar Frederik Schwarzer

KPixmapCache -> QPixmapCache.

parent f2cb670b
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
#include "preferences.h" #include "preferences.h"
#include <QSvgRenderer> #include <QSvgRenderer>
#include <KPixmapCache> #include <QPixmapCache>
#define USE_UNSTABLE_LIBKDEGAMESPRIVATE_API #define USE_UNSTABLE_LIBKDEGAMESPRIVATE_API
#include <libkdegamesprivate/kgametheme.h> #include <libkdegamesprivate/kgametheme.h>
...@@ -35,9 +35,8 @@ namespace Kigo { ...@@ -35,9 +35,8 @@ namespace Kigo {
ThemeRenderer::ThemeRenderer() ThemeRenderer::ThemeRenderer()
: m_currentTheme() : m_currentTheme()
, m_renderer(new QSvgRenderer) , m_renderer(new QSvgRenderer)
, m_cache(new KPixmapCache(QStringLiteral("kigo-cache")))
{ {
m_cache->setCacheLimit(3 * 1024); QPixmapCache::setCacheLimit(3 * 1024);
if (!loadTheme(Preferences::theme())) { if (!loadTheme(Preferences::theme())) {
//qDebug() << "Failed to load any game theme!"; //qDebug() << "Failed to load any game theme!";
} }
...@@ -45,7 +44,6 @@ ThemeRenderer::ThemeRenderer() ...@@ -45,7 +44,6 @@ ThemeRenderer::ThemeRenderer()
ThemeRenderer::~ThemeRenderer() ThemeRenderer::~ThemeRenderer()
{ {
delete m_cache;
delete m_renderer; delete m_renderer;
} }
...@@ -77,7 +75,7 @@ bool ThemeRenderer::loadTheme(const QString &themeName) ...@@ -77,7 +75,7 @@ bool ThemeRenderer::loadTheme(const QString &themeName)
if (discardCache) { if (discardCache) {
// //qDebug() << "Discarding cache"; // //qDebug() << "Discarding cache";
m_cache->discard(); QPixmapCache::clear();
} }
emit themeChanged(m_currentTheme); emit themeChanged(m_currentTheme);
return true; return true;
...@@ -136,7 +134,7 @@ QPixmap ThemeRenderer::renderElement(Element element, const QSize &size) const ...@@ -136,7 +134,7 @@ QPixmap ThemeRenderer::renderElement(Element element, const QSize &size) const
// Check if board element is already in cache, if not render it // Check if board element is already in cache, if not render it
QPixmap pixmap; QPixmap pixmap;
if (!m_cache->find(cacheName, pixmap)) { if (!QPixmapCache::find(cacheName, pixmap)) {
pixmap = QPixmap(size); pixmap = QPixmap(size);
pixmap.fill(Qt::transparent); pixmap.fill(Qt::transparent);
QPainter p(&pixmap); QPainter p(&pixmap);
...@@ -174,7 +172,7 @@ QPixmap ThemeRenderer::renderElement(Element element, const QSize &size) const ...@@ -174,7 +172,7 @@ QPixmap ThemeRenderer::renderElement(Element element, const QSize &size) const
m_renderer->render(&p, QStringLiteral("placement_marker")); m_renderer->render(&p, QStringLiteral("placement_marker"));
break; break;
} }
m_cache->insert(cacheName, pixmap); QPixmapCache::insert(cacheName, pixmap);
} }
return pixmap; return pixmap;
} }
......
...@@ -24,7 +24,6 @@ ...@@ -24,7 +24,6 @@
#include <QObject> #include <QObject>
#include <QString> #include <QString>
class KPixmapCache;
class QSvgRenderer; class QSvgRenderer;
class QPixmap; class QPixmap;
class QPainter; class QPainter;
...@@ -119,7 +118,6 @@ signals: ...@@ -119,7 +118,6 @@ signals:
private: private:
QString m_currentTheme; ///< Holds the current seleted theme QString m_currentTheme; ///< Holds the current seleted theme
QSvgRenderer *m_renderer; ///< Converts SVG parts into pixmaps QSvgRenderer *m_renderer; ///< Converts SVG parts into pixmaps
KPixmapCache *m_cache; ///< Stores pixmaps efficiently
}; };
} // End of namespace Kigo } // End of namespace Kigo
......
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