1 /***************************************************************************
2 * Copyright (C) 2005-08 by the Quassel IRC Team *
3 * devel@quassel-irc.org *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 2 of the License, or *
8 * (at your option) version 3. *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program; if not, write to the *
17 * Free Software Foundation, Inc., *
18 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
19 ***************************************************************************
20 * Based in part on KDE's kiconloader.h *
21 * This declares a subset of that API. *
22 ***************************************************************************/
29 /// Provides basic facilities to load icons from standard locations or resources
30 /** This implements a (very) basic subset of KIconLoader's API, such that we can use those classes
31 * interchangeably in Quassel.
33 * We currently (unless somebody does a more fancy implementation ;-)) assume the Oxygen icon theme
34 * to be used. In particular, this means that we do assume its directory layout and existing icons to
35 * be present. Though it should be easy to switch to a different theme name, we don't currently support
36 * any fallback mechanism if this other theme misses an icon for a given size. Also, we only support PNG.
38 * Since we do support integrating the required part of Oxygen into the binary via Qt Resources, this
39 * should work for everyone for now.
41 * - $XDG_DATA_DIRS/icons/$theme (in order)
42 * - :/icons/$theme (fallback in case we use Qt Resources)
43 * - $XDG_DATA_DIRS/apps/quassel/icons/hicolor (our own unthemed icons)
45 * - $XDG_DATA_DIRS/apps/quassel/pics
48 * We don't search for size/context dirs in /pics, i.e. for a given $name, we expect pics/$name.png.
50 class IconLoader : public QObject {
55 NoGroup = -1, ///< No group
56 Desktop = 0, ///< Desktop icons
57 Toolbar, ///< Toolbar icons
58 MainToolbar, ///< Main toolbar icons
59 Small, ///< Small icons, e.g. for buttons
60 Panel, ///< Panel icons
61 Dialog, ///< Icons for use in dialog title etc.
65 /// Standard icon sizes
67 SizeSmall=16, ///< Small icons for menu entries
68 SizeSmallMedium=22, ///< Slightly larger small icons for toolbars, panels, etc
69 SizeMedium=32, ///< Medium-sized icons for the desktop
70 SizeLarge=48, ///< Large icons for the panel
71 SizeHuge=64, ///< Huge icons for iconviews
72 SizeEnormous=128 ///< Enormous icons for iconviews
75 explicit IconLoader(QObject *parent = 0);
78 static IconLoader *global();
80 /// Load a pixmap for the given name and group
81 QPixmap loadIcon(const QString& name, IconLoader::Group group, int size = 0);
83 inline QString theme() const;
84 void setTheme(const QString &name);
87 QString findIconPath(const QString &name, int size);
89 static IconLoader _iconLoader;
91 QStringList _themedIconDirNames;
92 QStringList _plainIconDirNames;
93 static int _groupSize[];
97 QPixmap DesktopIcon(const QString& name, int size = 0);
98 QPixmap BarIcon(const QString& name, int size = 0);
99 QPixmap MainBarIcon(const QString& name, int size = 0);
100 QPixmap SmallIcon(const QString& name, int size = 0);
101 //QPixmap SmallMediumIcon(const QString &name, int size = 0); // not part of KIconLoader
103 QString IconLoader::theme() const { return _theme; }