10#include "kiconcolors.h"
11#include <KColorScheme>
13static QString STYLESHEET_TEMPLATE()
16 return QStringLiteral(
".ColorScheme-Text { color:%1; }\
17.ColorScheme-Background{ color:%2; }\
18.ColorScheme-Highlight{ color:%3; }\
19.ColorScheme-HighlightedText{ color:%4; }\
20.ColorScheme-PositiveText{ color:%5; }\
21.ColorScheme-NeutralText{ color:%6; }\
22.ColorScheme-NegativeText{ color:%7; }\
23.ColorScheme-ActiveText{ color:%8; }\
24.ColorScheme-Complement{ color:%9; }\
25.ColorScheme-Contrast{ color:%10; }\
26.ColorScheme-Accent{ color:%11; }\
37 KIconColorsPrivate(
const KIconColorsPrivate &other)
40 , background(other.background)
41 , highlight(other.highlight)
42 , highlightedText(other.highlightedText)
43 , accent(other.accent)
44 , positiveText(other.positiveText)
45 , neutralText(other.neutralText)
46 , negativeText(other.negativeText)
62 static std::optional<QPalette> lastPalette;
63 static std::optional<KColorScheme> lastColorScheme;
66std::optional<QPalette> KIconColorsPrivate::lastPalette;
67std::optional<KColorScheme> KIconColorsPrivate::lastColorScheme;
81 if (d_ptr != other.d_ptr) {
88 : d_ptr(new KIconColorsPrivate)
92 d->background = colors;
93 d->highlight = colors;
94 d->highlightedText = colors;
95 d->positiveText = colors;
96 d->neutralText = colors;
97 d->negativeText = colors;
102 : d_ptr(new KIconColorsPrivate)
111 if (!d->lastColorScheme || !d->lastPalette || palette != d->lastPalette) {
112 d->lastPalette = palette;
122KIconColors::~KIconColors()
127 return (0.299 * color.
red() + 0.587 * color.
green() + 0.114 * color.
blue()) / 255;
140 QColor accentColor = d->accent;
145 const qreal tintRatio = 0.85;
146 const qreal r = accentColor.
redF() * tintRatio + d->highlightedText.redF() * (1.0 - tintRatio);
147 const qreal g = accentColor.
greenF() * tintRatio + d->highlightedText.greenF() * (1.0 - tintRatio);
148 const qreal b = accentColor.
blueF() * tintRatio + d->highlightedText.blueF() * (1.0 - tintRatio);
152 return STYLESHEET_TEMPLATE()
166QColor KIconColors::highlight()
const
172QColor KIconColors::highlightedText()
const
175 return d->highlightedText;
178QColor KIconColors::accent()
const
184QColor KIconColors::background()
const
187 return d->background;
190QColor KIconColors::text()
const
196QColor KIconColors::negativeText()
const
199 return d->negativeText;
202QColor KIconColors::positiveText()
const
205 return d->positiveText;
208QColor KIconColors::neutralText()
const
211 return d->neutralText;
214QColor KIconColors::activeText()
const
217 return d->activeText;
220void KIconColors::setText(
const QColor &color)
226void KIconColors::setBackground(
const QColor &color)
229 d->background = color;
232void KIconColors::setHighlight(
const QColor &color)
235 d->highlight = color;
238void KIconColors::setHighlightedText(
const QColor &color)
241 d->highlightedText = color;
244void KIconColors::setAccent(
const QColor &color)
250void KIconColors::setNegativeText(
const QColor &color)
253 d->negativeText = color;
256void KIconColors::setNeutralText(
const QColor &color)
259 d->neutralText = color;
262void KIconColors::setPositiveText(
const QColor &color)
265 d->positiveText = color;
268void KIconColors::setActiveText(
const QColor &color)
271 d->activeText = color;
Sepecifies which colors will be used when recoloring icons as its stylesheet.
KIconColors()
Will fill the colors based on the default QPalette() constructor.
QString stylesheet(KIconLoader::States state) const
States
Defines the possible states of an icon.
@ SelectedState
Icon is selected.
KGUIADDONS_EXPORT qreal luma(const QColor &)
const QColor & color() const const
float alphaF() const const
float blueF() const const
float greenF() const const
QString name(NameFormat format) const const
void setRgbF(float r, float g, float b, float a)
const QBrush & accent() const const
const QBrush & highlight() const const
const QBrush & highlightedText() const const
const QBrush & window() const const
const QBrush & windowText() const const
QString arg(Args &&... args) const const