GrantleeTheme

color.h
1/*
2 * SPDX-FileCopyrightText: 2019 Volker Krause <vkrause@kde.org>
3 *
4 * SPDX-License-Identifier: LGPL-2.1-or-later
5 */
6
7#pragma once
8#include <KTextTemplate/Filter>
9#include <KTextTemplate/Node>
10#include <QObject>
11
12/**
13 * @name colorHexRgb filter
14 * @brief Provides colorName filter for converting a QColor to a color string.
15 *
16 * The syntax is:
17 * @code
18 * {{ myColor|colorHexRgb }}
19 * @endcode
20 */
21class ColorHexRgbFilter : public KTextTemplate::Filter
22{
23public:
24 QVariant doFilter(const QVariant &input, const QVariant &arg, bool autoescape) const override;
25};
26
27/**
28 * @name colorCssRgba filter
29 * @brief Provides colorRgba filter for converting a QColor to a rgba() CSS color definition.
30 *
31 * The syntax is:
32 * @code
33 * {{ myColor|colorCssRgba }}
34 * @endcode
35 */
36class ColorCssRgbaFilter : public KTextTemplate::Filter
37{
38public:
39 QVariant doFilter(const QVariant &input, const QVariant &arg, bool autoescape) const override;
40};
41
42/**
43 * @name colorLighter filter
44 * @brief Provides colorLighter filter for applying QColor::lighter to a color.
45 *
46 * The syntax is:
47 * @code
48 * {{ myColor|colorLighter:<factor> }}
49 * @endcode
50 */
51class ColorLighterFilter : public KTextTemplate::Filter
52{
53public:
54 QVariant doFilter(const QVariant &input, const QVariant &arg, bool autoescape) const override;
55};
56
57/**
58 * @name colorDarker filter
59 * @brief Provides colorDarker filter for applying QColor::darker to a color.
60 *
61 * The syntax is:
62 * @code
63 * {{ myColor|colorDarker:<factor> }}
64 * @endcode
65 */
66class ColorDarkerFilter : public KTextTemplate::Filter
67{
68public:
69 QVariant doFilter(const QVariant &input, const QVariant &arg, bool autoescape) const override;
70};
71
72/**
73 * @name colorSetAlpha filter
74 * @brief Provides colorSetAlpha filter for setting a fixed alpha value on the given color.
75 *
76 * The syntax is:
77 * @code
78 * {{ myColor|colorSetAlpha:<alpha-value-from-0-to-255> }}
79 * @endcode
80 */
81class ColorSetAlphaFilter : public KTextTemplate::Filter
82{
83public:
84 QVariant doFilter(const QVariant &input, const QVariant &arg, bool autoescape) const override;
85};
86
87/**
88 * @name colorMix tag
89 * @brief Provides {% colorMix %} tag for mixing two colors
90 *
91 * The syntax is:
92 * @code
93 * {% colorMix "#rrggbb"|var-with-color "#rrggbb"|var-with-color <ratio> %}
94 * @endcode
95 *
96 * The tag generates a rgba() CSS color definition.
97 */
98class ColorMixTag : public KTextTemplate::AbstractNodeFactory
99{
101public:
102 explicit ColorMixTag(QObject *parent = nullptr);
103 ~ColorMixTag() override;
104 KTextTemplate::Node *getNode(const QString &tagContent, KTextTemplate::Parser *p) const override;
105};
106
107class ColorMixNode : public KTextTemplate::Node
108{
110public:
111 explicit ColorMixNode(const QString &color1Name, const QString &color2Name, double ratio, const QString &varName, QObject *parent = nullptr);
112 ~ColorMixNode() override;
113 void render(KTextTemplate::OutputStream *stream, KTextTemplate::Context *c) const override;
114
115private:
116 QString m_color1Name;
117 QString m_color2Name;
118 QString m_varName;
119 double m_ratio;
120};
121
122namespace Color
123{
124void registerMetaType();
125}
int registerMetaType()
Q_OBJECTQ_OBJECT
QObject * parent() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 18 2024 12:07:43 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.