1 /***************************************************************************
2 * Copyright (C) 2005-2013 by the Quassel Project *
3 * devel@quassel-irc.org *
5 * Based in part on KDE's kiconloader.h *
6 * This declares a subset of that API. *
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. *
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. *
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 ***************************************************************************/
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.
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.
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.
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)
47 * - $XDG_DATA_DIRS/apps/quassel/pics
50 * We don't search for size/context dirs in /pics, i.e. for a given $name, we expect pics/$name.png.
52 class IconLoader : public QObject
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.
68 /// Standard icon sizes
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
78 explicit IconLoader(QObject *parent = 0);
81 static IconLoader *global();
83 /// Load a pixmap for the given name and group
84 QPixmap loadIcon(const QString &name, IconLoader::Group group, int size = 0);
86 inline QString theme() const;
87 void setTheme(const QString &name);
90 QString findIconPath(const QString &name, int size);
92 static IconLoader _iconLoader;
94 QStringList _themedIconDirNames;
95 QStringList _plainIconDirNames;
96 static int _groupSize[];
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
107 QString IconLoader::theme() const { return _theme; }
111 #include <KIconLoader>
112 class IconLoader : public KIconLoader
118 #endif /* HAVE_KDE */