KIconThemes

kiconengine.h
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 * This is mostly used to provide Qt's icon loading in plasma-integration
25 *
26 * Application developers should use QIcon::fromTheme instead of using it directly.
27 */
28class KICONTHEMES_EXPORT KIconEngine : public QIconEngine // exported for plasma-integration
29{
30public:
31 /**
32 * Constructs an icon engine for a named icon.
33 *
34 * @param iconName the name of the icon to load
35 * @param iconLoader The icon loader that this engine is to use.
36 * @param overlays Add one or more overlays to the icon. See KIconLoader::Overlays.
37 *
38 * @sa KIconLoader
39 */
40 KIconEngine(const QString &iconName, KIconLoader *iconLoader, const QStringList &overlays);
41
42 /**
43 * \overload
44 */
45 KIconEngine(const QString &iconName, KIconLoader *iconLoader);
46
47 /**
48 * Constructs an icon engine for a KDE named icon with a specific palette.
49 *
50 * @param iconName the name of the icon to load
51 * @param colors defines the colors we want to be applied on this icon
52 * @param iconLoader The KDE icon loader that this engine is to use.
53 */
54 KIconEngine(const QString &iconName, const KIconColors &colors, KIconLoader *iconLoader);
55
56 /**
57 * Constructs an icon engine for a KDE named icon with a specific palette and overlays.
58 *
59 * @param iconName the name of the icon to load
60 * @param colors defines the colors we want to be applied on this icon
61 * @param iconLoader The KDE icon loader that this engine is to use.
62 * @param overlays Add one or more overlays to the icon. See KIconLoader::Overlays.
63 *
64 * @since 6.1
65 */
66 KIconEngine(const QString &iconName, const KIconColors &colors, KIconLoader *iconLoader, const QStringList &overlays);
67
68 /**
69 * Destructor.
70 */
71 ~KIconEngine() override;
72
73 /// Reimplementation
74 QSize actualSize(const QSize &size, QIcon::Mode mode, QIcon::State state) override;
75 /// Reimplementation
76 void paint(QPainter *painter, const QRect &rect, QIcon::Mode mode, QIcon::State state) override;
77 /// Reimplementation
78 QPixmap pixmap(const QSize &size, QIcon::Mode mode, QIcon::State state) override;
79 QPixmap scaledPixmap(const QSize &size, QIcon::Mode mode, QIcon::State state, qreal scale) override;
80
81 /// Reimplementation
82 QString iconName() override;
83 /// Reimplementation
85
86 bool isNull() override;
87
88 QString key() const override;
89 QIconEngine *clone() const override;
90 bool read(QDataStream &in) override;
91 bool write(QDataStream &out) const override;
92
93private:
94 // TODO KF6: move those into the d-pointer
95 QPixmap createPixmap(const QSize &size, qreal scale, QIcon::Mode mode, QIcon::State state);
96 QString mIconName;
97 QStringList mOverlays;
98 KIconEnginePrivate *const d;
99};
100
101#endif
Sepecifies which colors will be used when recoloring icons as its stylesheet.
Definition kiconcolors.h:31
A class to provide rendering of KDE icons.
Definition kiconengine.h:29
QList< QSize > availableSizes(QIcon::Mode mode, QIcon::State state) override
Reimplementation.
Iconloader for KDE.
Definition kiconloader.h:73
virtual QSize actualSize(const QSize &size, QIcon::Mode mode, QIcon::State state)
virtual QIconEngine * clone() const const=0
virtual QString iconName()
virtual bool isNull()
virtual QString key() const const
virtual void paint(QPainter *painter, const QRect &rect, QIcon::Mode mode, QIcon::State state)=0
virtual QPixmap pixmap(const QSize &size, QIcon::Mode mode, QIcon::State state)
virtual bool read(QDataStream &in)
virtual QPixmap scaledPixmap(const QSize &size, QIcon::Mode mode, QIcon::State state, qreal scale)
virtual bool write(QDataStream &out) const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Dec 21 2024 16:57:01 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.