1 #pragma once
2 
3 #include <QHash>
4 #include <QImage>
5 #include <QSharedPointer>
6 #include <unordered_map>
7 
8 #include "skin/legacy/imgsource.h"
9 #include "skin/legacy/pixmapsource.h"
10 #include "util/memory.h"
11 
12 class WImageStore {
13   public:
14     static std::shared_ptr<QImage> getImage(const QString& fileName, double scaleFactor);
15     static QImage* getImageNoCache(const QString& fileName, double scaleFactor);
16     static std::shared_ptr<QImage> getImage(const PixmapSource& source, double scaleFactor);
17     static QImage* getImageNoCache(const PixmapSource& source, double scaleFactor);
18     static void setLoader(QSharedPointer<ImgSource> ld);
19     // For external owned images like software generated ones.
20     static void correctImageColors(QImage* p);
21     static bool willCorrectColors();
22 
23   private:
24     static void deleteImage(QImage* p);
25 
26     // Dictionary of Images already instantiated
27     static QHash<QString, std::weak_ptr<QImage> > m_dictionary;
28     static QSharedPointer<ImgSource> m_loader;
29 };
30