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
qquickpalettecolorprovider_p.h
Go to the documentation of this file.
1// Copyright (C) 2020 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#ifndef QQUICKPALETTECOLORPROVIDER_P_H
5#define QQUICKPALETTECOLORPROVIDER_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 <QtGui/QPalette>
19
20#include <QtQuick/qtquickglobal.h>
21
22#include <QtQuick/private/qtquickglobal_p.h>
23#include <private/qlazilyallocated_p.h>
24
25QT_BEGIN_NAMESPACE
26
27class QQuickAbstractPaletteProvider;
28
29class Q_QUICK_EXPORT QQuickPaletteColorProvider
30 : public std::enable_shared_from_this<QQuickPaletteColorProvider>
31{
32public:
33 QQuickPaletteColorProvider();
34
35 const QColor &color(QPalette::ColorGroup group, QPalette::ColorRole role) const;
36 bool setColor(QPalette::ColorGroup group, QPalette::ColorRole role, QColor color);
37 bool resetColor(QPalette::ColorGroup group, QPalette::ColorRole role);
38 bool resetColor(QPalette::ColorGroup group);
39
40 bool fromQPalette(QPalette p);
41 QPalette palette() const;
42
43 const QQuickAbstractPaletteProvider *paletteProvider() const;
44 void setPaletteProvider(const QQuickAbstractPaletteProvider *paletteProvider);
45
46 bool copyColorGroup(QPalette::ColorGroup cg, const QQuickPaletteColorProvider &p);
47
48 bool reset();
49
50 bool inheritPalette(const QPalette &palette);
51
52private:
53 bool doInheritPalette(const QPalette &palette);
54 bool updateInheritedPalette();
55 void ensureRequestedPalette();
56
57 QPalette m_resolvedPalette;
58 QLazilyAllocated<QPalette> m_requestedPalette;
59 QLazilyAllocated<QPalette> m_lastInheritedPalette;
60
61 using Deleter = std::function<void(const QQuickAbstractPaletteProvider*)>;
62 using ProviderPtr = std::unique_ptr<const QQuickAbstractPaletteProvider, Deleter>;
63 ProviderPtr m_paletteProvider;
64};
65
66QT_END_NAMESPACE
67
68#endif // QQUICKPALETTECOLORPROVIDER_P_H
QPalette defaultPalette() const override
static std::default_delete< const QQuickAbstractPaletteProvider > defaultDeleter()
static QPalette::ColorGroup adjustCg(QPalette::ColorGroup group)
static QT_BEGIN_NAMESPACE bool notEq(const QPalette &p1, const QPalette &p2)