diff options
Diffstat (limited to 'gui/iconcache.h')
-rw-r--r-- | gui/iconcache.h | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/gui/iconcache.h b/gui/iconcache.h new file mode 100644 index 00000000..5c5e4142 --- /dev/null +++ b/gui/iconcache.h @@ -0,0 +1,43 @@ +#pragma once + +#include <QMutex> +#include <QtGui/QIcon> + +class Private; + +class IconCache +{ +public: + static IconCache* instance() + { + if (!m_Instance) + { + mutex.lock(); + if (!m_Instance) + m_Instance = new IconCache; + mutex.unlock(); + } + return m_Instance; + } + + static void drop() + { + mutex.lock(); + delete m_Instance; + m_Instance = 0; + mutex.unlock(); + } + + QIcon getIcon(QString name); + +private: + IconCache(); + // hide copy constructor + IconCache(const IconCache &); + // hide assign op + IconCache& operator=(const IconCache &); + static IconCache* m_Instance; + static QMutex mutex; + Private* d; +}; +
\ No newline at end of file |