File indexing completed on 2024-09-29 03:36:24
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, accent 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 accent() const; 0058 QColor background() const; 0059 QColor neutralText() const; 0060 QColor positiveText() const; 0061 QColor negativeText() const; 0062 QColor activeText() const; 0063 0064 void setText(const QColor &color); 0065 void setHighlight(const QColor &color); 0066 void setHighlightedText(const QColor &color); 0067 void setAccent(const QColor &color); 0068 void setBackground(const QColor &color); 0069 void setNeutralText(const QColor &color); 0070 void setPositiveText(const QColor &color); 0071 void setNegativeText(const QColor &color); 0072 void setActiveText(const QColor& color); 0073 0074 protected: 0075 /** 0076 * @returns a CSS stylesheet to be used SVG icon files. 0077 * @param state defines the state we are rendering the stylesheet for 0078 * 0079 * Specifies: .ColorScheme-Text, .ColorScheme-Background, .ColorScheme-Highlight, 0080 * .ColorScheme-HighlightedText, .ColorScheme-PositiveText, .ColorScheme-NeutralText 0081 * .ColorScheme-NegativeText, .ColorScheme-ActiveText, .ColorScheme-Complement, 0082 * .ColorScheme-Contrast, .ColorScheme-Accent, 0083 */ 0084 QString stylesheet(KIconLoader::States state) const; 0085 0086 private: 0087 Q_DECLARE_PRIVATE(KIconColors) 0088 friend class KIconLoaderPrivate; 0089 0090 QExplicitlySharedDataPointer<KIconColorsPrivate> d_ptr; 0091 }; 0092 0093 #endif