10#include <QtCore/qmetaobject.h>
17 "The resolve mask type is not wide enough to fit the entire bit mask.");
21 return QColor((
a.red() +
b.red()) / 2, (
a.green() +
b.green()) / 2,
22 (
a.blue() +
b.blue()) / 2, (
a.alpha() +
b.alpha()) / 2);
37 if (alpha < 0 or alpha > 100)
46 const int a = (
c.alpha() *
alpha) / 100;
78 const QBrush baseBrush =
v > 128 ? whiteBrush : blackBrush;
79 const QBrush foregroundBrush =
v > 128 ? blackBrush : whiteBrush;
85 buttonBrushDark, buttonBrushDark150, foregroundBrush, whiteBrush,
86 baseBrush, buttonBrush);
88 buttonBrushDark, buttonBrushDark150, foregroundBrush, whiteBrush,
89 baseBrush, buttonBrush);
91 buttonBrushDark, buttonBrushDark150, buttonBrushDark,
92 whiteBrush, buttonBrush, buttonBrush);
638 const QBrush baseBrush =
v > 128 ? whiteBrush : blackBrush;
639 const QBrush foregroundBrush =
v > 128 ? blackBrush : whiteBrush;
649 buttonBrushDark150, foregroundBrush, whiteBrush, baseBrush,
652 buttonBrushDark150, foregroundBrush, whiteBrush, baseBrush,
655 buttonBrushDark, buttonBrushDark150, disabledForeground,
656 whiteBrush, baseBrush, windowBrush);
668 :
d(
p.
d), currentGroup(
p.currentGroup)
708 currentGroup =
p.currentGroup;
755 qWarning(
"QPalette::brush: Unknown ColorGroup: %d", (
int)gr);
759 return d->
data->br[gr][cr];
793 qWarning(
"QPalette::setBrush: Unknown ColorGroup: %d", cg);
798 const auto valueChanged = d->
data->br[cg][cr] !=
b;
803 d->
data->br[cg][cr] =
b;
835 qWarning() <<
"Wrong color group:" << cg;
840 qWarning() <<
"Wrong color role:" << cr;
850void QPalette::detach()
892 for(
int role = 0; role < (int)
NColorRoles; role++) {
896 if (d->
data->br[grp][role] !=
p.d->data->br[grp][role])
913 group1 = currentGroup;
915 qWarning(
"QPalette::brush: Unknown ColorGroup(1): %d", (
int)group1);
921 group2 = currentGroup;
923 qWarning(
"QPalette::brush: Unknown ColorGroup(2): %d", (
int)group2);
927 if (group1 == group2)
929 for(
int role = 0; role < (int)
NColorRoles; role++) {
930 if (d->
data->br[group1][role] != d->
data->br[group2][role])
978 for (
int role = 0; role < int(
NColorRoles); ++role) {
986 palette.d->data->br[grp][role] =
other.d->data->br[grp][role];
1028#ifndef QT_NO_DATASTREAM
1046 if (
s.version() == 1) {
1052 if (
s.version() <= QDataStream::Qt_2_1)
1054 else if (
s.version() <= QDataStream::Qt_4_3)
1056 else if (
s.version() <= QDataStream::Qt_5_11)
1058 else if (
s.version() <= QDataStream::Qt_6_5)
1061 for (
int r = 0;
r < max;
r++)
1062 s <<
p.d->data->br[grp][
r];
1088 if (
s.version() == 1) {
1095 if (
s.version() <= QDataStream::Qt_2_1) {
1098 }
else if (
s.version() <= QDataStream::Qt_4_3) {
1101 }
else if (
s.version() <= QDataStream::Qt_5_11) {
1104 }
else if (
s.version() <= QDataStream::Qt_6_5) {
1113 for(
int role = 0; role < max; ++role) {
1119 if (
s.version() < QDataStream::Qt_6_6)
1186 const QBrush &highlight,
const QBrush &highlighted_text,
1190 text, bright_text,
base, alternate_base, background,
1192 link, link_visited, background, foreground);
1202 const QBrush &highlight,
const QBrush &highlighted_text,
1227#ifndef QT_NO_DEBUG_STREAM
1230 const auto groupEnum = QMetaEnum::fromType<QPalette::ColorGroup>();
1236 if (
p.isBrushSet(cg, cr)) {
1237 const auto &
color =
p.color(cg, cr);
1249 const auto roleEnum = QMetaEnum::fromType<QPalette::ColorRole>();
1273 if (!roleString.isEmpty())
1274 dbg <<
',' << roleString;
1284#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
static constexpr QPalette::ResolveMask bitPosition(QPalette::ColorGroup colorGroup, QPalette::ColorRole colorRole)
static int qt_palette_private_count
QPalette::ResolveMask resolveMask
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
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 GLint GLint GLint GLint GLint GLint GLbitfield mask
GLfloat GLfloat GLfloat GLfloat h
GLfloat GLfloat GLfloat alpha
static const int NumOldRoles
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 void qt_placeholder_from_text(QPalette &pal, int alpha=50)
static constexpr QPalette::ResolveMask allResolveMask()
static QString rolesToString(const QPalette &p)
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)