1/*
2 This file is part of the KDE libraries
3 SPDX-FileCopyrightText: 2006 Hamish Rodda <rodda@kde.org>
4
5 SPDX-License-Identifier: LGPL-2.0-only
6*/
7
8#ifndef KICONENGINE_H
9#define KICONENGINE_H
10
11#include "kiconthemes_export.h"
12#include <QIconEngine>
13#include <QPointer>
14
15class KIconColors;
16class KIconLoader;
17class KIconEnginePrivate;
18
19/**
20 * @class KIconEngine kiconengine.h KIconEngine
21 *
22 * \short A class to provide rendering of KDE icons.
23 *
24 * Currently, this class is not much more than a wrapper around QIconEngine.
25 * However, it should not be difficult to extend with features such as SVG
26 * rendered icons.
27 *
28 * Icon themes specifying a KDE-Extensions string list setting, will limit
29 * themselves to checking these extensions exclusively, in the order specified
30 * in the setting.
31 *
32 * @author Hamish Rodda <rodda@kde.org>
33 */
34class KICONTHEMES_EXPORT KIconEngine : public QIconEngine // exported for kdelibs4support's KIcon and plasma integration
35{
36public:
37 /**
38 * Constructs an icon engine for a KDE named icon.
39 *
40 * @param iconName the name of the icon to load
41 * @param iconLoader The KDE icon loader that this engine is to use.
42 * @param overlays Add one or more overlays to the icon. See KIconLoader::Overlays.
43 *
44 * @sa KIconLoader
45 */
46 KIconEngine(const QString &iconName, KIconLoader *iconLoader, const QStringList &overlays);
47
48 /**
49 * \overload
50 */
51 KIconEngine(const QString &iconName, KIconLoader *iconLoader);
52
53 /**
54 * Constructs an icon engine for a KDE named icon with a specific palette.
55 *
56 * @param iconName the name of the icon to load
57 * @param colors defines the colors we want to be applied on this icon
58 * @param iconLoader The KDE icon loader that this engine is to use.
59 */
60 KIconEngine(const QString &iconName, const KIconColors &colors, KIconLoader *iconLoader);
61
62 /**
63 * Destructor.
64 */
65 ~KIconEngine() override;
66
67 /// Reimplementation
68 QSize actualSize(const QSize &size, QIcon::Mode mode, QIcon::State state) override;
69 /// Reimplementation
70 void paint(QPainter *painter, const QRect &rect, QIcon::Mode mode, QIcon::State state) override;
71 /// Reimplementation
72 QPixmap pixmap(const QSize &size, QIcon::Mode mode, QIcon::State state) override;
73 QPixmap scaledPixmap(const QSize &size, QIcon::Mode mode, QIcon::State state, qreal scale) override;
74
75 /// Reimplementation
76 QString iconName() override;
77 /// Reimplementation
78 QList<QSize> availableSizes(QIcon::Mode mode, QIcon::State state) override;
79
80 bool isNull() override;
81
82 QString key() const override;
83 QIconEngine *clone() const override;
84 bool read(QDataStream &in) override;
85 bool write(QDataStream &out) const override;
86
87private:
88 // TODO KF6: move those into the d-pointer
89 QPixmap createPixmap(const QSize &size, qreal scale, QIcon::Mode mode, QIcon::State state);
90 QString mIconName;
91 QStringList mOverlays;
92 KIconEnginePrivate *const d;
93};
94
95#endif
96

source code of kiconthemes/src/kiconengine.h