Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qpalette_p.h
Go to the documentation of this file.
1// Copyright (C) 2023 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_P_H
5#define QPALETTE_P_H
6
7//
8// W A R N I N G
9// -------------
10//
11// This file is not part of the Qt API. It exists purely as an
12// implementation detail. This header file may change from version to
13// version without notice, or even be removed.
14//
15// We mean it.
16//
17
18#include "qpalette.h"
19
21
22class Q_GUI_EXPORT QPalettePrivate
23{
24public:
25 class Data : public QSharedData {
26 public:
27 // Every instance of Data has to have a unique serial number, even
28 // if it gets created by copying another - we wouldn't create a copy
29 // in the first place if the serial number should be the same!
30 Data(const Data &other)
31 : QSharedData(other)
32 {
33 for (int grp = 0; grp < int(QPalette::NColorGroups); grp++) {
34 for (int role = 0; role < int(QPalette::NColorRoles); role++)
35 br[grp][role] = other.br[grp][role];
36 }
37 }
38 Data() = default;
39
40 QBrush br[QPalette::NColorGroups][QPalette::NColorRoles];
41 const int ser_no = qt_palette_count++;
42 };
43
44 QPalettePrivate(const QExplicitlySharedDataPointer<Data> &data)
45 : ref(1), data(data)
46 { }
47 QPalettePrivate()
48 : QPalettePrivate(QExplicitlySharedDataPointer<Data>(new Data))
49 { }
50
51 static constexpr QPalette::ResolveMask colorRoleOffset(QPalette::ColorGroup colorGroup)
52 {
53 // Exclude NoRole; that bit is used for Accent
54 return (qToUnderlying(QPalette::NColorRoles) - 1) * qToUnderlying(colorGroup);
55 }
56
57 static constexpr QPalette::ResolveMask bitPosition(QPalette::ColorGroup colorGroup,
58 QPalette::ColorRole colorRole)
59 {
60 // Map Accent into NoRole for resolving purposes
61 if (colorRole == QPalette::Accent)
62 colorRole = QPalette::NoRole;
63
64 return colorRole + colorRoleOffset(colorGroup);
65 }
66
67 QAtomicInt ref;
68 QPalette::ResolveMask resolveMask = {0};
69 static inline int qt_palette_count = 0;
70 static inline int qt_palette_private_count = 0;
71 int detach_no = ++qt_palette_private_count;
72 QExplicitlySharedDataPointer<Data> data;
73};
74
75QT_END_NAMESPACE
76
77#endif // QPALETTE_P_H
Combined button and popup list for selecting options.
QDataStream & operator>>(QDataStream &s, QKeyCombination &combination)
QDebug operator<<(QDebug dbg, const QFileInfo &fi)
static QString groupsToString(const QPalette &p, QPalette::ColorRole cr)
static void qt_ensure_default_accent_color(QPalette &pal)
Definition qpalette.cpp:53
static const int NumOldRoles
static void qt_placeholder_from_text(QPalette &pal, int alpha=50)
Definition qpalette.cpp:35
static constexpr QPalette::ResolveMask allResolveMask()
Definition qpalette.cpp:946
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)
Definition qpalette.cpp:19
static const int oldRoles[7]
static void qt_palette_from_color(QPalette &pal, const QColor &button)
Definition qpalette.cpp:71