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// Qt-Security score:significant reason:default
4
5#ifndef QPALETTE_P_H
6#define QPALETTE_P_H
7
8//
9// W A R N I N G
10// -------------
11//
12// This file is not part of the Qt API. It exists purely as an
13// implementation detail. This header file may change from version to
14// version without notice, or even be removed.
15//
16// We mean it.
17//
18
19#include "qpalette.h"
20
21#include <QtCore/qatomic.h>
22
24
25class Q_GUI_EXPORT QPalettePrivate
26{
27public:
28 class Data : public QSharedData {
29 public:
30 // Every instance of Data has to have a unique serial number, even
31 // if it gets created by copying another - we wouldn't create a copy
32 // in the first place if the serial number should be the same!
33 Data(const Data &other)
34 : QSharedData(other)
35 {
36 for (int grp = 0; grp < int(QPalette::NColorGroups); grp++) {
37 for (int role = 0; role < int(QPalette::NColorRoles); role++)
38 br[grp][role] = other.br[grp][role];
39 }
40 }
41 Data() = default;
42
43 QBrush br[QPalette::NColorGroups][QPalette::NColorRoles];
44 const int ser_no = qt_palette_count++;
45 };
46
47 QPalettePrivate(const QExplicitlySharedDataPointer<Data> &data)
48 : ref(1), data(data)
49 { }
50 QPalettePrivate()
51 : QPalettePrivate(QExplicitlySharedDataPointer<Data>(new Data))
52 { }
53
54 static constexpr QPalette::ResolveMask colorRoleOffset(QPalette::ColorGroup colorGroup)
55 {
56 // Exclude NoRole; that bit is used for Accent
57 return (qToUnderlying(QPalette::NColorRoles) - 1) * qToUnderlying(colorGroup);
58 }
59
60 static constexpr QPalette::ResolveMask bitPosition(QPalette::ColorGroup colorGroup,
61 QPalette::ColorRole colorRole)
62 {
63 // Map Accent into NoRole for resolving purposes
64 if (colorRole == QPalette::Accent)
65 colorRole = QPalette::NoRole;
66
67 return colorRole + colorRoleOffset(colorGroup);
68 }
69
70 QAtomicInt ref;
71 QPalette::ResolveMask resolveMask = {0};
72 static QAtomicInt qt_palette_count;
73 static QAtomicInt qt_palette_private_count;
74 int detach_no = ++qt_palette_private_count;
75 QExplicitlySharedDataPointer<Data> data;
76};
77
78QT_END_NAMESPACE
79
80#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:57
static const int NumOldRoles
static void qt_placeholder_from_text(QPalette &pal, int alpha=50)
Definition qpalette.cpp:39
static constexpr QPalette::ResolveMask allResolveMask()
Definition qpalette.cpp:950
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:23
static const int oldRoles[7]
static void qt_palette_from_color(QPalette &pal, const QColor &button)
Definition qpalette.cpp:75