File indexing completed on 2024-12-01 09:52:16
0001 /* 0002 This file is part of the KDE libraries 0003 SPDX-FileCopyrightText: 2006 Hamish Rodda <rodda@kde.org> 0004 0005 SPDX-License-Identifier: LGPL-2.0-only 0006 */ 0007 0008 #ifndef KICONENGINE_H 0009 #define KICONENGINE_H 0010 0011 #include "kiconthemes_export.h" 0012 #include <QIconEngine> 0013 #include <QPointer> 0014 0015 class KIconColors; 0016 class KIconLoader; 0017 class KIconEnginePrivate; 0018 0019 /** 0020 * @class KIconEngine kiconengine.h KIconEngine 0021 * 0022 * \short A class to provide rendering of KDE icons. 0023 * 0024 * Currently, this class is not much more than a wrapper around QIconEngine. 0025 * However, it should not be difficult to extend with features such as SVG 0026 * rendered icons. 0027 * 0028 * Icon themes specifying a KDE-Extensions string list setting, will limit 0029 * themselves to checking these extensions exclusively, in the order specified 0030 * in the setting. 0031 * 0032 * @author Hamish Rodda <rodda@kde.org> 0033 */ 0034 class KICONTHEMES_EXPORT KIconEngine : public QIconEngine // exported for kdelibs4support's KIcon and plasma integration 0035 { 0036 public: 0037 /** 0038 * Constructs an icon engine for a KDE named icon. 0039 * 0040 * @param iconName the name of the icon to load 0041 * @param iconLoader The KDE icon loader that this engine is to use. 0042 * @param overlays Add one or more overlays to the icon. See KIconLoader::Overlays. 0043 * 0044 * @sa KIconLoader 0045 */ 0046 KIconEngine(const QString &iconName, KIconLoader *iconLoader, const QStringList &overlays); 0047 0048 /** 0049 * \overload 0050 */ 0051 KIconEngine(const QString &iconName, KIconLoader *iconLoader); 0052 0053 /** 0054 * Constructs an icon engine for a KDE named icon with a specific palette. 0055 * 0056 * @param iconName the name of the icon to load 0057 * @param colors defines the colors we want to be applied on this icon 0058 * @param iconLoader The KDE icon loader that this engine is to use. 0059 */ 0060 KIconEngine(const QString &iconName, const KIconColors &colors, KIconLoader *iconLoader); 0061 0062 /** 0063 * Destructor. 0064 */ 0065 ~KIconEngine() override; 0066 0067 /// Reimplementation 0068 QSize actualSize(const QSize &size, QIcon::Mode mode, QIcon::State state) override; 0069 /// Reimplementation 0070 void paint(QPainter *painter, const QRect &rect, QIcon::Mode mode, QIcon::State state) override; 0071 /// Reimplementation 0072 QPixmap pixmap(const QSize &size, QIcon::Mode mode, QIcon::State state) override; 0073 0074 /// Reimplementation 0075 QString iconName() const override; 0076 /// Reimplementation 0077 QList<QSize> availableSizes(QIcon::Mode mode, QIcon::State state) const override; 0078 0079 QString key() const override; 0080 QIconEngine *clone() const override; 0081 bool read(QDataStream &in) override; 0082 bool write(QDataStream &out) const override; 0083 0084 void virtual_hook(int id, void *data) override; 0085 0086 private: 0087 // TODO KF6: move those into the d-pointer 0088 QPixmap createPixmap(const QSize &size, qreal scale, QIcon::Mode mode, QIcon::State state); 0089 QString mIconName; 0090 QStringList mOverlays; 0091 KIconEnginePrivate *const d; 0092 }; 0093 0094 #endif