KCalUtils

icon.h
1/*
2 * SPDX-FileCopyrightText: 2015 Daniel Vrátil <dvratil@redhat.com>
3 *
4 * SPDX-License-Identifier: LGPL-2.1-or-later
5 *
6 */
7
8#pragma once
9#include <KTextTemplate/Node>
10#include <QObject>
11
12/**
13 * @name icon tag
14 * @brief Provides {% icon %} tag for inserting themed icons
15 *
16 * The syntax is:
17 * @code
18 * {% icon "icon-name"|var-with-icon-name [ sizeOrGroup ] [ alt text ] %}
19 * @endcode
20 *
21 * Where @p icon-name is a string literal with icon name, @p var-with-icon-name
22 * is a variable that contains a string with the icon name. @p sizeOrGrop is
23 * one of the KIconLoader::Group or KIconLoader::StdSizes enum values. The value
24 * is case-insensitive.
25 *
26 * The tag generates a full <img> HTML code:
27 * @code
28 * <img src="/usr/share/icons/[theme]/[type]/[size]/[icon-name].png" width="[width]" height="[height]">
29 * @endcode
30 *
31 * The full path to the icon is resolved using KIconLoader::iconPath(). The
32 * @p width and @p height attributes are calculated based on current settings
33 * for icon sizes in KDE.
34 *
35 * @note Support for nested variables inside tags is non-standard for Grantlee
36 * tags, but makes it easier to use {% icon %} in sub-templates.
37 */
38class IconTag : public KTextTemplate::AbstractNodeFactory
39{
41public:
42 explicit IconTag(QObject *parent = nullptr);
43 ~IconTag() override;
44 KTextTemplate::Node *getNode(const QString &tagContent, KTextTemplate::Parser *p) const override;
45};
46class IconNode : public KTextTemplate::Node
47{
49public:
50 explicit IconNode(QObject *parent = nullptr);
51 IconNode(const QString &iconName, int sizeOrGroup, const QString &altText, QObject *parent = nullptr);
52 ~IconNode() override;
53 void render(KTextTemplate::OutputStream *stream, KTextTemplate::Context *c) const override;
54
55private:
56 QString mIconName;
57 QString mAltText;
58 int mSizeOrGroup;
59};
Q_OBJECTQ_OBJECT
QObject * parent() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Tue Mar 26 2024 11:20:39 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.