1/* vi: ts=8 sts=4 sw=4
2
3 This file is part of the KDE project, module kdecore.
4 SPDX-FileCopyrightText: 2000 Geert Jansen <jansen@kde.org>
5 SPDX-FileCopyrightText: 2000 Antonio Larrosa <larrosa@kde.org>
6
7 SPDX-License-Identifier: LGPL-2.0-only
8*/
9
10#ifndef KICONCOLORS_H
11#define KICONCOLORS_H
12
13#include "kiconloader.h"
14#include <QPalette>
15#include <QSharedDataPointer>
16
17class KIconColorsPrivate;
18
19/**
20 * @class KIconColors
21 *
22 * Sepecifies which colors will be used when recoloring icons as its stylesheet.
23 *
24 * KIconLoader supports re-coloring svg icons based on a set of colors. This
25 * class will define them.
26 *
27 * @see KIconEngine
28 * @see KDE::icon
29 */
30class KICONTHEMES_EXPORT KIconColors
31{
32public:
33 /**
34 * Will fill the colors based on the default QPalette() constructor.
35 */
36 KIconColors();
37
38 /**
39 * Makes all the color property be @p colors
40 */
41 explicit KIconColors(const QColor &colors);
42
43 /**
44 * Uses @palette to define text, highlight, highlightedText and background.
45 * The rest being positiveText, negativeText and neutralText are filled from
46 * KColorScheme(QPalette::Active, KColorScheme::Window);
47 */
48 explicit KIconColors(const QPalette &palette);
49
50 KIconColors(const KIconColors &other);
51 ~KIconColors();
52 KIconColors operator=(const KIconColors &other);
53
54 QColor text() const;
55 QColor highlight() const;
56 QColor highlightedText() const;
57 QColor background() const;
58 QColor neutralText() const;
59 QColor positiveText() const;
60 QColor negativeText() const;
61 QColor activeText() const;
62
63 void setText(const QColor &color);
64 void setHighlight(const QColor &color);
65 void setHighlightedText(const QColor &color);
66 void setBackground(const QColor &color);
67 void setNeutralText(const QColor &color);
68 void setPositiveText(const QColor &color);
69 void setNegativeText(const QColor &color);
70 void setActiveText(const QColor& color);
71
72protected:
73 /**
74 * @returns a CSS stylesheet to be used SVG icon files.
75 * @param state defines the state we are rendering the stylesheet for
76 *
77 * Specifies: .ColorScheme-Text, .ColorScheme-Background, .ColorScheme-Highlight,
78 * .ColorScheme-HighlightedText, .ColorScheme-PositiveText, .ColorScheme-NeutralText
79 * .ColorScheme-NegativeText, .ColorScheme-ActiveText, .ColorScheme-Complement,
80 * .ColorScheme-Contrast
81 */
82 QString stylesheet(KIconLoader::States state) const;
83
84private:
85 Q_DECLARE_PRIVATE(KIconColors)
86 friend class KIconLoaderPrivate;
87
88 QExplicitlySharedDataPointer<KIconColorsPrivate> d_ptr;
89};
90
91#endif
92

source code of kiconthemes/src/kiconcolors.h