~ubuntu-branches/ubuntu/karmic/python-kde3/karmic

« back to all changes in this revision

Viewing changes to extra/kde353/kicontheme.h

  • Committer: Bazaar Package Importer
  • Author(s): Jonathan Riddell
  • Date: 2006-11-22 19:03:34 UTC
  • mfrom: (1.1.5 upstream) (3.1.1 etch)
  • Revision ID: james.westby@ubuntu.com-20061122190334-z7nhzu4dca926iam
Tags: 3.16.0-0ubuntu1
* New upstream release
* Build-depend on pyqt 3.17 and sip 4.5
* Add build-depends on /usr/lib/kde3/libkonsolepart.so
* Don't build for python 2.5, it fails to build
* Merge with Debian, remaining change:
  - kubuntu_01_dcop.diff patch

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* vi: ts=8 sts=4 sw=4
 
2
 *
 
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>
 
6
 *
 
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.
 
10
 *
 
11
 */
 
12
 
 
13
#ifndef __KIconTheme_h_Included__
 
14
#define __KIconTheme_h_Included__
 
15
 
 
16
#include <qstring.h>
 
17
#include <qstringlist.h>
 
18
#include <qptrlist.h>
 
19
#include "kdelibs_export.h"
 
20
 
 
21
class KConfig;
 
22
//class KIconThemeDir;
 
23
 
 
24
class KIconThemePrivate;
 
25
 
 
26
class KIconPrivate;
 
27
 
 
28
/**
 
29
 * One icon as found by KIconTheme. Also serves as a namespace containing
 
30
 * icon related constants.
 
31
 * @see KIconEffect
 
32
 * @see KIconTheme
 
33
 * @see KIconLoader
 
34
 */
 
35
class KDECORE_EXPORT KIcon
 
36
{
 
37
public:
 
38
    KIcon() { size = 0; }
 
39
 
 
40
    /**
 
41
     * Return true if this icon is valid, false otherwise.
 
42
     */
 
43
    bool isValid() const { return size != 0; }
 
44
 
 
45
    /**
 
46
     * Defines the context of the icon.
 
47
     */
 
48
    enum Context {
 
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).
 
55
    };
 
56
 
 
57
    /**
 
58
     * The type of the icon.
 
59
     */
 
60
    enum Type {
 
61
      Fixed, ///< Fixed-size icon.
 
62
      Scalable, ///< Scalable-size icon.
 
63
      Threshold ///< A threshold icon.
 
64
    };
 
65
 
 
66
    /**
 
67
     * The type of a match.
 
68
     */
 
69
    enum MatchType {
 
70
      MatchExact, ///< Only try to find an exact match.
 
71
      MatchBest   ///< Take the best match if there is no exact match.
 
72
 
 
73
    };
 
74
 
 
75
    // if you add a group here, make sure to change the config reading in
 
76
    // KIconLoader too
 
77
    /**
 
78
     * The group of the icon.
 
79
     */
 
80
    enum Group {
 
81
        /// No group
 
82
        NoGroup=-1,
 
83
        /// Desktop icons
 
84
        Desktop=0,
 
85
        /// First group
 
86
        FirstGroup=0,
 
87
        /// Toolbar icons
 
88
        Toolbar,
 
89
        /// Main toolbar icons
 
90
        MainToolbar,
 
91
        /// Small icons
 
92
        Small,
 
93
        /// Panel (Kicker) icons
 
94
        Panel,
 
95
        /// Last group
 
96
        LastGroup,
 
97
        /// User icons
 
98
        User
 
99
         };
 
100
 
 
101
    /**
 
102
     * These are the standard sizes for icons.
 
103
     */
 
104
    enum StdSizes {
 
105
        /// small icons for menu entries
 
106
        SizeSmall=16,
 
107
        /// slightly larger small icons for toolbars, panels, etc
 
108
        SizeSmallMedium=22,
 
109
        /// medium sized icons for the desktop
 
110
        SizeMedium=32,
 
111
        /// large sized icons for the panel
 
112
        SizeLarge=48,
 
113
        /// huge sized icons for iconviews
 
114
        SizeHuge=64,
 
115
        /// enormous sized icons for iconviews
 
116
        SizeEnormous=128
 
117
         };
 
118
 
 
119
    /**
 
120
     * Defines the possible states of an icon.
 
121
     */
 
122
    enum States { DefaultState, ///< The default state.
 
123
                  ActiveState,  ///< Icon is active.
 
124
                  DisabledState, ///< Icon is disabled.
 
125
                  LastState      ///< Last state (last constant)
 
126
    };
 
127
 
 
128
    /**
 
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.
 
132
     */
 
133
    enum Overlays {
 
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
 
139
      OverlayMask = ~0xff
 
140
    };
 
141
 
 
142
    /**
 
143
     * The size in pixels of the icon.
 
144
     */
 
145
    int size;
 
146
 
 
147
    /**
 
148
     * The context of the icon.
 
149
     */
 
150
    Context context;
 
151
 
 
152
    /**
 
153
     * The type of the icon: Fixed, Scalable or Threshold.
 
154
     **/
 
155
    Type type;
 
156
 
 
157
    /**
 
158
     * The threshold in case type == Threshold
 
159
     */
 
160
    int threshold;
 
161
 
 
162
    /**
 
163
     * The full path of the icon.
 
164
     */
 
