summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Cord-Landwehr <cordlandwehr@kde.org>2015-09-28 17:45:35 (GMT)
committerAndreas Cord-Landwehr <cordlandwehr@kde.org>2015-09-28 18:25:01 (GMT)
commit391857e7697727f684f745d123a24e673b377cbe (patch)
treee9b2ad717d2d57fdd9878628578a26e79ec405ee
parent68bfc67c2b653afff9eed7d39f3cf59c7a85778a (diff)
Port away from KPixmapCache.
Actually KPixmapCache was never fully used, just as a convenience method to avoid loading pixmaps "by hand".
-rw-r--r--src/kalziumdataobject.cpp38
1 files changed, 19 insertions, 19 deletions
diff --git a/src/kalziumdataobject.cpp b/src/kalziumdataobject.cpp
index d42371d..a12fbbb 100644
--- a/src/kalziumdataobject.cpp
+++ b/src/kalziumdataobject.cpp
@@ -27,13 +27,13 @@
#include <QFile>
#include <QFileInfo>
+#include <QSvgRenderer>
#include <QPainter>
#include <QGlobalStatic>
#include <QLocale>
#include <QDebug>
#include <QUrl>
-#include <KPixmapCache>
#include <kunitconversion/converter.h>
#include <QStandardPaths>
@@ -193,28 +193,28 @@ void KalziumDataObject::cleanup()
void KalziumDataObject::loadIconSet()
{
- KPixmapCache cache("kalzium");
//FIXME in case we ever get more than one theme we need
//a settings-dialog where we can select the different iconsets...
const QString setname = "school";
- QString pathname = QStandardPaths::locate(QStandardPaths::DataLocation, "data/iconsets/") + "data/iconsets/";
- pathname = QFileInfo(pathname).absolutePath();
+ QString pathname = QStandardPaths::locate(
+ QStandardPaths::DataLocation, "data/iconsets/" + setname + '/',
+ QStandardPaths::LocateDirectory);
+ QSvgRenderer renderer;
+
+ for (int i = 0; i < m_numOfElements; ++i) {
+ QString filename = pathname + QString::number(i + 1) + ".svg";
+
+ renderer.load(filename);
+ QPixmap pix(40, 40);
+ pix.fill(Qt::transparent);
+ QPainter p(&pix);
+ renderer.render(&p);
+
+ Element *e = ElementList.at(i);
+ QString esymbol = e->dataAsString(ChemicalDataObject::symbol);
+ p.drawText(0,0,40,40, Qt::AlignCenter | Qt::TextWordWrap, esymbol);
+ p.end();
- for (int i = 0; i < m_numOfElements; ++i)
- {
- QString filename = pathname + setname + '/' + QString::number(i + 1) + ".svg";
-
- QPixmap pix = cache.loadFromSvg(filename, QSize(40, 40));
- if (pix.isNull()) {
- pix = QPixmap(40, 40);
- pix.fill(Qt::transparent);
-
- QPainter p(&pix);
- Element *e = ElementList.at(i);
- QString esymbol = e->dataAsString(ChemicalDataObject::symbol);
- p.drawText(0,0,40,40, Qt::AlignCenter | Qt::TextWordWrap, esymbol);
- p.end();
- }
PixmapList << pix;
}
}