11#include <QtCore/qmetaobject.h>
36 "The resolve mask type is not wide enough to fit the entire bit mask.");
51 br[grp][role] =
other.br[grp][role];
76 return QColor((
a.red() +
b.red()) / 2, (
a.green() +
b.green()) / 2,
77 (
a.blue() +
b.blue()) / 2, (
a.alpha() +
b.alpha()) / 2);
92 if (alpha < 0 or alpha > 100)
101 const int a = (
c.alpha() *
alpha) / 100;
133 const QBrush baseBrush =
v > 128 ? whiteBrush : blackBrush;
134 const QBrush foregroundBrush =
v > 128 ? blackBrush : whiteBrush;
140 buttonBrushDark, buttonBrushDark150, foregroundBrush, whiteBrush,
141 baseBrush, buttonBrush);
143 buttonBrushDark, buttonBrushDark150, foregroundBrush, whiteBrush,
144 baseBrush, buttonBrush);
146 buttonBrushDark, buttonBrushDark150, buttonBrushDark,
147 whiteBrush, buttonBrush, buttonBrush);
684 const QBrush baseBrush =
v > 128 ? whiteBrush : blackBrush;
685 const QBrush foregroundBrush =
v > 128 ? blackBrush : whiteBrush;
695 buttonBrushDark150, foregroundBrush, whiteBrush, baseBrush,
698 buttonBrushDark150, foregroundBrush, whiteBrush, baseBrush,
701 buttonBrushDark, buttonBrushDark150, disabledForeground,
702 whiteBrush, baseBrush, windowBrush);
714 :
d(
p.
d), currentGroup(
p.currentGroup)
754 currentGroup =
p.currentGroup;
801 qWarning(
"QPalette::brush: Unknown ColorGroup: %d", (
int)gr);
805 return d->
data->br[gr][cr];
839 qWarning(
"QPalette::setBrush: Unknown ColorGroup: %d", cg);
844 const auto valueChanged = d->
data->br[cg][cr] !=
b;
849 d->
data->br[cg][cr] =
b;
881 qWarning() <<
"Wrong color group:" << cg;
886 qWarning() <<
"Wrong color role:" << cr;
896void QPalette::detach()
938 for(
int role = 0; role < (int)
NColorRoles; role++) {
942 if (d->
data->br[grp][role] !=
p.d->data->br[grp][role])
959 group1 = currentGroup;
961 qWarning(
"QPalette::brush: Unknown ColorGroup(1): %d", (
int)group1);
967 group2 = currentGroup;
969 qWarning(
"QPalette::brush: Unknown ColorGroup(2): %d", (
int)group2);
973 if (group1 == group2)
975 for(
int role = 0; role < (int)
NColorRoles; role++) {
976 if (d->
data->br[group1][role] != d->
data->br[group2][role])
1024 for (
int role = 0; role < int(
NColorRoles); ++role) {
1032 palette.d->data->br[grp][role] =
other.d->data->br[grp][role];
1074#ifndef QT_NO_DATASTREAM
1092 if (
s.version() == 1) {
1107 for (
int r = 0;
r < max;
r++)
1108 s <<
p.d->data->br[grp][
r];
1134 if (
s.version() == 1) {
1159 for(
int role = 0; role < max; ++role) {
1232 const QBrush &highlight,
const QBrush &highlighted_text,
1236 text, bright_text,
base, alternate_base, background,
1238 link, link_visited, background, foreground);
1248 const QBrush &highlight,
const QBrush &highlighted_text,
1273#ifndef QT_NO_DEBUG_STREAM
1276 const auto groupEnum = QMetaEnum::fromType<QPalette::ColorGroup>();
1282 if (
p.isBrushSet(cg, cr)) {
1283 const auto &
color =
p.color(cg, cr);
1295 const auto roleEnum = QMetaEnum::fromType<QPalette::ColorRole>();
1319 if (!roleString.isEmpty())
1320 dbg <<
',' << roleString;
1330#include "moc_qpalette.cpp"
T loadRelaxed() const noexcept
const QColor & color() const
Returns the brush color.
The QColor class provides colors based on RGB, HSV or CMYK values.
int lightness() const noexcept
void setAlpha(int alpha)
Sets the alpha of this color to alpha.
QColor lighter(int f=150) const noexcept
\inmodule QtCore\reentrant
void detach()
If the shared data object's reference count is greater than 1, this function creates a deep copy of t...
static QPalette * app_pal
QBrush br[QPalette::NColorGroups][QPalette::NColorRoles]
static int qt_palette_private_count
QPalette::ResolveMask resolveMask
QPalettePrivate(const QExplicitlySharedDataPointer< Data > &data)
QExplicitlySharedDataPointer< Data > data
The QPalette class contains color groups for each widget state.
const QBrush & highlight() const
Returns the highlight brush of the current color group.
const QBrush & button() const
Returns the button brush of the current color group.
const QBrush & text() const
Returns the text foreground brush of the current color group.
const QBrush & toolTipBase() const
const QBrush & windowText() const
Returns the window text (general foreground) brush of the current color group.
const QBrush & dark() const
Returns the dark brush of the current color group.
const QBrush & brush(ColorGroup cg, ColorRole cr) const
Returns the brush in the specified color group, used for the given color role.
QPalette & operator=(const QPalette &palette)
Move-assigns other to this QPalette instance.
qint64 cacheKey() const
Returns a number that identifies the contents of this QPalette object.
const QBrush & toolTipText() const
const QBrush & link() const
Returns the unvisited link text brush of the current color group.
const QBrush & shadow() const
Returns the shadow brush of the current color group.
const QBrush & light() const
Returns the light brush of the current color group.
const QColor & color(ColorGroup cg, ColorRole cr) const
Returns the color in the specified color group, used for the given color role.
const QBrush & mid() const
Returns the mid brush of the current color group.
void setBrush(ColorRole cr, const QBrush &brush)
Sets the brush for the given color role to the specified brush for all groups in the palette.
bool isEqual(ColorGroup cr1, ColorGroup cr2) const
Returns true (usually quickly) if color group cg1 is equal to cg2; otherwise returns false.
void setResolveMask(ResolveMask mask)
bool operator==(const QPalette &p) const
Returns true (usually quickly) if this palette is equal to p; otherwise returns false (slowly).
QPalette()
Constructs an empty palette object with no color roles set.
bool isBrushSet(ColorGroup cg, ColorRole cr) const
QDataStream & operator>>(QDataStream &s, QPalette &p)
Reads a palette from the stream, s into the palette p, and returns a reference to the stream.
ResolveMask resolveMask() const
const QBrush & midlight() const
Returns the midlight brush of the current color group.
~QPalette()
Destroys the palette.
ColorGroup
\value Disabled \value Active \value Inactive \value Normal synonym for Active
QPalette resolve(const QPalette &other) const
Returns a new QPalette that is a union of this instance and other.
void setColor(ColorGroup cg, ColorRole cr, const QColor &color)
Sets the color in the specified color group, used for the given color role, to the specified solid co...
void setColorGroup(ColorGroup cr, const QBrush &windowText, const QBrush &button, const QBrush &light, const QBrush &dark, const QBrush &mid, const QBrush &text, const QBrush &bright_text, const QBrush &base, const QBrush &window)
Sets a the group at cg.
const QBrush & window() const
Returns the window (general background) brush of the current color group.
const QBrush & base() const
Returns the base brush of the current color group.
bool isCopyOf(const QPalette &p) const
Returns true if this palette and p are copies of each other, i.e.
\macro QT_RESTRICTED_CAST_FROM_ASCII
void chop(qsizetype n)
Removes n characters from the end of the string.
static QString fromUtf8(QByteArrayView utf8)
This is an overloaded member function, provided for convenience. It differs from the above function o...
static auto fromValue(T &&value) noexcept(std::is_nothrow_copy_constructible_v< T > &&Private::CanUseInternalSpace< T >) -> std::enable_if_t< std::conjunction_v< std::is_copy_constructible< T >, std::is_destructible< T > >, QVariant >
[Window class with invokable method]
Combined button and popup list for selecting options.
QTextStream & hex(QTextStream &stream)
Calls QTextStream::setIntegerBase(16) on stream and returns stream.
QTextStream & showbase(QTextStream &stream)
Calls QTextStream::setNumberFlags(QTextStream::numberFlags() | QTextStream::ShowBase) on stream and r...
GLboolean GLboolean GLboolean b
GLsizei const GLfloat * v
[13]
GLint GLint GLint GLint GLint x
[0]
GLsizei GLsizei GLchar * groupString
GLboolean GLboolean GLboolean GLboolean a
[7]
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
GLint GLint GLint GLint GLint GLint GLint GLbitfield mask
GLfloat GLfloat GLfloat GLfloat h
GLfloat GLfloat GLfloat alpha
static const int NumOldRoles
static constexpr QPalette::ResolveMask bitPosition(QPalette::ColorGroup colorGroup, QPalette::ColorRole colorRole)
static QString groupsToString(const QPalette &p, QPalette::ColorRole cr)
static void qt_ensure_default_accent_color(QPalette &pal)
static const int oldRoles[7]
QDebug operator<<(QDebug dbg, const QPalette &p)
static constexpr QPalette::ResolveMask colorRoleOffset(QPalette::ColorGroup colorGroup)
static void qt_placeholder_from_text(QPalette &pal, int alpha=50)
static constexpr QPalette::ResolveMask allResolveMask()
static QString rolesToString(const QPalette &p)
static QT_BEGIN_NAMESPACE int qt_palette_count
static void readV1ColorGroup(QDataStream &s, QPalette &pal, QPalette::ColorGroup grp)
static QColor qt_mix_colors(QColor a, QColor b)
static void qt_palette_from_color(QPalette &pal, const QColor &button)
#define QStringLiteral(str)
constexpr std::underlying_type_t< Enum > qToUnderlying(Enum e) noexcept