File indexing completed on 2024-04-14 14:23:36

0001 /* vi: ts=8 sts=4 sw=4
0002 
0003     This file is part of the KDE project, module kdecore.
0004     SPDX-FileCopyrightText: 2000 Geert Jansen <jansen@kde.org>
0005     SPDX-FileCopyrightText: 2000 Antonio Larrosa <larrosa@kde.org>
0006 
0007     SPDX-License-Identifier: LGPL-2.0-only
0008 */
0009 
0010 #ifndef KICONCOLORS_H
0011 #define KICONCOLORS_H
0012 
0013 #include "kiconloader.h"
0014 #include <QPalette>
0015 #include <QSharedDataPointer>
0016 
0017 class KIconColorsPrivate;
0018 
0019 /**
0020  * @class KIconColors
0021  *
0022  * Sepecifies which colors will be used when recoloring icons as its stylesheet.
0023  *
0024  * KIconLoader supports re-coloring svg icons based on a set of colors. This
0025  * class will define them.
0026  *
0027  * @see KIconEngine
0028  * @see KDE::icon
0029  */
0030 class KICONTHEMES_EXPORT KIconColors
0031 {
0032 public:
0033     /**
0034      * Will fill the colors based on the default QPalette() constructor.
0035      */
0036     KIconColors();
0037 
0038     /**
0039      * Makes all the color property be @p colors
0040      */
0041     explicit KIconColors(const QColor &colors);
0042 
0043     /**
0044      * Uses @palette to define text, highlight, highlightedText and background.
0045      * The rest being positiveText, negativeText and neutralText are filled from
0046      * KColorScheme(QPalette::Active, KColorScheme::Window);
0047      */
0048     explicit KIconColors(const QPalette &palette);
0049 
0050     KIconColors(const KIconColors &other);
0051     ~KIconColors();
0052     KIconColors operator=(const KIconColors &other);
0053 
0054     QColor text() const;
0055     QColor highlight() const;
0056     QColor highlightedText() const;
0057     QColor background() const;
0058     QColor neutralText() const;
0059     QColor positiveText() const;
0060     QColor negativeText() const;
0061     QColor activeText() const;
0062 
0063     void setText(const QColor &color);
0064     void setHighlight(const QColor &color);
0065     void setHighlightedText(const QColor &color);
0066     void setBackground(const QColor &color);
0067     void setNeutralText(const QColor &color);
0068     void setPositiveText(const QColor &color);
0069     void setNegativeText(const QColor &color);
0070     void setActiveText(const QColor& color);
0071 
0072 protected:
0073     /**
0074      * @returns a CSS stylesheet to be used SVG icon files.
0075      * @param state defines the state we are rendering the stylesheet for
0076      *
0077      * Specifies: .ColorScheme-Text, .ColorScheme-Background, .ColorScheme-Highlight,
0078      * .ColorScheme-HighlightedText, .ColorScheme-PositiveText, .ColorScheme-NeutralText
0079      * .ColorScheme-NegativeText, .ColorScheme-ActiveText, .ColorScheme-Complement,
0080      * .ColorScheme-Contrast
0081      */
0082     QString stylesheet(KIconLoader::States state) const;
0083 
0084 private:
0085     Q_DECLARE_PRIVATE(KIconColors)
0086     friend class KIconLoaderPrivate;
0087 
0088     QExplicitlySharedDataPointer<KIconColorsPrivate> d_ptr;
0089 };
0090 
0091 #endif