1
0
Fork 0
mirror of https://github.com/transmission/transmission synced 2024-12-23 00:04:06 +00:00
transmission/qt/IconCache.h
Charles Kerr 68920f5fa6
refactor: remove exit-time destructors from transmission-qt (#1395)
* refactor: remove exit-time destructors from transmission-qt
2020-08-15 10:42:51 -05:00

48 lines
1,023 B
C++

/*
* This file Copyright (C) 2009-2015 Mnemosyne LLC
*
* It may be used under the GNU GPL versions 2 or 3
* or any future license endorsed by Mnemosyne LLC.
*
*/
#pragma once
#if defined(_WIN32)
#include <windows.h> // UINT
class QFileInfo;
#else
#include <unordered_map>
#include <unordered_set>
#include "Utils.h" // std::hash<QString>()
#endif
#include <QIcon>
#include <QString>
class QModelIndex;
class IconCache
{
public:
static IconCache& get();
QIcon folderIcon() const { return folder_icon_; }
QIcon fileIcon() const { return file_icon_; }
QIcon guessMimeIcon(QString const& filename) const;
protected:
IconCache();
private:
QIcon const folder_icon_;
QIcon const file_icon_;
#if defined(_WIN32)
void addAssociatedFileIcon(QFileInfo const& file_info, UINT icon_size, QIcon& icon) const;
#else
mutable std::unordered_map<QString, QIcon> icon_cache_;
mutable std::unordered_set<QString> suffixes_;
QIcon getMimeIcon(QString const& filename) const;
#endif
};