OpenTwin 0.1
OpenTwin
 
Loading...
Searching...
No Matches
IconManager.h
Go to the documentation of this file.
1
4// ###########################################################################################################################################################################################################################################################################################################################
5
6#pragma once
7
8// OpenTwin header
10#include "OTCore/Logger.h"
11
12// Qt header
13#include <QtCore/qstring.h>
14#include <QtCore/qbytearray.h>
15#include <QtCore/qstringlist.h>
16#include <QtGui/qicon.h>
17#include <QtGui/qmovie.h>
18#include <QtGui/qpixmap.h>
19
20// std header
21#include <map>
22#include <mutex>
23#include <optional>
24
25namespace ot {
26
34 public:
36 static IconManager& instance(void);
37
38 static bool addSearchPath(const QString& _path);
39
40 static const QStringList& searchPaths(void);
41
43 static const QIcon& getIcon(const QString& _subPath);
44
46 static const QPixmap& getPixmap(const QString& _subPath);
47
49 static std::shared_ptr<QMovie> getMovie(const QString& _subPath);
50
52 static const QByteArray& getSvgData(const QString& _subPath);
53
55 static void setApplicationIcon(const QIcon& _icon);
56
59 static const QIcon& getApplicationIcon(void);
60
61 private:
62 template <class T>
63 std::shared_ptr<T>& getOrCreate(const QString& _subPath, std::map<QString, std::shared_ptr<T>>& _dataMap, std::shared_ptr<T>& _default);
64
65 template <class T>
66 std::optional<std::shared_ptr<T>*> get(const QString& _subPath, std::map<QString, std::shared_ptr<T>>& _dataMap);
67
68 template <class T>
69 std::optional<std::shared_ptr<T>*> getWhileLocked(const QString& _subPath, std::map<QString, std::shared_ptr<T>>& _dataMap);
70
71 QString findFullPath(const QString& _subPath);
72
74 virtual ~IconManager();
75
76 QStringList m_searchPaths;
77 std::mutex m_mutex;
78 std::map<QString, std::shared_ptr<QIcon>> m_icons;
79 std::map<QString, std::shared_ptr<QPixmap>> m_pixmaps;
80 std::map<QString, std::shared_ptr<QMovie>> m_movies;
81 std::map<QString, std::shared_ptr<QByteArray>> m_svgData;
82 std::shared_ptr<QIcon> m_emptyIcon;
83 std::shared_ptr<QPixmap> m_emptyPixmap;
84 std::shared_ptr<QMovie> m_emptyMovie;
85 std::shared_ptr<QByteArray> m_emptySvgData;
86 QIcon m_applicationIcon;
87 };
88
89}
90
OpenTwin Logging system.
#define OT_WIDGETS_API_EXPORT
Definition OTWidgetsAPIExport.h:12
The IconManager loads images or animations and caches them. The IconManager has a search path list....
Definition IconManager.h:33
Definition Connector.h:8