Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qpalette.h
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#ifndef QPALETTE_H
5#define QPALETTE_H
6
7#include <QtGui/qtguiglobal.h>
8#include <QtGui/qwindowdefs.h>
9#include <QtGui/qcolor.h>
10#include <QtGui/qbrush.h>
11
13
14
15class QPalettePrivate;
16class QVariant;
17
18class Q_GUI_EXPORT QPalette
19{
21public:
22 QPalette();
23 QPalette(const QColor &button);
25 QPalette(const QColor &button, const QColor &window);
26 QPalette(const QBrush &windowText, const QBrush &button, const QBrush &light,
27 const QBrush &dark, const QBrush &mid, const QBrush &text,
28 const QBrush &bright_text, const QBrush &base, const QBrush &window);
29 QPalette(const QColor &windowText, const QColor &window, const QColor &light,
30 const QColor &dark, const QColor &mid, const QColor &text, const QColor &base);
32 ~QPalette();
33 QPalette &operator=(const QPalette &palette);
35 : d(std::exchange(other.d, nullptr)), currentGroup(other.currentGroup)
36 {}
37 QT_MOVE_ASSIGNMENT_OPERATOR_IMPL_VIA_PURE_SWAP(QPalette)
38
40 {
41 std::swap(currentGroup, other.currentGroup);
43 }
44
45 operator QVariant() const;
46
47 // Do not change the order, the serialization format depends on it
48 // Ensure these values are kept in sync with QQuickColorGroup's properties.
49 enum ColorGroup { Active, Disabled, Inactive, NColorGroups, Current, All, Normal = Active };
50 Q_ENUM(ColorGroup)
51 enum ColorRole { WindowText, Button, Light, Midlight, Dark, Mid,
52 Text, BrightText, ButtonText, Base, Window, Shadow,
53 Highlight, HighlightedText,
54 Link, LinkVisited,
57 ToolTipBase, ToolTipText,
60 NColorRoles = Accent + 1,
61 };
62 Q_ENUM(ColorRole)
63
64 inline ColorGroup currentColorGroup() const { return currentGroup; }
65 inline void setCurrentColorGroup(ColorGroup cg) { currentGroup = cg; }
66
67 inline const QColor &color(ColorGroup cg, ColorRole cr) const
68 { return brush(cg, cr).color(); }
69 const QBrush &brush(ColorGroup cg, ColorRole cr) const;
70 inline void setColor(ColorGroup cg, ColorRole cr, const QColor &color);
71 inline void setColor(ColorRole cr, const QColor &color);
72 inline void setBrush(ColorRole cr, const QBrush &brush);
73 bool isBrushSet(ColorGroup cg, ColorRole cr) const;
74 void setBrush(ColorGroup cg, ColorRole cr, const QBrush &brush);
75 void setColorGroup(ColorGroup cr, const QBrush &windowText, const QBrush &button,
76 const QBrush &light, const QBrush &dark, const QBrush &mid,
77 const QBrush &text, const QBrush &bright_text, const QBrush &base,
78 const QBrush &window);
79 bool isEqual(ColorGroup cr1, ColorGroup cr2) const;
80
81 inline const QColor &color(ColorRole cr) const { return color(Current, cr); }
82 inline const QBrush &brush(ColorRole cr) const { return brush(Current, cr); }
83 inline const QBrush &windowText() const { return brush(WindowText); }
84 inline const QBrush &button() const { return brush(Button); }
85 inline const QBrush &light() const { return brush(Light); }
86 inline const QBrush &dark() const { return brush(Dark); }
87 inline const QBrush &mid() const { return brush(Mid); }
88 inline const QBrush &text() const { return brush(Text); }
89 inline const QBrush &base() const { return brush(Base); }
90 inline const QBrush &alternateBase() const { return brush(AlternateBase); }
91 inline const QBrush &toolTipBase() const { return brush(ToolTipBase); }
92 inline const QBrush &toolTipText() const { return brush(ToolTipText); }
93 inline const QBrush &window() const { return brush(Window); }
94 inline const QBrush &midlight() const { return brush(Midlight); }
95 inline const QBrush &brightText() const { return brush(BrightText); }
96 inline const QBrush &buttonText() const { return brush(ButtonText); }
97 inline const QBrush &shadow() const { return brush(Shadow); }
98 inline const QBrush &highlight() const { return brush(Highlight); }
99 inline const QBrush &highlightedText() const { return brush(HighlightedText); }
100 inline const QBrush &link() const { return brush(Link); }
101 inline const QBrush &linkVisited() const { return brush(LinkVisited); }
102 inline const QBrush &placeholderText() const { return brush(PlaceholderText); }
103 inline const QBrush &accent() const { return brush(Accent); }
104
105 bool operator==(const QPalette &p) const;
106 inline bool operator!=(const QPalette &p) const { return !(operator==(p)); }
107 bool isCopyOf(const QPalette &p) const;
108
109 qint64 cacheKey() const;
110
111 QPalette resolve(const QPalette &other) const;
112
114 ResolveMask resolveMask() const;
115 void setResolveMask(ResolveMask mask);
116
117private:
118 void setColorGroup(ColorGroup cr, const QBrush &windowText, const QBrush &button,
119 const QBrush &light, const QBrush &dark, const QBrush &mid,
120 const QBrush &text, const QBrush &bright_text,
121 const QBrush &base, const QBrush &alternate_base,
122 const QBrush &window, const QBrush &midlight,
123 const QBrush &button_text, const QBrush &shadow,
124 const QBrush &highlight, const QBrush &highlighted_text,
125 const QBrush &link, const QBrush &link_visited);
126 void setColorGroup(ColorGroup cr, const QBrush &windowText, const QBrush &button,
127 const QBrush &light, const QBrush &dark, const QBrush &mid,
128 const QBrush &text, const QBrush &bright_text,
129 const QBrush &base, const QBrush &alternate_base,
130 const QBrush &window, const QBrush &midlight,
131 const QBrush &button_text, const QBrush &shadow,
132 const QBrush &highlight, const QBrush &highlighted_text,
133 const QBrush &link, const QBrush &link_visited,
134 const QBrush &toolTipBase, const QBrush &toolTipText);
135 void init();
136 void detach();
137
139 ColorGroup currentGroup{Active};
140
141 friend Q_GUI_EXPORT QDataStream &operator<<(QDataStream &s, const QPalette &p);
142};
143
144Q_DECLARE_SHARED(QPalette)
145
146inline void QPalette::setColor(ColorGroup acg, ColorRole acr,
147 const QColor &acolor)
148{ setBrush(acg, acr, QBrush(acolor)); }
149inline void QPalette::setColor(ColorRole acr, const QColor &acolor)
150{ setColor(All, acr, acolor); }
151inline void QPalette::setBrush(ColorRole acr, const QBrush &abrush)
152{ setBrush(All, acr, abrush); }
153
154/*****************************************************************************
155 QPalette stream functions
156 *****************************************************************************/
157#ifndef QT_NO_DATASTREAM
158Q_GUI_EXPORT QDataStream &operator<<(QDataStream &ds, const QPalette &p);
160#endif // QT_NO_DATASTREAM
161
162#ifndef QT_NO_DEBUG_STREAM
163Q_GUI_EXPORT QDebug operator<<(QDebug, const QPalette &);
164#endif
165
167
168#endif // QPALETTE_H
static bool isEqual(const aiUVTransform &a, const aiUVTransform &b)
\inmodule QtGui
Definition qbrush.h:30
The QColor class provides colors based on RGB, HSV or CMYK values.
Definition qcolor.h:31
\inmodule QtCore\reentrant
Definition qdatastream.h:46
\inmodule QtCore
The QPalette class contains color groups for each widget state.
Definition qpalette.h:19
const QBrush & highlight() const
Returns the highlight brush of the current color group.
Definition qpalette.h:98
const QBrush & button() const
Returns the button brush of the current color group.
Definition qpalette.h:84
const QBrush & text() const
Returns the text foreground brush of the current color group.
Definition qpalette.h:88
const QBrush & toolTipBase() const
Definition qpalette.h:91
const QBrush & windowText() const
Returns the window text (general foreground) brush of the current color group.
Definition qpalette.h:83
QPalette(QPalette &&other) noexcept
Definition qpalette.h:34
const QBrush & dark() const
Returns the dark brush of the current color group.
Definition qpalette.h:86
const QBrush & accent() const
Definition qpalette.h:103
bool operator!=(const QPalette &p) const
Returns true (slowly) if this palette is different from p; otherwise returns false (usually quickly).
Definition qpalette.h:106
const QBrush & toolTipText() const
Definition qpalette.h:92
const QBrush & link() const
Returns the unvisited link text brush of the current color group.
Definition qpalette.h:100
const QBrush & shadow() const
Returns the shadow brush of the current color group.
Definition qpalette.h:97
const QBrush & brightText() const
Returns the bright text foreground brush of the current color group.
Definition qpalette.h:95
const QBrush & brush(ColorRole cr) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition qpalette.h:82
const QBrush & light() const
Returns the light brush of the current color group.
Definition qpalette.h:85
quint64 ResolveMask
Definition qpalette.h:113
void setCurrentColorGroup(ColorGroup cg)
Set the palette's current color group to cg.
Definition qpalette.h:65
const QColor & color(ColorGroup cg, ColorRole cr) const
Returns the color in the specified color group, used for the given color role.
Definition qpalette.h:67
const QBrush & linkVisited() const
Returns the visited link text brush of the current color group.
Definition qpalette.h:101
const QBrush & mid() const
Returns the mid brush of the current color group.
Definition qpalette.h:87
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.
Definition qpalette.h:151
const QBrush & alternateBase() const
Returns the alternate base brush of the current color group.
Definition qpalette.h:90
const QColor & color(ColorRole cr) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition qpalette.h:81
const QBrush & midlight() const
Returns the midlight brush of the current color group.
Definition qpalette.h:94
ColorGroup
\value Disabled \value Active \value Inactive \value Normal synonym for Active
Definition qpalette.h:49
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...
Definition qpalette.h:146
const QBrush & placeholderText() const
Definition qpalette.h:102
const QBrush & window() const
Returns the window (general background) brush of the current color group.
Definition qpalette.h:93
const QBrush & base() const
Returns the base brush of the current color group.
Definition qpalette.h:89
@ ToolTipBase
Definition qpalette.h:57
@ AlternateBase
Definition qpalette.h:55
@ Highlight
Definition qpalette.h:53
@ PlaceholderText
Definition qpalette.h:58
const QBrush & buttonText() const
Returns the button text foreground brush of the current color group.
Definition qpalette.h:96
const QBrush & highlightedText() const
Returns the highlighted text brush of the current color group.
Definition qpalette.h:99
\inmodule QtCore
Definition qvariant.h:65
[Window class with invokable method]
Definition window.h:11
QString text
QPushButton * button
[2]
Combined button and popup list for selecting options.
GlobalColor
Definition qnamespace.h:27
Definition brush.cpp:5
DBusConnection const char DBusError DBusBusType DBusError return DBusConnection DBusHandleMessageFunction void DBusFreeFunction return DBusConnection return DBusConnection return const char DBusError return DBusConnection DBusMessage dbus_uint32_t return DBusConnection dbus_bool_t DBusConnection DBusAddWatchFunction DBusRemoveWatchFunction DBusWatchToggledFunction void DBusFreeFunction return DBusConnection DBusDispatchStatusFunction void DBusFreeFunction DBusTimeout return DBusTimeout return DBusWatch return DBusWatch unsigned int return DBusError const DBusError return const DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessageIter int const void return DBusMessageIter DBusMessageIter return DBusMessageIter void DBusMessageIter void int return DBusMessage DBusMessageIter return DBusMessageIter return DBusMessageIter DBusMessageIter const char const char const char const char return DBusMessage return DBusMessage const char return DBusMessage dbus_bool_t return DBusMessage dbus_uint32_t return DBusMessage void
static QByteArray cacheKey(Args &&...args)
Button
GLuint color
[2]
GLint GLint GLint GLint GLint GLint GLint GLbitfield mask
GLdouble s
[6]
Definition qopenglext.h:235
GLfloat GLfloat p
[1]
Q_GUI_EXPORT QDataStream & operator>>(QDataStream &ds, QPalette &p)
Q_GUI_EXPORT QDataStream & operator<<(QDataStream &ds, const QPalette &p)
static const QQmlJSScope * resolve(const QQmlJSScope *current, const QStringList &names)
bool operator==(const QRandomGenerator &rng1, const QRandomGenerator &rng2)
Definition qrandom.cpp:1220
constexpr void qt_ptr_swap(T *&lhs, T *&rhs) noexcept
Definition qswap.h:29
static QT_BEGIN_NAMESPACE void init(QTextBoundaryFinder::BoundaryType type, QStringView str, QCharAttributes *attributes)
#define Q_ENUM(x)
#define Q_GADGET
unsigned long long quint64
Definition qtypes.h:61
long long qint64
Definition qtypes.h:60
static const uint base
Definition qurlidna.cpp:20
XID Window
QDataStream & operator<<(QDataStream &out, const MyClass &myObj)
[4]
QSharedPointer< T > other(t)
[5]
this swap(other)
myFilter setColor(QColor(128, 0, 0))
aWidget window() -> setWindowTitle("New Window Title")
[2]