Remove unused cipher map.
[quassel.git] / src / uisupport / iconloader.h
1 /***************************************************************************
2  *   Copyright (C) 2005-2013 by the Quassel Project                        *
3  *   devel@quassel-irc.org                                                 *
4  *                                                                         *
5  *   Based in part on KDE's kiconloader.h                                  *
6  *   This declares a subset of that API.                                   *
7  *                                                                         *
8  *   This program is free software; you can redistribute it and/or modify  *
9  *   it under the terms of the GNU General Public License as published by  *
10  *   the Free Software Foundation; either version 2 of the License, or     *
11  *   (at your option) version 3.                                           *
12  *                                                                         *
13  *   This program is distributed in the hope that it will be useful,       *
14  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
15  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
16  *   GNU General Public License for more details.                          *
17  *                                                                         *
18  *   You should have received a copy of the GNU General Public License     *
19  *   along with this program; if not, write to the                         *
20  *   Free Software Foundation, Inc.,                                       *
21  *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.         *
22  ***************************************************************************/
23
24 #ifndef ICONLOADER_H_
25 #define ICONLOADER_H_
26
27 #ifndef HAVE_KDE
28
29 #include <QPixmap>
30
31 /// Provides basic facilities to load icons from standard locations or resources
32 /** This implements a (very) basic subset of KIconLoader's API, such that we can use those classes
33  *  interchangeably in Quassel.
34  *
35  *  We currently (unless somebody does a more fancy implementation ;-)) assume the Oxygen icon theme
36  *  to be used. In particular, this means that we do assume its directory layout and existing icons to
37  *  be present. Though it should be easy to switch to a different theme name, we don't currently support
38  *  any fallback mechanism if this other theme misses an icon for a given size. Also, we only support PNG.
39  *
40  *  Since we do support integrating the required part of Oxygen into the binary via Qt Resources, this
41  *  should work for everyone for now.
42  *
43  *  - $XDG_DATA_DIRS/icons/$theme (in order)
44  *  - :/icons/$theme (fallback in case we use Qt Resources)
45  *  - $XDG_DATA_DIRS/apps/quassel/icons/hicolor (our own unthemed icons)
46  *  - :/icons/hicolor
47  *  - $XDG_DATA_DIRS/apps/quassel/pics
48  *  - :/pics
49  *
50  *  We don't search for size/context dirs in /pics, i.e. for a given $name, we expect pics/$name.png.
51  */
52 class IconLoader : public QObject
53 {
54     Q_OBJECT
55
56 public:
57     enum Group {
58         NoGroup = -1, ///< No group
59         Desktop = 0, ///< Desktop icons
60         Toolbar,    ///< Toolbar icons
61         MainToolbar, ///< Main toolbar icons
62         Small,      ///< Small icons, e.g. for buttons
63         Panel,      ///< Panel icons
64         Dialog,     ///< Icons for use in dialog title etc.
65         LastGroup
66     };
67
68     /// Standard icon sizes
69     enum StdSizes {
70         SizeSmall = 16,   ///< Small icons for menu entries
71         SizeSmallMedium = 22, ///< Slightly larger small icons for toolbars, panels, etc
72         SizeMedium = 32,  ///< Medium-sized icons for the desktop
73         SizeLarge = 48,   ///< Large icons for the panel
74         SizeHuge = 64,    ///< Huge icons for iconviews
75         SizeEnormous = 128 ///< Enormous icons for iconviews
76     };
77
78     explicit IconLoader(QObject *parent = 0);
79     ~IconLoader();
80
81     static IconLoader *global();
82
83     /// Load a pixmap for the given name and group
84     QPixmap loadIcon(const QString &name, IconLoader::Group group, int size = 0);
85
86     inline QString theme() const;
87     void setTheme(const QString &name);
88
89 private:
90     QString findIconPath(const QString &name, int size);
91
92     static IconLoader _iconLoader;
93     QString _theme;
94     QStringList _themedIconDirNames;
95     QStringList _plainIconDirNames;
96     static int _groupSize[];
97 };
98
99
100 // convenience
101 QPixmap DesktopIcon(const QString &name, int size = 0);
102 QPixmap BarIcon(const QString &name, int size = 0);
103 QPixmap MainBarIcon(const QString &name, int size = 0);
104 QPixmap SmallIcon(const QString &name, int size = 0);
105 //QPixmap SmallMediumIcon(const QString &name, int size = 0);  // not part of KIconLoader
106
107 QString IconLoader::theme() const { return _theme; }
108
109 #else /* HAVE_KDE */
110
111 #include <KIconLoader>
112 class IconLoader : public KIconLoader
113 {
114     Q_OBJECT
115 };
116
117
118 #endif /* HAVE_KDE */
119
120 #endif