KColorScheme

kstatefulbrush.cpp
1/*
2 SPDX-FileCopyrightText: 2007 Matthew Woehlke <mw_triad@users.sourceforge.net>
3
4 SPDX-License-Identifier: LGPL-2.0-or-later
5*/
6
7#include "kstatefulbrush.h"
8
9#include "kcolorschemehelpers_p.h"
10
11#include <array>
12
13class KStatefulBrushPrivate
14{
15public:
16 std::array<QBrush, QPalette::NColorGroups> brushes;
17};
18
20 : d(std::make_unique<KStatefulBrushPrivate>())
21{
22}
23
25
28{
29 d->brushes[QPalette::Active] = KColorScheme(QPalette::Active, set, config).foreground(role);
30 d->brushes[QPalette::Disabled] = KColorScheme(QPalette::Disabled, set, config).foreground(role);
31 d->brushes[QPalette::Inactive] = KColorScheme(QPalette::Inactive, set, config).foreground(role);
32}
33
36
37{
38 d->brushes[QPalette::Active] = KColorScheme(QPalette::Active, set, config).background(role);
39 d->brushes[QPalette::Disabled] = KColorScheme(QPalette::Disabled, set, config).background(role);
40 d->brushes[QPalette::Inactive] = KColorScheme(QPalette::Inactive, set, config).background(role);
41}
42
45{
46 d->brushes[QPalette::Active] = KColorScheme(QPalette::Active, set, config).decoration(role);
47 d->brushes[QPalette::Disabled] = KColorScheme(QPalette::Disabled, set, config).decoration(role);
48 d->brushes[QPalette::Inactive] = KColorScheme(QPalette::Inactive, set, config).decoration(role);
49}
50
51KStatefulBrush::KStatefulBrush(const QBrush &brush, KSharedConfigPtr config)
53{
54 if (!config) {
55 config = defaultConfig();
56 }
57 d->brushes[QPalette::Active] = brush;
58 d->brushes[QPalette::Disabled] = StateEffects(QPalette::Disabled, config).brush(brush);
59 d->brushes[QPalette::Inactive] = StateEffects(QPalette::Inactive, config).brush(brush);
60}
61
62KStatefulBrush::KStatefulBrush(const QBrush &brush, const QBrush &background, KSharedConfigPtr config)
64{
65 if (!config) {
66 config = defaultConfig();
67 }
68 d->brushes[QPalette::Active] = brush;
69 d->brushes[QPalette::Disabled] = StateEffects(QPalette::Disabled, config).brush(brush, background);
70 d->brushes[QPalette::Inactive] = StateEffects(QPalette::Inactive, config).brush(brush, background);
71}
72
75{
76 d->brushes[QPalette::Active] = other.d->brushes[QPalette::Active];
77 d->brushes[QPalette::Disabled] = other.d->brushes[QPalette::Disabled];
78 d->brushes[QPalette::Inactive] = other.d->brushes[QPalette::Inactive];
79}
80
82{
83 d->brushes[QPalette::Active] = other.d->brushes[QPalette::Active];
84 d->brushes[QPalette::Disabled] = other.d->brushes[QPalette::Disabled];
85 d->brushes[QPalette::Inactive] = other.d->brushes[QPalette::Inactive];
86 return *this;
87}
88
90{
91 if (state >= QPalette::Active && state < QPalette::NColorGroups) {
92 return d->brushes[state];
93 } else {
94 return d->brushes[QPalette::Active];
95 }
96}
97
99{
100 return brush(pal.currentColorGroup());
101}
A set of methods used to work with colors.
ForegroundRole
This enumeration describes the foreground color being selected from the given set.
BackgroundRole
This enumeration describes the background color being selected from the given set.
ColorSet
This enumeration describes the color set for which a color is being selected.
QBrush background(BackgroundRole=NormalBackground) const
Retrieve the requested background brush.
DecorationRole
This enumeration describes the decoration color being selected from the given set.
QBrush decoration(DecorationRole) const
Retrieve the requested decoration brush.
QBrush foreground(ForegroundRole=NormalText) const
Retrieve the requested foreground brush.
A container for a "state-aware" brush.
QBrush brush(QPalette::ColorGroup) const
Retrieve the brush for the specified widget state.
KStatefulBrush & operator=(const KStatefulBrush &)
Standard assignment operator.
KStatefulBrush()
Construct a "default" stateful brush.
~KStatefulBrush()
Destructor.
ColorGroup currentColorGroup() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri May 3 2024 11:49:20 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.