165
    QString path;
 
166
 
 
167
private:
 
168
    KIconPrivate *d;
 
169
};
 
170
 
 
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; }
 
173
 
 
174
/**
 
175
 * Class to use/access icon themes in KDE. This class is used by the
 
176
 * iconloader but can be used by others too.
 
177
 * @see KIconLoader
 
178
 */
 
179
class KDECORE_EXPORT KIconTheme
 
180
{
 
181
public:
 
182
    /**
 
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.
 
187
     */
 
188
    KIconTheme(const QString& name, const QString& appName=QString::null);
 
189
    ~KIconTheme();
 
190
 
 
191
    /**
 
192
     * The stylized name of the icon theme.
 
193
     * @return the (human-readable) name of the theme
 
194
     */
 
195
    QString name() const { return mName; }
 
196
 
 
197
    /**
 
198
     * A description for the icon theme.
 
199
     * @return a human-readable description of the theme, QString::null
 
200
     *         if there is none
 
201
     */
 
202
    QString description() const { return mDesc; }
 
203
 
 
204
    /**
 
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
 
208
     */
 
209
    QString example() const;
 
210
 
 
211
    /**
 
212
     * Return the name of the screenshot.
 
213
     * @return the name of the screenshot, QString::null if there is none
 
214
     */
 
215
    QString screenshot() const;
 
216
 
 
217
    /**
 
218
     * Returns the name of this theme's link overlay.
 
219
     * @return the name of the link overlay
 
220
     */
 
221
    QString linkOverlay() const;
 
222
 
 
223
    /**
 
224
     * Returns the name of this theme's zip overlay.
 
225
     * @return the name of the zip overlay
 
226
     */
 
227
    QString zipOverlay() const;
 
228
 
 
229
    /**
 
230
     * Returns the name of this theme's lock overlay.
 
231
     * @return the name of the lock overlay
 
232
     */
 
233
    QString lockOverlay() const;
 
234
 
 
235
    /**
 
236
     * Returns the name of this theme's share overlay.
 
237
     * @return the name of the share overlay
 
238
     * @since 3.1
 
239
     */
 
240
    QString shareOverlay () const;
 
241
 
 
242
    /**
 
243
     * Returns the toplevel theme directory.
 
244
     * @return the directory of the theme
 
245
     */
 
246
    QString dir() const { return mDir; }
 
247
 
 
248
    /**
 
249
     * The themes this icon theme falls back on.
 
250
     * @return a list of icon themes that are used as fall-backs
 
251
     */
 
252
    QStringList inherits() const { return mInherits; }
 
253
 
 
254
    /**
 
255
     * The icon theme exists?
 
256
     * @return true if the icon theme is valid
 
257
     */
 
258
    bool isValid() const;
 
259
 
 
260
    /**
 
261
     * The icon theme should be hidden to the user?
 
262
     * @return true if the icon theme is hidden
 
263
     * @since 3.1
 
264
     */
 
265
    bool isHidden() const;
 
266
 
 
267
    /**
 
268
     * The minimum display depth required for this theme. This can either
 
269
     * be 8 or 32.
 
270
     * @return the minimum bpp (8 or 32)
 
271
     */
 
272
    int depth() const { return mDepth; }
 
273
 
 
274
    /**
 
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.
 
278
     */
 
279
    int defaultSize(KIcon::Group group) const;
 
280
 
 
281
    /**
 
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
 
285
     */
 
286
    QValueList<int> querySizes(KIcon::Group group) const;
 
287
 
 
288
    /**
 
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
 
293
     */
 
294
    QStringList queryIcons(int size, KIcon::Context context = KIcon::Any) const;
 
295
 
 
296
    /**
 
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
 
301
     */
 
302
    QStringList queryIconsByContext(int size, KIcon::Context context = KIcon::Any) const;
 
303
 
 
304
 
 
305
    /**
 
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
 
311
     * icon.
 
312
     * @return A KIcon class that describes the icon. If an icon is found,
 
313
     * @see KIcon::isValid will return true, and false otherwise.
 
314
     */
 
315
    KIcon iconPath(const QString& name, int size, KIcon::MatchType match) const;
 
316
 
 
317
    /**
 
318
     * List all icon themes installed on the system, global and local.
 
319
     * @return the list of all icon themes
 
320
     */
 
321
    static QStringList list();
 
322
 
 
323
    /**
 
324
     * Returns the current icon theme.
 
325
     * @return the name of the current theme
 
326
     */
 
327
    static QString current();
 
328
 
 
329
    /**
 
330
     * Reconfigure the theme.
 
331
     */
 
332
    static void reconfigure();
 
333
 
 
334
    /**
 
335
     * Returns the default icon theme.
 
336
     * @return the name of the default theme name
 
337
     * @since 3.1
 
338
     */
 
339
    static QString defaultThemeName();
 
340
 
 
341
private:
 
342
    int mDefSize[8];
 
343
    QValueList<int> mSizes[8];
 
344
 
 
345
    int mDepth;
 
346
    QString mDir, mName, mDesc;
 
347
    QStringList mInherits;
 
348
//    QPtrList<KIconThemeDir> mDirs;
 
349
    KIconThemePrivate *d;
 
350
 
 
351
    static QString *_theme;
 
352
    static QStringList *_theme_list;
 
353
};
 
354
 
 
355
#endif