3
* This file is part of the KDE project, module kdecore.
4
* Copyright (C) 2000 Geert Jansen <jansen@kde.org>
5
* Antonio Larrosa <larrosa@kde.org>
7
* This is free software; it comes under the GNU Library General
8
* Public License, version 2. See the file "COPYING.LIB" for the
9
* exact licensing terms.
13
#ifndef __KIconTheme_h_Included__
14
#define __KIconTheme_h_Included__
17
#include <qstringlist.h>
19
#include "kdelibs_export.h"
22
//class KIconThemeDir;
24
class KIconThemePrivate;
29
* One icon as found by KIconTheme. Also serves as a namespace containing
30
* icon related constants.
35
class KDECORE_EXPORT KIcon
41
* Return true if this icon is valid, false otherwise.
43
bool isValid() const { return size != 0; }
46
* Defines the context of the icon.
49
Any, ///< Some icon with unknown purpose.
50
Action, ///< An action icon (e.g. 'save', 'print').
51
Application, ///< An icon that represents an application.
52
Device, ///< An icon that represents a device.
53
FileSystem, ///< An icon that represents a file system.
54
MimeType ///< An icon that represents a mime type (or file type).
58
* The type of the icon.
61
Fixed, ///< Fixed-size icon.
62
Scalable, ///< Scalable-size icon.
63
Threshold ///< A threshold icon.
67
* The type of a match.
70
MatchExact, ///< Only try to find an exact match.
71
MatchBest ///< Take the best match if there is no exact match.
75
// if you add a group here, make sure to change the config reading in
78
* The group of the icon.
89
/// Main toolbar icons
93
/// Panel (Kicker) icons
102
* These are the standard sizes for icons.
105
/// small icons for menu entries
107
/// slightly larger small icons for toolbars, panels, etc
109
/// medium sized icons for the desktop
111
/// large sized icons for the panel
113
/// huge sized icons for iconviews
115
/// enormous sized icons for iconviews
120
* Defines the possible states of an icon.
122
enum States { DefaultState, ///< The default state.
123
ActiveState, ///< Icon is active.
124
DisabledState, ///< Icon is disabled.
125
LastState ///< Last state (last constant)
129
* This defines an overlay, a semi-transparent image that is
130
* projected onto the icon. They are used to show that the file
131
* represented by the icon is, for example, locked, zipped or hidden.
134
LockOverlay=0x100, ///< a file is locked
135
ZipOverlay=0x200, ///< a file is zipped
136
LinkOverlay=0x400, ///< a file is a link
137
HiddenOverlay=0x800, ///< a file is hidden
138
ShareOverlay=0x1000, ///< a file is shared
143
* The size in pixels of the icon.
148
* The context of the icon.
153
* The type of the icon: Fixed, Scalable or Threshold.
158
* The threshold in case type == Threshold
163
* The full path of the icon.
171
inline KIcon::Group& operator++(KIcon::Group& group) { group = static_cast<KIcon::Group>(group+1); return group; }
172
inline KIcon::Group operator++(KIcon::Group& group,int) { KIcon::Group ret = group; ++group; return ret; }
175
* Class to use/access icon themes in KDE. This class is used by the
176
* iconloader but can be used by others too.
179
class KDECORE_EXPORT KIconTheme
183
* Load an icon theme by name.
184
* @param name the name of the theme (e.g. "hicolor" or "keramik")
185
* @param appName the name of the application. Can be null. This argument
186
* allows applications to have themed application icons.
188
KIconTheme(const QString& name, const QString& appName=QString::null);
192
* The stylized name of the icon theme.
193
* @return the (human-readable) name of the theme
195
QString name() const { return mName; }
198
* A description for the icon theme.
199
* @return a human-readable description of the theme, QString::null
202
QString description() const { return mDesc; }
205
* Return the name of the "example" icon. This can be used to
206
* present the theme to the user.
207
* @return the name of the example icon, QString::null if there is none
209
QString example() const;
212
* Return the name of the screenshot.
213
* @return the name of the screenshot, QString::null if there is none
215
QString screenshot() const;
218
* Returns the name of this theme's link overlay.
219
* @return the name of the link overlay
221
QString linkOverlay() const;
224
* Returns the name of this theme's zip overlay.
225
* @return the name of the zip overlay
227
QString zipOverlay() const;
230
* Returns the name of this theme's lock overlay.
231
* @return the name of the lock overlay
233
QString lockOverlay() const;
236
* Returns the name of this theme's share overlay.
237
* @return the name of the share overlay
240
QString shareOverlay () const;
243
* Returns the toplevel theme directory.
244
* @return the directory of the theme
246
QString dir() const { return mDir; }
249
* The themes this icon theme falls back on.
250
* @return a list of icon themes that are used as fall-backs
252
QStringList inherits() const { return mInherits; }
255
* The icon theme exists?
256
* @return true if the icon theme is valid
258
bool isValid() const;
261
* The icon theme should be hidden to the user?
262
* @return true if the icon theme is hidden
265
bool isHidden() const;
268
* The minimum display depth required for this theme. This can either
270
* @return the minimum bpp (8 or 32)
272
int depth() const { return mDepth; }
275
* The default size of this theme for a certain icon group.
276
* @param group The icon group. See KIcon::Group.
277
* @return The default size in pixels for the given icon group.
279
int defaultSize(KIcon::Group group) const;
282
* Query available sizes for a group.
283
* @param group The icon group. See KIcon::Group.
284
* @return a list of available sized for the given group
286
QValueList<int> querySizes(KIcon::Group group) const;
289
* Query available icons for a size and context.
290
* @param size the size of the icons
291
* @param context the context of the icons
292
* @return the list of icon names
294
QStringList queryIcons(int size, KIcon::Context context = KIcon::Any) const;
297
* Query available icons for a context and preferred size.
298
* @param size the size of the icons
299
* @param context the context of the icons
300
* @return the list of icon names
302
QStringList queryIconsByContext(int size, KIcon::Context context = KIcon::Any) const;
306
* Lookup an icon in the theme.
307
* @param name The name of the icon, without extension.
308
* @param size The desired size of the icon.
309
* @param match The matching mode. KIcon::MatchExact returns an icon
310
* only if matches exactly. KIcon::MatchBest returns the best matching
312
* @return A KIcon class that describes the icon. If an icon is found,
313
* @see KIcon::isValid will return true, and false otherwise.
315
KIcon iconPath(const QString& name, int size, KIcon::MatchType match) const;
318
* List all icon themes installed on the system, global and local.
319
* @return the list of all icon themes
321
static QStringList list();
324
* Returns the current icon theme.
325
* @return the name of the current theme
327
static QString current();
330
* Reconfigure the theme.
332
static void reconfigure();
335
* Returns the default icon theme.
336
* @return the name of the default theme name
339
static QString defaultThemeName();
343
QValueList<int> mSizes[8];
346
QString mDir, mName, mDesc;
347
QStringList mInherits;
348
// QPtrList<KIconThemeDir> mDirs;
349
KIconThemePrivate *d;
351
static QString *_theme;
352
static QStringList *_theme_list;