File indexing completed on 2024-04-28 07:43:14

0001 /* vi: ts=8 sts=4 sw=4
0002 
0003     This file is part of the KDE project, module kdecore.
0004     SPDX-FileCopyrightText: 2000 Geert Jansen <jansen@kde.org>
0005     SPDX-FileCopyrightText: 2000 Antonio Larrosa <larrosa@kde.org>
0006 
0007     SPDX-License-Identifier: LGPL-2.0-only
0008 */
0009 
0010 #ifndef KICONLOADER_H
0011 #define KICONLOADER_H
0012 
0013 #include <QObject>
0014 #include <QSize>
0015 #include <QString>
0016 #include <QStringList>
0017 #include <memory>
0018 
0019 #if __has_include(<optional>) && __cplusplus >= 201703L
0020 #include <optional>
0021 #endif
0022 
0023 #include <kiconthemes_export.h>
0024 
0025 class QIcon;
0026 class QMovie;
0027 class QPixmap;
0028 
0029 class KIconColors;
0030 class KIconLoaderPrivate;
0031 class KIconEffect;
0032 class KIconTheme;
0033 
0034 /**
0035  * @class KIconLoader kiconloader.h KIconLoader
0036  *
0037  * Iconloader for KDE.
0038  *
0039  * KIconLoader will load the current icon theme and all its base themes.
0040  * Icons will be searched in any of these themes. Additionally, it caches
0041  * icons and applies effects according to the user's preferences.
0042  *
0043  * In KDE, it is encouraged to load icons by "Group". An icon group is a
0044  * location on the screen where icons are being used. Standard groups are:
0045  * Desktop, Toolbar, MainToolbar, Small and Panel. Each group can have some
0046  * centrally-configured effects applied to its icons. This makes it possible
0047  * to offer a consistent icon look in all KDE applications.
0048  *
0049  * The standard groups are defined below.
0050  *
0051  * @li KIconLoader::Desktop: Icons in the iconview of konqueror, kdesktop and similar apps.
0052  * @li KIconLoader::Toolbar: Icons in toolbars.
0053  * @li KIconLoader::MainToolbar: Icons in the main toolbars.
0054  * @li KIconLoader::Small: Various small (typical 16x16) places: titlebars, listviews
0055  * and menu entries.
0056  * @li KIconLoader::Panel: Icons in kicker's panel
0057  *
0058  * The icons are stored on disk in an icon theme or in a standalone
0059  * directory. The icon theme directories contain multiple sizes and/or
0060  * depths for the same icon. The iconloader will load the correct one based
0061  * on the icon group and the current theme. Icon themes are stored globally
0062  * in share/icons, or, application specific in share/apps/$appdir/icons.
0063  *
0064  * The standalone directories contain just one version of an icon. The
0065  * directories that are searched are: $appdir/pics and $appdir/toolbar.
0066  * Icons in these directories can be loaded by using the special group
0067  * "User".
0068  *
0069  */
0070 class KICONTHEMES_EXPORT KIconLoader : public QObject
0071 {
0072     Q_OBJECT
0073 
0074 public:
0075     /**
0076      * Defines the context of the icon.
0077      */
0078     enum Context {
0079         Any, ///< Some icon with unknown purpose.
0080         Action, ///< An action icon (e.g. 'save', 'print').
0081         Application, ///< An icon that represents an application.
0082         Device, ///< An icon that represents a device.
0083         MimeType, ///< An icon that represents a mime type (or file type).
0084         Animation, ///< An icon that is animated.
0085         Category, ///< An icon that represents a category.
0086         Emblem, ///< An icon that adds information to an existing icon.
0087         Emote, ///< An icon that expresses an emotion.
0088         International, ///< An icon that represents a country's flag.
0089         Place, ///< An icon that represents a location (e.g. 'home', 'trash').
0090         StatusIcon, ///< An icon that represents an event.
0091     };
0092     Q_ENUM(Context)
0093 
0094     /**
0095      * The type of the icon.
0096      */
0097     enum Type {
0098         Fixed, ///< Fixed-size icon.
0099         Scalable, ///< Scalable-size icon.
0100         Threshold, ///< A threshold icon.
0101     };
0102     Q_ENUM(Type)
0103 
0104     /**
0105      * The type of a match.
0106      */
0107     enum MatchType {
0108         MatchExact, ///< Only try to find an exact match.
0109         MatchBest, ///< Take the best match if there is no exact match.
0110         MatchBestOrGreaterSize, ///< Take the best match or the match with a greater size if there is no exact match. @since 6.0
0111     };
0112     Q_ENUM(MatchType)
0113 
0114     /**
0115      * The group of the icon.
0116      */
0117     enum Group {
0118         /// No group
0119         NoGroup = -1,
0120         /// Desktop icons
0121         Desktop = 0,
0122         /// First group
0123         FirstGroup = 0,
0124         /// Toolbar icons
0125         Toolbar,
0126         /// Main toolbar icons
0127         MainToolbar,
0128         /// Small icons, e.g. for buttons
0129         Small,
0130         /// Panel (Plasma Taskbar) icons
0131         // TODO KF6: remove this (See https://phabricator.kde.org/T14340)
0132         Panel,
0133         /// Icons for use in dialog titles, page lists, etc
0134         Dialog,
0135         /// Last group
0136         LastGroup,
0137         /// User icons
0138         User,
0139     };
0140     Q_ENUM(Group)
0141 
0142     /**
0143      * These are the standard sizes for icons.
0144      */
0145     enum StdSizes {
0146         /// small icons for menu entries
0147         SizeSmall = 16,
0148         /// slightly larger small icons for toolbars, panels, etc
0149         SizeSmallMedium = 22,
0150         /// medium sized icons for the desktop
0151         SizeMedium = 32,
0152         /// large sized icons for the panel
0153         SizeLarge = 48,
0154         /// huge sized icons for iconviews
0155         SizeHuge = 64,
0156         /// enormous sized icons for iconviews
0157         SizeEnormous = 128,
0158     };
0159     Q_ENUM(StdSizes)
0160 
0161     /**
0162      * Defines the possible states of an icon.
0163      */
0164     enum States {
0165         DefaultState, ///< The default state.
0166         ActiveState, ///< Icon is active.
0167         DisabledState, ///< Icon is disabled.
0168         SelectedState, ///< Icon is selected. @since 5.22
0169         LastState, ///< Last state (last constant)
0170     };
0171     Q_ENUM(States)
0172 
0173     /**
0174      * Constructs an iconloader.
0175      * @param appname Add the data directories of this application to the
0176      * icon search path for the "User" group. The default argument adds the
0177      * directories of the current application.
0178      * @param extraSearchPaths additional search paths, either absolute or relative to GenericDataLocation
0179      *
0180      * Usually, you use the default iconloader, which can be accessed via
0181      * KIconLoader::global(), so you hardly ever have to create an
0182      * iconloader object yourself. That one is the application's iconloader.
0183      */
0184     explicit KIconLoader(const QString &appname = QString(), const QStringList &extraSearchPaths = QStringList(), QObject *parent = nullptr);
0185 
0186     /**
0187      * Cleanup
0188      */
0189     ~KIconLoader() override;
0190 
0191     /**
0192      * Returns the global icon loader initialized with the application name.
0193      * @return global icon loader
0194      */
0195     static KIconLoader *global();
0196 
0197     /**
0198      * Adds @p appname to the list of application specific directories with @p themeBaseDir as its base directory.
0199      * Assume the icons are in /home/user/app/icons/hicolor/48x48/my_app.png, the base directory would be
0200      * /home/user/app/icons; KIconLoader automatically searches @p themeBaseDir + "/hicolor"
0201      * This directory must contain a dir structure as defined by the XDG icons specification
0202      * @param appname The application name.
0203      * @param themeBaseDir The base directory of the application's theme (eg. "/home/user/app/icons")
0204      */
0205     void addAppDir(const QString &appname, const QString &themeBaseDir = QString());
0206 
0207     /**
0208      * Loads an icon. It will try very hard to find an icon which is
0209      * suitable. If no exact match is found, a close match is searched.
0210      * If neither an exact nor a close match is found, a null pixmap or
0211      * the "unknown" pixmap is returned, depending on the value of the
0212      * @p canReturnNull parameter.
0213      *
0214      * @param name The name of the icon, without extension.
0215      * @param group The icon group. This will specify the size of and effects to
0216      * be applied to the icon.
0217      * @param size If nonzero, this overrides the size specified by @p group.
0218      *             See KIconLoader::StdSizes.
0219      * @param state The icon state: @p DefaultState, @p ActiveState or
0220      * @p DisabledState. Depending on the user's preferences, the iconloader
0221      * may apply a visual effect to hint about its state.
0222      * @param overlays a list of emblem icons to overlay, by name
0223      *                 @see drawOverlays
0224      * @param path_store If not null, the path of the icon is stored here,
0225      *        if the icon was found. If the icon was not found @p path_store
0226      *        is unaltered even if the "unknown" pixmap was returned.
0227      * @param canReturnNull Can return a null pixmap? If false, the
0228      *        "unknown" pixmap is returned when no appropriate icon has been
0229      *        found. <em>Note:</em> a null pixmap can still be returned in the
0230      *        event of invalid parameters, such as empty names, negative sizes,
0231      *        and etc.
0232      * @return the QPixmap. Can be null when not found, depending on
0233      *         @p canReturnNull.
0234      */
0235     QPixmap loadIcon(const QString &name,
0236                      KIconLoader::Group group,
0237                      int size = 0,
0238                      int state = KIconLoader::DefaultState,
0239                      const QStringList &overlays = QStringList(),
0240                      QString *path_store = nullptr,
0241                      bool canReturnNull = false) const;
0242 
0243     /**
0244      * Loads an icon. It will try very hard to find an icon which is
0245      * suitable. If no exact match is found, a close match is searched.
0246      * If neither an exact nor a close match is found, a null pixmap or
0247      * the "unknown" pixmap is returned, depending on the value of the
0248      * @p canReturnNull parameter.
0249      *
0250      * @param name The name of the icon, without extension.
0251      * @param group The icon group. This will specify the size of and effects to
0252      * be applied to the icon.
0253      * @param scale The scale of the icon group to use. If no icon exists in the
0254      * scaled group, a 1x icon with its size multiplied by the scale will be
0255      * loaded instead.
0256      * @param size If nonzero, this overrides the size specified by @p group.
0257      *             See KIconLoader::StdSizes.
0258      * @param state The icon state: @p DefaultState, @p ActiveState or
0259      * @p DisabledState. Depending on the user's preferences, the iconloader
0260      * may apply a visual effect to hint about its state.
0261      * @param overlays a list of emblem icons to overlay, by name
0262      *                 @see drawOverlays
0263      * @param path_store If not null, the path of the icon is stored here,
0264      *        if the icon was found. If the icon was not found @p path_store
0265      *        is unaltered even if the "unknown" pixmap was returned.
0266      * @param canReturnNull Can return a null pixmap? If false, the
0267      *        "unknown" pixmap is returned when no appropriate icon has been
0268      *        found. <em>Note:</em> a null pixmap can still be returned in the
0269      *        event of invalid parameters, such as empty names, negative sizes,
0270      *        and etc.
0271      * @return the QPixmap. Can be null when not found, depending on
0272      *         @p canReturnNull.
0273      * @since 5.48
0274      */
0275     // TODO KF6 merge loadIcon() and loadScaledIcon()
0276     QPixmap loadScaledIcon(const QString &name,
0277                            KIconLoader::Group group,
0278                            qreal scale,
0279                            int size = 0,
0280                            int state = KIconLoader::DefaultState,
0281                            const QStringList &overlays = QStringList(),
0282                            QString *path_store = nullptr,
0283                            bool canReturnNull = false) const;
0284 
0285     /**
0286      * Loads an icon. It will try very hard to find an icon which is
0287      * suitable. If no exact match is found, a close match is searched.
0288      * If neither an exact nor a close match is found, a null pixmap or
0289      * the "unknown" pixmap is returned, depending on the value of the
0290      * @p canReturnNull parameter.
0291      *
0292      * @param name The name of the icon, without extension.
0293      * @param group The icon group. This will specify the size of and effects to
0294      * be applied to the icon.
0295      * @param scale The scale of the icon group to use. If no icon exists in the
0296      * scaled group, a 1x icon with its size multiplied by the scale will be
0297      * loaded instead.
0298      * @param size If nonzero, this overrides the size specified by @p group.
0299      *             See KIconLoader::StdSizes. The icon will be fit into @p size
0300      *             without changing the aspect ratio, which particularly matters
0301      *             for non-square icons.
0302      * @param state The icon state: @p DefaultState, @p ActiveState or
0303      * @p DisabledState. Depending on the user's preferences, the iconloader
0304      * may apply a visual effect to hint about its state.
0305      * @param overlays a list of emblem icons to overlay, by name
0306      *                 @see drawOverlays
0307      * @param path_store If not null, the path of the icon is stored here,
0308      *        if the icon was found. If the icon was not found @p path_store
0309      *        is unaltered even if the "unknown" pixmap was returned.
0310      * @param canReturnNull Can return a null pixmap? If false, the
0311      *        "unknown" pixmap is returned when no appropriate icon has been
0312      *        found. <em>Note:</em> a null pixmap can still be returned in the
0313      *        event of invalid parameters, such as empty names, negative sizes,
0314      *        and etc.
0315      * @return the QPixmap. Can be null when not found, depending on
0316      *         @p canReturnNull.
0317      * @since 5.81
0318      */
0319     QPixmap loadScaledIcon(const QString &name,
0320                            KIconLoader::Group group,
0321                            qreal scale,
0322                            const QSize &size = {},
0323                            int state = KIconLoader::DefaultState,
0324                            const QStringList &overlays = QStringList(),
0325                            QString *path_store = nullptr,
0326                            bool canReturnNull = false) const;
0327 
0328 #if __has_include(<optional>) && __cplusplus >= 201703L
0329     /**
0330      * Loads an icon. It will try very hard to find an icon which is
0331      * suitable. If no exact match is found, a close match is searched.
0332      * If neither an exact nor a close match is found, a null pixmap or
0333      * the "unknown" pixmap is returned, depending on the value of the
0334      * @p canReturnNull parameter.
0335      *
0336      * @param name The name of the icon, without extension.
0337      * @param group The icon group. This will specify the size of and effects to
0338      * be applied to the icon.
0339      * @param scale The scale of the icon group to use. If no icon exists in the
0340      * scaled group, a 1x icon with its size multiplied by the scale will be
0341      * loaded instead.
0342      * @param size If nonzero, this overrides the size specified by @p group.
0343      *             See KIconLoader::StdSizes. The icon will be fit into @p size
0344      *             without changing the aspect ratio, which particularly matters
0345      *             for non-square icons.
0346      * @param state The icon state: @p DefaultState, @p ActiveState or
0347      * @p DisabledState. Depending on the user's preferences, the iconloader
0348      * may apply a visual effect to hint about its state.
0349      * @param overlays a list of emblem icons to overlay, by name
0350      *                 @see drawOverlays
0351      * @param path_store If not null, the path of the icon is stored here,
0352      *        if the icon was found. If the icon was not found @p path_store
0353      *        is unaltered even if the "unknown" pixmap was returned.
0354      * @param canReturnNull Can return a null pixmap? If false, the
0355      *        "unknown" pixmap is returned when no appropriate icon has been
0356      *        found. <em>Note:</em> a null pixmap can still be returned in the
0357      *        event of invalid parameters, such as empty names, negative sizes,
0358      *        and etc.
0359      * @param colorScheme will define the stylesheet used to color this icon.
0360      *        Note this will only work if @p name is an svg file.
0361      * @return the QPixmap. Can be null when not found, depending on
0362      *         @p canReturnNull.
0363      * @since 5.88
0364      */
0365     QPixmap loadScaledIcon(const QString &name,
0366                            KIconLoader::Group group,
0367                            qreal scale,
0368                            const QSize &size,
0369                            int state,
0370                            const QStringList &overlays,
0371                            QString *path_store,
0372                            bool canReturnNull,
0373                            const std::optional<KIconColors> &colorScheme) const;
0374 #endif
0375 
0376     /**
0377      * Loads an icon for a mimetype.
0378      * This is basically like loadIcon except that extra desktop themes are loaded if necessary.
0379      *
0380      * Consider using QIcon::fromTheme() with a fallback to "application-octet-stream" instead.
0381      *
0382      * @param iconName The name of the icon, without extension, usually from KMimeType.
0383      * @param group The icon group. This will specify the size of and effects to
0384      * be applied to the icon.
0385      * @param size If nonzero, this overrides the size specified by @p group.
0386      *             See KIconLoader::StdSizes.
0387      * @param state The icon state: @p DefaultState, @p ActiveState or
0388      * @p DisabledState. Depending on the user's preferences, the iconloader
0389      * may apply a visual effect to hint about its state.
0390      * @param path_store If not null, the path of the icon is stored here.
0391      * @param overlays a list of emblem icons to overlay, by name
0392      *                 @see drawOverlays
0393      * @return the QPixmap. Can not be null, the
0394      * "unknown" pixmap is returned when no appropriate icon has been found.
0395      */
0396     QPixmap loadMimeTypeIcon(const QString &iconName,
0397                              KIconLoader::Group group,
0398                              int size = 0,
0399                              int state = KIconLoader::DefaultState,
0400                              const QStringList &overlays = QStringList(),
0401                              QString *path_store = nullptr) const;
0402 
0403     /**
0404      * Returns the path of an icon.
0405      * @param name The name of the icon, without extension. If an absolute
0406      * path is supplied for this parameter, iconPath will return it
0407      * directly.
0408      * @param group_or_size If positive, search icons whose size is
0409      * specified by the icon group @p group_or_size. If negative, search
0410      * icons whose size is - @p group_or_size.
0411      *             See KIconLoader::Group and KIconLoader::StdSizes
0412      * @param canReturnNull Can return a null string? If not, a path to the
0413      *                      "unknown" icon will be returned.
0414      * @return the path of an icon, can be null or the "unknown" icon when
0415      *         not found, depending on @p canReturnNull.
0416      */
0417     QString iconPath(const QString &name, int group_or_size, bool canReturnNull = false) const;
0418 
0419     /**
0420      * Returns the path of an icon.
0421      * @param name The name of the icon, without extension. If an absolute
0422      * path is supplied for this parameter, iconPath will return it
0423      * directly.
0424      * @param group_or_size If positive, search icons whose size is
0425      * specified by the icon group @p group_or_size. If negative, search
0426      * icons whose size is - @p group_or_size.
0427      *             See KIconLoader::Group and KIconLoader::StdSizes
0428      * @param canReturnNull Can return a null string? If not, a path to the
0429      *                      "unknown" icon will be returned.
0430      * @param scale The scale of the icon group.
0431      * @return the path of an icon, can be null or the "unknown" icon when
0432      *         not found, depending on @p canReturnNull.
0433      * @since 5.48
0434      */
0435     // TODO KF6 merge iconPath() with and without "scale" and move that argument after "group_or_size"
0436     QString iconPath(const QString &name, int group_or_size, bool canReturnNull, qreal scale) const;
0437 
0438     /**
0439      * Loads an animated icon.
0440      * @param name The name of the icon.
0441      * @param group The icon group. See loadIcon().
0442      * @param size Override the default size for @p group.
0443      *             See KIconLoader::StdSizes.
0444      * @param parent The parent object of the returned QMovie.
0445      * @return A QMovie object. Can be null if not found or not valid.
0446      *         Ownership is passed to the caller.
0447      */
0448     QMovie *loadMovie(const QString &name, KIconLoader::Group group, int size = 0, QObject *parent = nullptr) const;
0449 
0450     /**
0451      * Returns the path to an animated icon.
0452      * @param name The name of the icon.
0453      * @param group The icon group. See loadIcon().
0454      * @param size Override the default size for @p group.
0455      *             See KIconLoader::StdSizes.
0456      * @return the full path to the movie, ready to be passed to QMovie's constructor.
0457      * Empty string if not found.
0458      */
0459     QString moviePath(const QString &name, KIconLoader::Group group, int size = 0) const;
0460 
0461     /**
0462      * Loads an animated icon as a series of still frames. If you want to load
0463      * a .mng animation as QMovie instead, please use loadMovie() instead.
0464      * @param name The name of the icon.
0465      * @param group The icon group. See loadIcon().
0466      * @param size Override the default size for @p group.
0467      *             See KIconLoader::StdSizes.
0468      * @return A QStringList containing the absolute path of all the frames
0469      * making up the animation.
0470      */
0471     QStringList loadAnimated(const QString &name, KIconLoader::Group group, int size = 0) const;
0472 
0473     /**
0474      * Queries all available icons for a specific group, having a specific
0475      * context.
0476      * @param group_or_size If positive, search icons whose size is
0477      * specified by the icon group @p group_or_size. If negative, search
0478      * icons whose size is - @p group_or_size.
0479      *             See KIconLoader::Group and KIconLoader::StdSizes
0480      * @param context The icon context.
0481      * @return a list of all icons
0482      */
0483     QStringList queryIcons(int group_or_size, KIconLoader::Context context = KIconLoader::Any) const;
0484 
0485     /**
0486      * Queries all available icons for a specific context.
0487      * @param group_or_size The icon preferred group or size. If available
0488      * at this group or size, those icons will be returned, in other case,
0489      * icons of undefined size will be returned. Positive numbers are groups,
0490      * negative numbers are negated sizes. See KIconLoader::Group and
0491      * KIconLoader::StdSizes
0492      * @param context The icon context.
0493      * @return A QStringList containing the icon names
0494      * available for that context
0495      */
0496     QStringList queryIconsByContext(int group_or_size, KIconLoader::Context context = KIconLoader::Any) const;
0497 
0498     /**
0499      * @internal
0500      */
0501     bool hasContext(KIconLoader::Context context) const;
0502 
0503     /**
0504      * Returns a list of all icons (*.png or *.xpm extension) in the
0505      * given directory.
0506      * @param iconsDir the directory to search in
0507      * @return A QStringList containing the icon paths
0508      */
0509     QStringList queryIconsByDir(const QString &iconsDir) const;
0510 
0511     /**
0512      * Returns all the search paths for this icon loader, either absolute or
0513      * relative to GenericDataLocation.
0514      * Mostly internal (for KIconDialog).
0515      * \since 5.0
0516      */
0517     QStringList searchPaths() const;
0518 
0519     /**
0520      * Returns the size of the specified icon group.
0521      * Using e.g. KIconLoader::SmallIcon will return 16.
0522      * @param group the group to check.
0523      * @return the current size for an icon group.
0524      */
0525     int currentSize(KIconLoader::Group group) const;
0526 
0527     /**
0528      * Returns a pointer to the current theme. Can be used to query
0529      * available and default sizes for groups.
0530      * @note The KIconTheme will change if reconfigure() is called and
0531      * therefore it's not recommended to store the pointer anywhere.
0532      * @return a pointer to the current theme. 0 if no theme set.
0533      */
0534     KIconTheme *theme() const;
0535 
0536     /**
0537      * Returns a pointer to the KIconEffect object used by the icon loader.
0538      * @return the KIconEffect.
0539      */
0540     KIconEffect *iconEffect() const;
0541 
0542     /**
0543      * Reconfigure the icon loader, for instance to change the associated app name or extra search paths.
0544      * This also clears the in-memory pixmap cache (even if the appname didn't change, which is useful for unittests)
0545      * @param appname the application name (empty for the global iconloader)
0546      * @param extraSearchPaths additional search paths, either absolute or relative to GenericDataLocation
0547      */
0548     void reconfigure(const QString &appname, const QStringList &extraSearchPaths = QStringList());
0549 
0550     /**
0551      * Returns the unknown icon. An icon that is used when no other icon
0552      * can be found.
0553      * @return the unknown pixmap
0554      */
0555     static QPixmap unknown();
0556 
0557     /**
0558      * Draws overlays on the specified pixmap, it takes the width and height
0559      * of the pixmap into consideration
0560      * @param overlays List of up to 4 overlays to blend over the pixmap. The first overlay
0561      *                 will be in the bottom right corner, followed by bottom left, top left
0562      *                 and top right. An empty QString can be used to leave the specific position
0563      *                 blank.
0564      * @param pixmap to draw on
0565      * @since 4.7
0566      */
0567     void drawOverlays(const QStringList &overlays, QPixmap &pixmap, KIconLoader::Group group, int state = KIconLoader::DefaultState) const;
0568 
0569     bool hasIcon(const QString &iconName) const;
0570 
0571     /**
0572      * Sets the colors for this KIconLoader.
0573      * NOTE: if you set a custom palette, if you are using some colors from
0574      * application's palette, you need to track the application palette changes by yourself.
0575      * If you no longer wish to use a custom palette, use resetPalette()
0576      * @see resetPalette
0577      * @since 5.39
0578      */
0579     void setCustomPalette(const QPalette &palette);
0580 
0581     /**
0582      * The colors that will be used for the svg stylesheet in case the
0583      * loaded icons are svg-based, icons can be colored in different ways in
0584      * different areas of the application
0585      * @return the palette, if any, an invalid one if the user didn't set it
0586      * @since 5.39
0587      */
0588     QPalette customPalette() const;
0589 
0590     /**
0591      * Resets the custom palette used by the KIconLoader to use the
0592      * QGuiApplication::palette() again (and to follow it in case the
0593      * application's palette changes)
0594      * @since 5.39
0595      */
0596     void resetPalette();
0597 
0598     /**
0599      * @returns whether we have set a custom palette using @f setCustomPalette
0600      *
0601      * @since 5.85
0602      * @see resetPalette, setCustomPalette
0603      */
0604     bool hasCustomPalette() const;
0605 
0606 public Q_SLOTS:
0607     // TODO: while marked as deprecated, newIconLoader() is still used:
0608     // internally by KIconLoadeer as well as by Plasma's Icons kcm module (state: 5.17)
0609     // this needs some further cleanup work before removing it from the API with KICONTHEMES_ENABLE_DEPRECATED_SINCE
0610     /**
0611      * Re-initialize the global icon loader
0612      *
0613      * @todo Check deprecation, still used internally.
0614      * @deprecated Since 5.0, use emitChange(Group)
0615      */
0616     KICONTHEMES_DEPRECATED_VERSION(5, 0, "Use KIconLoader::emitChange(Group)") // TODO KF6 remove
0617     void newIconLoader();
0618 
0619     /**
0620      * Emits an iconChanged() signal on all the KIconLoader instances in the system
0621      * indicating that a system's icon group has changed in some way. It will also trigger
0622      * a reload in all of them to update to the new theme.
0623      *
0624      * @p group indicates the group that has changed
0625      *
0626      * @since 5.0
0627      */
0628     static void emitChange(Group group);
0629 
0630 Q_SIGNALS:
0631     /**
0632      * Emitted by newIconLoader once the new settings have been loaded
0633      */
0634     void iconLoaderSettingsChanged();
0635 
0636     /**
0637      * Emitted when the system icon theme changes
0638      *
0639      * @since 5.0
0640      */
0641     void iconChanged(int group);
0642 
0643 private:
0644     friend class KIconLoaderPrivate;
0645     // @internal the data object
0646     std::unique_ptr<KIconLoaderPrivate> const d;
0647 
0648     Q_PRIVATE_SLOT(d, void _k_refreshIcons(int group))
0649 };
0650 
0651 namespace KDE
0652 {
0653 /**
0654  * \relates KIconLoader
0655  * Returns a QIcon with an appropriate
0656  * KIconEngine to perform loading and rendering.  KIcons thus adhere to
0657  * KDE style and effect standards.
0658  * @since 5.0
0659  */
0660 KICONTHEMES_EXPORT QIcon icon(const QString &iconName, KIconLoader *iconLoader = nullptr);
0661 KICONTHEMES_EXPORT QIcon icon(const QString &iconName, const KIconColors &colors, KIconLoader *iconLoader = nullptr);
0662 
0663 /**
0664  * \relates KIconLoader
0665  * Returns a QIcon for the given icon, with additional overlays.
0666  * @since 5.0
0667  */
0668 KICONTHEMES_EXPORT QIcon icon(const QString &iconName, const QStringList &overlays, KIconLoader *iconLoader = nullptr);
0669 
0670 }
0671 
0672 inline KIconLoader::Group &operator++(KIconLoader::Group &group)
0673 {
0674     group = static_cast<KIconLoader::Group>(group + 1);
0675     return group;
0676 }
0677 inline KIconLoader::Group operator++(KIconLoader::Group &group, int)
0678 {
0679     KIconLoader::Group ret = group;
0680     ++group;
0681     return ret;
0682 }
0683 
0684 #endif // KICONLOADER_H