Freeciv21
Develop your civilization from humble roots to a global empire
icons.h
Go to the documentation of this file.
1 /**************************************************************************
2  Copyright (c) 1996-2020 Freeciv21 and Freeciv contributors. This file is
3  part of Freeciv21. Freeciv21 is free software: you can redistribute it
4  and/or modify it under the terms of the GNU General Public License as
5  published by the Free Software Foundation, either version 3 of the
6  License, or (at your option) any later version. You should have received
7  a copy of the GNU General Public License along with Freeciv21. If not,
8  see https://www.gnu.org/licenses/.
9 **************************************************************************/
10 #pragma once
11 
12 #include <QHash>
13 #include <QPixmapCache>
14 /****************************************************************************
15  Class helping reading icons/pixmaps from themes/icons folder
16 ****************************************************************************/
17 class fcIcons {
19 
20 private:
21  explicit fcIcons();
23 
24 public:
25  static fcIcons *instance();
26  static void drop();
27  QIcon getIcon(const QString &id);
28  QPixmap *getPixmap(const QString &id);
29  QString getPath(const QString &id);
30 };
31 
32 // header city icons
33 class hIcon {
35 
36 private:
37  explicit hIcon() = default;
38  ;
39  static hIcon *m_instance;
40  QHash<QString, QIcon> hash;
41 
42 public:
43  static hIcon *i();
44  static void drop();
45  void createIcons();
46  QIcon get(const QString &id);
47 };
Definition: icons.h:17
QIcon getIcon(const QString &id)
Returns icon by given name.
Definition: icons.cpp:125
QPixmap * getPixmap(const QString &id)
Returns pixmap by given name, pixmap needs to be deleted by someone else.
Definition: icons.cpp:166
static fcIcons * m_instance
Definition: icons.h:22
QString getPath(const QString &id)
Returns path for icon.
Definition: icons.cpp:194
static fcIcons * instance()
Returns instance of fc_icons.
Definition: icons.cpp:36
fcIcons()
Icon provider constructor.
static void drop()
Deletes fc_icons instance.
Definition: icons.cpp:47
Q_DISABLE_COPY(fcIcons)
Definition: icons.h:33
Q_DISABLE_COPY(hIcon)
static void drop()
Definition: icons.cpp:214
hIcon()=default
void createIcons()
Definition: icons.cpp:220
QHash< QString, QIcon > hash
Definition: icons.h:40
static hIcon * m_instance
Definition: icons.h:38
static hIcon * i()
Definition: icons.cpp:205
QIcon get(const QString &id)
Definition: icons.cpp:236