1 /***************************************************************************
2 * Copyright (C) 2005-09 by the Quassel Project *
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 ***************************************************************************/
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 {
57 NoGroup = -1, ///< No group
58 Desktop = 0, ///< Desktop icons
59 Toolbar, ///< Toolbar icons
60 MainToolbar, ///< Main toolbar icons
61 Small, ///< Small icons, e.g. for buttons
62 Panel, ///< Panel icons
63 Dialog, ///< Icons for use in dialog title etc.
67 /// Standard icon sizes
69 SizeSmall=16, ///< Small icons for menu entries
70 SizeSmallMedium=22, ///< Slightly larger small icons for toolbars, panels, etc
71 SizeMedium=32, ///< Medium-sized icons for the desktop
72 SizeLarge=48, ///< Large icons for the panel
73 SizeHuge=64, ///< Huge icons for iconviews
74 SizeEnormous=128 ///< Enormous icons for iconviews
77 explicit IconLoader(QObject *parent = 0);
80 static IconLoader *global();
82 /// Load a pixmap for the given name and group
83 QPixmap loadIcon(const QString& name, IconLoader::Group group, int size = 0);
85 inline QString theme() const;
86 void setTheme(const QString &name);
89 QString findIconPath(const QString &name, int size);
91 static IconLoader _iconLoader;
93 QStringList _themedIconDirNames;
94 QStringList _plainIconDirNames;
95 static int _groupSize[];
99 QPixmap DesktopIcon(const QString& name, int size = 0);
100 QPixmap BarIcon(const QString& name, int size = 0);
101 QPixmap MainBarIcon(const QString& name, int size = 0);
102 QPixmap SmallIcon(const QString& name, int size = 0);
103 //QPixmap SmallMediumIcon(const QString &name, int size = 0); // not part of KIconLoader
105 QString IconLoader::theme() const { return _theme; }
109 #include <KIconLoader>
110 class IconLoader : public KIconLoader { Q_OBJECT };
112 #endif /* HAVE_KDE */