KIconThemes

kiconloader.h
1/*
2
3 This file is part of the KDE project, module kdecore.
4 SPDX-FileCopyrightText: 2000 Geert Jansen <jansen@kde.org>
5 SPDX-FileCopyrightText: 2000 Antonio Larrosa <larrosa@kde.org>
6
7 SPDX-License-Identifier: LGPL-2.0-only
8*/
9
10#ifndef KICONLOADER_H
11#define KICONLOADER_H
12
13#include <QObject>
14#include <QSize>
15#include <QString>
16#include <QStringList>
17#include <memory>
18
19#if __has_include(<optional>) && __cplusplus >= 201703L
20#include <optional>
21#endif
22
23#include <kiconthemes_export.h>
24
25class QIcon;
26class QMovie;
27class QPixmap;
28
29class KIconColors;
30class KIconLoaderPrivate;
31class KIconEffect;
32class KIconTheme;
33
34/**
35 * @class KIconLoader kiconloader.h KIconLoader
36 *
37 * Iconloader for KDE.
38 *
39 * @note For most icon loading use cases perfer using QIcon::fromTheme
40 *
41 * KIconLoader will load the current icon theme and all its base themes.
42 * Icons will be searched in any of these themes. Additionally, it caches
43 * icons and applies effects according to the user's preferences.
44 *
45 * In KDE, it is encouraged to load icons by "Group". An icon group is a
46 * location on the screen where icons are being used. Standard groups are:
47 * Desktop, Toolbar, MainToolbar, Small and Panel. Each group can have some
48 * centrally-configured effects applied to its icons. This makes it possible
49 * to offer a consistent icon look in all KDE applications.
50 *
51 * The standard groups are defined below.
52 *
53 * @li KIconLoader::Desktop: Icons in the iconview of konqueror, kdesktop and similar apps.
54 * @li KIconLoader::Toolbar: Icons in toolbars.
55 * @li KIconLoader::MainToolbar: Icons in the main toolbars.
56 * @li KIconLoader::Small: Various small (typical 16x16) places: titlebars, listviews
57 * and menu entries.
58 * @li KIconLoader::Panel: Icons in kicker's panel
59 *
60 * The icons are stored on disk in an icon theme or in a standalone
61 * directory. The icon theme directories contain multiple sizes and/or
62 * depths for the same icon. The iconloader will load the correct one based
63 * on the icon group and the current theme. Icon themes are stored globally
64 * in share/icons, or, application specific in share/apps/$appdir/icons.
65 *
66 * The standalone directories contain just one version of an icon. The
67 * directories that are searched are: $appdir/pics and $appdir/toolbar.
68 * Icons in these directories can be loaded by using the special group
69 * "User".
70 *
71 */
72class KICONTHEMES_EXPORT KIconLoader : public QObject
73{
74 Q_OBJECT
75
76public:
77 /**
78 * Defines the context of the icon.
79 */
80 enum Context {
81 Any, ///< Some icon with unknown purpose.
82 Action, ///< An action icon (e.g. 'save', 'print').
83 Application, ///< An icon that represents an application.
84 Device, ///< An icon that represents a device.
85 MimeType, ///< An icon that represents a mime type (or file type).
86 Animation, ///< An icon that is animated.
87 Category, ///< An icon that represents a category.
88 Emblem, ///< An icon that adds information to an existing icon.
89 Emote, ///< An icon that expresses an emotion.
90 International, ///< An icon that represents a country's flag.
91 Place, ///< An icon that represents a location (e.g. 'home', 'trash').
92 StatusIcon, ///< An icon that represents an event.
93 };
94 Q_ENUM(Context)
95
96 /**
97 * The type of the icon.
98 */
99 enum Type {
100 Fixed, ///< Fixed-size icon.
101 Scalable, ///< Scalable-size icon.
102 Threshold, ///< A threshold icon.
103 };
104 Q_ENUM(Type)
105
106 /**
107 * The type of a match.
108 */
110 MatchExact, ///< Only try to find an exact match.
111 MatchBest, ///< Take the best match if there is no exact match.
112 MatchBestOrGreaterSize, ///< Take the best match or the match with a greater size if there is no exact match. @since 6.0
113 };
114 Q_ENUM(MatchType)
115
116 /**
117 * The group of the icon.
118 */
119 enum Group {
120 /// No group
121 NoGroup = -1,
122 /// Desktop icons
123 Desktop = 0,
124 /// First group
125 FirstGroup = 0,
126 /// Toolbar icons
128 /// Main toolbar icons
130 /// Small icons, e.g. for buttons
132 /// Panel (Plasma Taskbar) icons
133 // TODO KF6: remove this (See https://phabricator.kde.org/T14340)
135 /// Icons for use in dialog titles, page lists, etc
137 /// Last group
139 /// User icons
141 };
142 Q_ENUM(Group)
143
144 /**
145 * These are the standard sizes for icons.
146 */
147 enum StdSizes {
148 /// small icons for menu entries
149 SizeSmall = 16,
150 /// slightly larger small icons for toolbars, panels, etc
151 SizeSmallMedium = 22,
152 /// medium sized icons for the desktop
153 SizeMedium = 32,
154 /// large sized icons for the panel
155 SizeLarge = 48,
156 /// huge sized icons for iconviews
157 SizeHuge = 64,
158 /// enormous sized icons for iconviews
159 SizeEnormous = 128,
160 };
161 Q_ENUM(StdSizes)
162
163 /**
164 * Defines the possible states of an icon.
165 */
166 enum States {
167 DefaultState, ///< The default state.
168 ActiveState, ///< Icon is active.
169 DisabledState, ///< Icon is disabled.
170 SelectedState, ///< Icon is selected. @since 5.22
171 LastState, ///< Last state (last constant)
172 };
173 Q_ENUM(States)
174
175 /**
176 * Constructs an iconloader.
177 * @param appname Add the data directories of this application to the
178 * icon search path for the "User" group. The default argument adds the
179 * directories of the current application.
180 * @param extraSearchPaths additional search paths, either absolute or relative to GenericDataLocation
181 *
182 * Usually, you use the default iconloader, which can be accessed via
183 * KIconLoader::global(), so you hardly ever have to create an
184 * iconloader object yourself. That one is the application's iconloader.
185 */
186 explicit KIconLoader(const QString &appname = QString(), const QStringList &extraSearchPaths = QStringList(), QObject *parent = nullptr);
187
188 /**
189 * Cleanup
190 */
191 ~KIconLoader() override;
192
193 /**
194 * Returns the global icon loader initialized with the application name.
195 * @return global icon loader
196 */
197 static KIconLoader *global();
198
199 /**
200 * Adds @p appname to the list of application specific directories with @p themeBaseDir as its base directory.
201 * Assume the icons are in /home/user/app/icons/hicolor/48x48/my_app.png, the base directory would be
202 * /home/user/app/icons; KIconLoader automatically searches @p themeBaseDir + "/hicolor"
203 * This directory must contain a dir structure as defined by the XDG icons specification
204 * @param appname The application name.
205 * @param themeBaseDir The base directory of the application's theme (eg. "/home/user/app/icons")
206 */
207 void addAppDir(const QString &appname, const QString &themeBaseDir = QString());
208
209 /**
210 * Loads an icon. It will try very hard to find an icon which is
211 * suitable. If no exact match is found, a close match is searched.
212 * If neither an exact nor a close match is found, a null pixmap or
213 * the "unknown" pixmap is returned, depending on the value of the
214 * @p canReturnNull parameter.
215 *
216 * @param name The name of the icon, without extension.
217 * @param group The icon group. This will specify the size of and effects to
218 * be applied to the icon.
219 * @param size If nonzero, this overrides the size specified by @p group.
220 * See KIconLoader::StdSizes.
221 * @param state The icon state: @p DefaultState, @p ActiveState or
222 * @p DisabledState. Depending on the user's preferences, the iconloader
223 * may apply a visual effect to hint about its state.
224 * @param overlays a list of emblem icons to overlay, by name
225 * @see drawOverlays
226 * @param path_store If not null, the path of the icon is stored here,
227 * if the icon was found. If the icon was not found @p path_store
228 * is unaltered even if the "unknown" pixmap was returned.
229 * @param canReturnNull Can return a null pixmap? If false, the
230 * "unknown" pixmap is returned when no appropriate icon has been
231 * found. <em>Note:</em> a null pixmap can still be returned in the
232 * event of invalid parameters, such as empty names, negative sizes,
233 * and etc.
234 * @return the QPixmap. Can be null when not found, depending on
235 * @p canReturnNull.
236 */
237 QPixmap loadIcon(const QString &name,
238 KIconLoader::Group group,
239 int size = 0,
240 int state = KIconLoader::DefaultState,
241 const QStringList &overlays = QStringList(),
242 QString *path_store = nullptr,
243 bool canReturnNull = false) const;
244
245 /**
246 * Loads an icon. It will try very hard to find an icon which is
247 * suitable. If no exact match is found, a close match is searched.
248 * If neither an exact nor a close match is found, a null pixmap or
249 * the "unknown" pixmap is returned, depending on the value of the
250 * @p canReturnNull parameter.
251 *
252 * @param name The name of the icon, without extension.
253 * @param group The icon group. This will specify the size of and effects to
254 * be applied to the icon.
255 * @param scale The scale of the icon group to use. If no icon exists in the
256 * scaled group, a 1x icon with its size multiplied by the scale will be
257 * loaded instead.
258 * @param size If nonzero, this overrides the size specified by @p group.
259 * See KIconLoader::StdSizes.
260 * @param state The icon state: @p DefaultState, @p ActiveState or
261 * @p DisabledState. Depending on the user's preferences, the iconloader
262 * may apply a visual effect to hint about its state.
263 * @param overlays a list of emblem icons to overlay, by name
264 * @see drawOverlays
265 * @param path_store If not null, the path of the icon is stored here,
266 * if the icon was found. If the icon was not found @p path_store
267 * is unaltered even if the "unknown" pixmap was returned.
268 * @param canReturnNull Can return a null pixmap? If false, the
269 * "unknown" pixmap is returned when no appropriate icon has been
270 * found. <em>Note:</em> a null pixmap can still be returned in the
271 * event of invalid parameters, such as empty names, negative sizes,
272 * and etc.
273 * @return the QPixmap. Can be null when not found, depending on
274 * @p canReturnNull.
275 * @since 5.48
276 */
277 // TODO KF6 merge loadIcon() and loadScaledIcon()
278 QPixmap loadScaledIcon(const QString &name,
279 KIconLoader::Group group,
280 qreal scale,
281 int size = 0,
282 int state = KIconLoader::DefaultState,
283 const QStringList &overlays = QStringList(),
284 QString *path_store = nullptr,
285 bool canReturnNull = false) const;
286
287 /**
288 * Loads an icon. It will try very hard to find an icon which is
289 * suitable. If no exact match is found, a close match is searched.
290 * If neither an exact nor a close match is found, a null pixmap or
291 * the "unknown" pixmap is returned, depending on the value of the
292 * @p canReturnNull parameter.
293 *
294 * @param name The name of the icon, without extension.
295 * @param group The icon group. This will specify the size of and effects to
296 * be applied to the icon.
297 * @param scale The scale of the icon group to use. If no icon exists in the
298 * scaled group, a 1x icon with its size multiplied by the scale will be
299 * loaded instead.
300 * @param size If nonzero, this overrides the size specified by @p group.
301 * See KIconLoader::StdSizes. The icon will be fit into @p size
302 * without changing the aspect ratio, which particularly matters
303 * for non-square icons.
304 * @param state The icon state: @p DefaultState, @p ActiveState or
305 * @p DisabledState. Depending on the user's preferences, the iconloader
306 * may apply a visual effect to hint about its state.
307 * @param overlays a list of emblem icons to overlay, by name
308 * @see drawOverlays
309 * @param path_store If not null, the path of the icon is stored here,
310 * if the icon was found. If the icon was not found @p path_store
311 * is unaltered even if the "unknown" pixmap was returned.
312 * @param canReturnNull Can return a null pixmap? If false, the
313 * "unknown" pixmap is returned when no appropriate icon has been
314 * found. <em>Note:</em> a null pixmap can still be returned in the
315 * event of invalid parameters, such as empty names, negative sizes,
316 * and etc.
317 * @return the QPixmap. Can be null when not found, depending on
318 * @p canReturnNull.
319 * @since 5.81
320 */
321 QPixmap loadScaledIcon(const QString &name,
322 KIconLoader::Group group,
323 qreal scale,
324 const QSize &size = {},
325 int state = KIconLoader::DefaultState,
326 const QStringList &overlays = QStringList(),
327 QString *path_store = nullptr,
328 bool canReturnNull = false) const;
329
330#if __has_include(<optional>) && __cplusplus >= 201703L
331 /**
332 * Loads an icon. It will try very hard to find an icon which is
333 * suitable. If no exact match is found, a close match is searched.
334 * If neither an exact nor a close match is found, a null pixmap or
335 * the "unknown" pixmap is returned, depending on the value of the
336 * @p canReturnNull parameter.
337 *
338 * @param name The name of the icon, without extension.
339 * @param group The icon group. This will specify the size of and effects to
340 * be applied to the icon.
341 * @param scale The scale of the icon group to use. If no icon exists in the
342 * scaled group, a 1x icon with its size multiplied by the scale will be
343 * loaded instead.
344 * @param size If nonzero, this overrides the size specified by @p group.
345 * See KIconLoader::StdSizes. The icon will be fit into @p size
346 * without changing the aspect ratio, which particularly matters
347 * for non-square icons.
348 * @param state The icon state: @p DefaultState, @p ActiveState or
349 * @p DisabledState. Depending on the user's preferences, the iconloader
350 * may apply a visual effect to hint about its state.
351 * @param overlays a list of emblem icons to overlay, by name
352 * @see drawOverlays
353 * @param path_store If not null, the path of the icon is stored here,
354 * if the icon was found. If the icon was not found @p path_store
355 * is unaltered even if the "unknown" pixmap was returned.
356 * @param canReturnNull Can return a null pixmap? If false, the
357 * "unknown" pixmap is returned when no appropriate icon has been
358 * found. <em>Note:</em> a null pixmap can still be returned in the
359 * event of invalid parameters, such as empty names, negative sizes,
360 * and etc.
361 * @param colorScheme will define the stylesheet used to color this icon.
362 * Note this will only work if @p name is an svg file.
363 * @return the QPixmap. Can be null when not found, depending on
364 * @p canReturnNull.
365 * @since 5.88
366 */
367 QPixmap loadScaledIcon(const QString &name,
368 KIconLoader::Group group,
369 qreal scale,
370 const QSize &size,
371 int state,
372 const QStringList &overlays,
373 QString *path_store,
374 bool canReturnNull,
375 const std::optional<KIconColors> &colorScheme) const;
376#endif
377
378 /**
379 * Loads an icon for a mimetype.
380 * This is basically like loadIcon except that extra desktop themes are loaded if necessary.
381 *
382 * Consider using QIcon::fromTheme() with a fallback to "application-octet-stream" instead.
383 *
384 * @param iconName The name of the icon, without extension, usually from KMimeType.
385 * @param group The icon group. This will specify the size of and effects to
386 * be applied to the icon.
387 * @param size If nonzero, this overrides the size specified by @p group.
388 * See KIconLoader::StdSizes.
389 * @param state The icon state: @p DefaultState, @p ActiveState or
390 * @p DisabledState. Depending on the user's preferences, the iconloader
391 * may apply a visual effect to hint about its state.
392 * @param path_store If not null, the path of the icon is stored here.
393 * @param overlays a list of emblem icons to overlay, by name
394 * @see drawOverlays
395 * @return the QPixmap. Can not be null, the
396 * "unknown" pixmap is returned when no appropriate icon has been found.
397 */
398 QPixmap loadMimeTypeIcon(const QString &iconName,
399 KIconLoader::Group group,
400 int size = 0,
401 int state = KIconLoader::DefaultState,
402 const QStringList &overlays = QStringList(),
403 QString *path_store = nullptr) const;
404
405 /**
406 * Returns the path of an icon.
407 * @param name The name of the icon, without extension. If an absolute
408 * path is supplied for this parameter, iconPath will return it
409 * directly.
410 * @param group_or_size If positive, search icons whose size is
411 * specified by the icon group @p group_or_size. If negative, search
412 * icons whose size is - @p group_or_size.
413 * See KIconLoader::Group and KIconLoader::StdSizes
414 * @param canReturnNull Can return a null string? If not, a path to the
415 * "unknown" icon will be returned.
416 * @return the path of an icon, can be null or the "unknown" icon when
417 * not found, depending on @p canReturnNull.
418 */
419 QString iconPath(const QString &name, int group_or_size, bool canReturnNull = false) const;
420
421 /**
422 * Returns the path of an icon.
423 * @param name The name of the icon, without extension. If an absolute
424 * path is supplied for this parameter, iconPath will return it
425 * directly.
426 * @param group_or_size If positive, search icons whose size is
427 * specified by the icon group @p group_or_size. If negative, search
428 * icons whose size is - @p group_or_size.
429 * See KIconLoader::Group and KIconLoader::StdSizes
430 * @param canReturnNull Can return a null string? If not, a path to the
431 * "unknown" icon will be returned.
432 * @param scale The scale of the icon group.
433 * @return the path of an icon, can be null or the "unknown" icon when
434 * not found, depending on @p canReturnNull.
435 * @since 5.48
436 */
437 // TODO KF6 merge iconPath() with and without "scale" and move that argument after "group_or_size"
438 QString iconPath(const QString &name, int group_or_size, bool canReturnNull, qreal scale) const;
439
440 /**
441 * Loads an animated icon.
442 * @param name The name of the icon.
443 * @param group The icon group. See loadIcon().
444 * @param size Override the default size for @p group.
445 * See KIconLoader::StdSizes.
446 * @param parent The parent object of the returned QMovie.
447 * @return A QMovie object. Can be null if not found or not valid.
448 * Ownership is passed to the caller.
449 */
450 QMovie *loadMovie(const QString &name, KIconLoader::Group group, int size = 0, QObject *parent = nullptr) const;
451
452 /**
453 * Returns the path to an animated icon.
454 * @param name The name of the icon.
455 * @param group The icon group. See loadIcon().
456 * @param size Override the default size for @p group.
457 * See KIconLoader::StdSizes.
458 * @return the full path to the movie, ready to be passed to QMovie's constructor.
459 * Empty string if not found.
460 */
461 QString moviePath(const QString &name, KIconLoader::Group group, int size = 0) const;
462
463 /**
464 * Loads an animated icon as a series of still frames. If you want to load
465 * a .mng animation as QMovie instead, please use loadMovie() instead.
466 * @param name The name of the icon.
467 * @param group The icon group. See loadIcon().
468 * @param size Override the default size for @p group.
469 * See KIconLoader::StdSizes.
470 * @return A QStringList containing the absolute path of all the frames
471 * making up the animation.
472 */
473 QStringList loadAnimated(const QString &name, KIconLoader::Group group, int size = 0) const;
474
475 /**
476 * Queries all available icons for a specific group, having a specific
477 * context.
478 * @param group_or_size If positive, search icons whose size is
479 * specified by the icon group @p group_or_size. If negative, search
480 * icons whose size is - @p group_or_size.
481 * See KIconLoader::Group and KIconLoader::StdSizes
482 * @param context The icon context.
483 * @return a list of all icons
484 */
485 QStringList queryIcons(int group_or_size, KIconLoader::Context context = KIconLoader::Any) const;
486
487 /**
488 * Queries all available icons for a specific context.
489 * @param group_or_size The icon preferred group or size. If available
490 * at this group or size, those icons will be returned, in other case,
491 * icons of undefined size will be returned. Positive numbers are groups,
492 * negative numbers are negated sizes. See KIconLoader::Group and
493 * KIconLoader::StdSizes
494 * @param context The icon context.
495 * @return A QStringList containing the icon names
496 * available for that context
497 */
498 QStringList queryIconsByContext(int group_or_size, KIconLoader::Context context = KIconLoader::Any) const;
499
500 /**
501 * @internal
502 */
503 bool hasContext(KIconLoader::Context context) const;
504
505 /**
506 * Returns a list of all icons (*.png or *.xpm extension) in the
507 * given directory.
508 * @param iconsDir the directory to search in
509 * @return A QStringList containing the icon paths
510 */
511 QStringList queryIconsByDir(const QString &iconsDir) const;
512
513 /**
514 * Returns all the search paths for this icon loader, either absolute or
515 * relative to GenericDataLocation.
516 * Mostly internal (for KIconDialog).
517 * \since 5.0
518 */
519 QStringList searchPaths() const;
520
521 /**
522 * Returns the size of the specified icon group.
523 * Using e.g. KIconLoader::SmallIcon will return 16.
524 * @param group the group to check.
525 * @return the current size for an icon group.
526 */
527 int currentSize(KIconLoader::Group group) const;
528
529 /**
530 * Returns a pointer to the current theme. Can be used to query
531 * available and default sizes for groups.
532 * @note The KIconTheme will change if reconfigure() is called and
533 * therefore it's not recommended to store the pointer anywhere.
534 * @return a pointer to the current theme. 0 if no theme set.
535 */
536 KIconTheme *theme() const;
537
538#if KICONTHEMES_ENABLE_DEPRECATED_SINCE(6, 5)
539 /**
540 * Returns a pointer to the KIconEffect object used by the icon loader.
541 * @return the KIconEffect.
542 *
543 * @deprecated since 6.5, use the static KIconEffect API
544 */
545 KICONTHEMES_DEPRECATED_VERSION(6, 5, "Use static KIconEffect API")
546 KIconEffect *iconEffect() const;
547#endif
548
549 /**
550 * Reconfigure the icon loader, for instance to change the associated app name or extra search paths.
551 * This also clears the in-memory pixmap cache (even if the appname didn't change, which is useful for unittests)
552 * @param appname the application name (empty for the global iconloader)
553 * @param extraSearchPaths additional search paths, either absolute or relative to GenericDataLocation
554 */
555 void reconfigure(const QString &appname, const QStringList &extraSearchPaths = QStringList());
556
557 /**
558 * Returns the unknown icon. An icon that is used when no other icon
559 * can be found.
560 * @return the unknown pixmap
561 */
562 static QPixmap unknown();
563
564 /**
565 * Draws overlays on the specified pixmap, it takes the width and height
566 * of the pixmap into consideration
567 * @param overlays List of up to 4 overlays to blend over the pixmap. The first overlay
568 * will be in the bottom right corner, followed by bottom left, top left
569 * and top right. An empty QString can be used to leave the specific position
570 * blank.
571 * @param pixmap to draw on
572 * @since 4.7
573 */
574 void drawOverlays(const QStringList &overlays, QPixmap &pixmap, KIconLoader::Group group, int state = KIconLoader::DefaultState) const;
575
576 bool hasIcon(const QString &iconName) const;
577
578 /**
579 * Sets the colors for this KIconLoader.
580 * NOTE: if you set a custom palette, if you are using some colors from
581 * application's palette, you need to track the application palette changes by yourself.
582 * If you no longer wish to use a custom palette, use resetPalette()
583 * @see resetPalette
584 * @since 5.39
585 */
586 void setCustomPalette(const QPalette &palette);
587
588 /**
589 * The colors that will be used for the svg stylesheet in case the
590 * loaded icons are svg-based, icons can be colored in different ways in
591 * different areas of the application
592 * @return the palette, if any, an invalid one if the user didn't set it
593 * @since 5.39
594 */
595 QPalette customPalette() const;
596
597 /**
598 * Resets the custom palette used by the KIconLoader to use the
599 * QGuiApplication::palette() again (and to follow it in case the
600 * application's palette changes)
601 * @since 5.39
602 */
603 void resetPalette();
604
605 /**
606 * @returns whether we have set a custom palette using @f setCustomPalette
607 *
608 * @since 5.85
609 * @see resetPalette, setCustomPalette
610 */
611 bool hasCustomPalette() const;
612
613public Q_SLOTS:
614 // TODO: while marked as deprecated, newIconLoader() is still used:
615 // internally by KIconLoadeer as well as by Plasma's Icons kcm module (state: 5.17)
616 // this needs some further cleanup work before removing it from the API with KICONTHEMES_ENABLE_DEPRECATED_SINCE
617 /**
618 * Re-initialize the global icon loader
619 *
620 * @todo Check deprecation, still used internally.
621 * @deprecated Since 5.0, use emitChange(Group)
622 */
623 KICONTHEMES_DEPRECATED_VERSION(5, 0, "Use KIconLoader::emitChange(Group)") // TODO KF6 remove
624 void newIconLoader();
625
626 /**
627 * Emits an iconChanged() signal on all the KIconLoader instances in the system
628 * indicating that a system's icon group has changed in some way. It will also trigger
629 * a reload in all of them to update to the new theme.
630 *
631 * @p group indicates the group that has changed
632 *
633 * @since 5.0
634 */
635 static void emitChange(Group group);
636
637Q_SIGNALS:
638 /**
639 * Emitted by newIconLoader once the new settings have been loaded
640 */
641 void iconLoaderSettingsChanged();
642
643 /**
644 * Emitted when the system icon theme changes
645 *
646 * @since 5.0
647 */
648 void iconChanged(int group);
649
650private:
651 friend class KIconLoaderPrivate;
652 // @internal the data object
653 std::unique_ptr<KIconLoaderPrivate> const d;
654
655 Q_PRIVATE_SLOT(d, void _k_refreshIcons(int group))
656};
657
658namespace KDE
659{
660/**
661 * \relates KIconLoader
662 * Returns a QIcon with an appropriate
663 * KIconEngine to perform loading and rendering. KIcons thus adhere to
664 * KDE style and effect standards.
665 * @since 5.0
666 */
667KICONTHEMES_EXPORT QIcon icon(const QString &iconName, KIconLoader *iconLoader = nullptr);
668KICONTHEMES_EXPORT QIcon icon(const QString &iconName, const KIconColors &colors, KIconLoader *iconLoader = nullptr);
669
670/**
671 * \relates KIconLoader
672 * Returns a QIcon for the given icon, with additional overlays.
673 * @since 5.0
674 */
675KICONTHEMES_EXPORT QIcon icon(const QString &iconName, const QStringList &overlays, KIconLoader *iconLoader = nullptr);
676
677}
678
679inline KIconLoader::Group &operator++(KIconLoader::Group &group)
680{
681 group = static_cast<KIconLoader::Group>(group + 1);
682 return group;
683}
684inline KIconLoader::Group operator++(KIconLoader::Group &group, int)
685{
686 KIconLoader::Group ret = group;
687 ++group;
688 return ret;
689}
690
691#endif // KICONLOADER_H
Sepecifies which colors will be used when recoloring icons as its stylesheet.
Definition kiconcolors.h:31
Applies effects to icons.
Definition kiconeffect.h:40
Iconloader for KDE.
Definition kiconloader.h:73
Group
The group of the icon.
@ Small
Small icons, e.g. for buttons.
@ Panel
Panel (Plasma Taskbar) icons.
@ User
User icons.
@ LastGroup
Last group.
@ MainToolbar
Main toolbar icons.
@ Toolbar
Toolbar icons.
@ Dialog
Icons for use in dialog titles, page lists, etc.
~KIconLoader() override
Cleanup.
States
Defines the possible states of an icon.
@ ActiveState
Icon is active.
@ DisabledState
Icon is disabled.
@ LastState
Last state (last constant)
@ DefaultState
The default state.
@ SelectedState
Icon is selected.
StdSizes
These are the standard sizes for icons.
KICONTHEMES_EXPORT QIcon icon(const QString &iconName, const QStringList &overlays, KIconLoader *iconLoader=nullptr)
Returns a QIcon for the given icon, with additional overlays.
KICONTHEMES_EXPORT QIcon icon(const QString &iconName, KIconLoader *iconLoader=nullptr)
Returns a QIcon with an appropriate KIconEngine to perform loading and rendering.
Context
Defines the context of the icon.
Definition kiconloader.h:80
@ Category
An icon that represents a category.
Definition kiconloader.h:87
@ Emblem
An icon that adds information to an existing icon.
Definition kiconloader.h:88
@ StatusIcon
An icon that represents an event.
Definition kiconloader.h:92
@ Application
An icon that represents an application.
Definition kiconloader.h:83
@ Emote
An icon that expresses an emotion.
Definition kiconloader.h:89
@ Any
Some icon with unknown purpose.
Definition kiconloader.h:81
@ Place
An icon that represents a location (e.g. 'home', 'trash').
Definition kiconloader.h:91
@ MimeType
An icon that represents a mime type (or file type).
Definition kiconloader.h:85
@ Action
An action icon (e.g. 'save', 'print').
Definition kiconloader.h:82
@ International
An icon that represents a country's flag.
Definition kiconloader.h:90
@ Animation
An icon that is animated.
Definition kiconloader.h:86
@ Device
An icon that represents a device.
Definition kiconloader.h:84
Type
The type of the icon.
Definition kiconloader.h:99
@ Fixed
Fixed-size icon.
@ Scalable
Scalable-size icon.
@ Threshold
A threshold icon.
MatchType
The type of a match.
@ MatchBest
Take the best match if there is no exact match.
@ MatchExact
Only try to find an exact match.
@ MatchBestOrGreaterSize
Take the best match or the match with a greater size if there is no exact match.
Q_ENUM(...)
Q_SLOTSQ_SLOTS
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Jul 26 2024 11:54:56 by doxygen 1.11.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.