KWin
Loading...
Searching...
No Matches
colorhelper.cpp
Go to the documentation of this file.
1/*
2 SPDX-FileCopyrightText: 2012 Martin Gräßlin <mgraesslin@kde.org>
3
4 SPDX-License-Identifier: GPL-2.0-or-later
5*/
6#include "colorhelper.h"
7
8#include <KColorScheme>
9
11 : QObject(parent)
12{
13}
14
18
19QColor ColorHelper::shade(const QColor &color, ColorHelper::ShadeRole role)
20{
21 return KColorScheme::shade(color, static_cast<KColorScheme::ShadeRole>(role));
22}
23
24QColor ColorHelper::shade(const QColor &color, ColorHelper::ShadeRole role, qreal contrast)
25{
26 return KColorScheme::shade(color, static_cast<KColorScheme::ShadeRole>(role), contrast);
27}
28
30{
31 return KColorScheme::contrastF();
32}
33
34QColor ColorHelper::multiplyAlpha(const QColor &color, qreal alpha)
35{
36 QColor retCol(color);
37 retCol.setAlphaF(color.alphaF() * alpha);
38 return retCol;
39}
40
42{
43 KColorScheme kcs(active ? QPalette::Active : QPalette::Inactive, KColorScheme::Button);
44 return kcs.background(static_cast<KColorScheme::BackgroundRole>(role)).color();
45}
46
48{
49 KColorScheme kcs(active ? QPalette::Active : QPalette::Inactive, KColorScheme::Button);
50 return kcs.foreground(static_cast<KColorScheme::ForegroundRole>(role)).color();
51}
52
53#include "moc_colorhelper.cpp"
Q_INVOKABLE QColor multiplyAlpha(const QColor &color, qreal alpha)
Q_INVOKABLE QColor foreground(bool active, ForegroundRole role=NormalText) const
qreal contrast
Definition colorhelper.h:22
Q_INVOKABLE QColor shade(const QColor &color, ShadeRole role)
Q_INVOKABLE QColor background(bool active, BackgroundRole role=NormalBackground) const
ColorHelper(QObject *parent=nullptr)
~ColorHelper() override