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
qgtk3json_p.h
Go to the documentation of this file.
1// Copyright (C) 2022 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 QGTK3JSON_P_H
5#define QGTK3JSON_P_H
6
7#include <QtCore/QCache>
8#include <QtCore/QJsonArray>
9#include <QtCore/QJsonDocument>
10#include <QtCore/QJsonObject>
11#include <QtCore/QMap>
12#include <QtCore/QString>
13#include <QtGui/QGuiApplication>
14#include <QtGui/QPalette>
15
16#include <qpa/qplatformtheme.h>
18#include "qgtk3storage_p.h"
19
20#undef signals // Collides with GTK symbols
21#include <gtk/gtk.h>
22#include <gdk/gdk.h>
23#include <glib.h>
24
25//
26// W A R N I N G
27// -------------
28//
29// This file is not part of the Qt API. It exists purely as an
30// implementation detail. This header file may change from version to
31// version without notice, or even be removed.
32//
33// We mean it.
34//
35
37
39{
41private:
42 QGtk3Json() {}
43
44public:
45 // Convert enums to strings
47 static QLatin1String fromGtkState(GtkStateFlags type);
48 static QLatin1String fromColor(const QColor &Color);
49 static QLatin1String fromColorRole(QPalette::ColorRole role);
50 static QLatin1String fromColorGroup(QPalette::ColorGroup group);
51 static QLatin1String fromGdkSource(QGtk3Interface::QGtkColorSource source);
54 static QLatin1String fromColorScheme(Qt::ColorScheme colorScheme);
55
56 // Convert strings to enums
57 static QPlatformTheme::Palette toPalette(const QString &palette);
58 static GtkStateFlags toGtkState(const QString &type);
59 static QColor toColor(const QString &Color);
60 static QPalette::ColorRole toColorRole(const QString &role);
61 static QPalette::ColorGroup toColorGroup(const QString &group);
62 static QGtk3Interface::QGtkColorSource toGdkSource(const QString &source);
63 static QGtk3Storage::SourceType toSourceType(const QString &sourceType);
64 static QGtk3Interface::QGtkWidget toWidgetType(const QString &widgetType);
65 static Qt::ColorScheme toColorScheme(const QString &colorScheme);
66
67 // Json keys
68 static constexpr QLatin1StringView cePalettes = "QtGtk3Palettes"_L1;
69 static constexpr QLatin1StringView cePalette = "PaletteType"_L1;
70 static constexpr QLatin1StringView ceGtkState = "GtkStateType"_L1;
71 static constexpr QLatin1StringView ceGtkWidget = "GtkWidgetType"_L1;
72 static constexpr QLatin1StringView ceColor = "Color"_L1;
73 static constexpr QLatin1StringView ceColorRole = "ColorRole"_L1;
74 static constexpr QLatin1StringView ceColorGroup = "ColorGroup"_L1;
75 static constexpr QLatin1StringView ceGdkSource = "GdkSource"_L1;
76 static constexpr QLatin1StringView ceSourceType = "SourceType"_L1;
77 static constexpr QLatin1StringView ceLighter = "Lighter"_L1;
78 static constexpr QLatin1StringView ceRed = "DeltaRed"_L1;
79 static constexpr QLatin1StringView ceGreen = "DeltaGreen"_L1;
80 static constexpr QLatin1StringView ceBlue = "DeltaBlue"_L1;
81 static constexpr QLatin1StringView ceWidth = "Width"_L1;
82 static constexpr QLatin1StringView ceHeight = "Height"_L1;
83 static constexpr QLatin1StringView ceBrush = "FixedBrush"_L1;
84 static constexpr QLatin1StringView ceData = "SourceData"_L1;
85 static constexpr QLatin1StringView ceBrushes = "Brushes"_L1;
86 static constexpr QLatin1StringView ceColorScheme = "ColorScheme"_L1;
87
88 // Save to a file
89 static bool save(const QGtk3Storage::PaletteMap &map, const QString &fileName,
90 QJsonDocument::JsonFormat format = QJsonDocument::Indented);
91
92 // Save to a Json document
93 static const QJsonDocument save(const QGtk3Storage::PaletteMap &map);
94
95 // Load from a file
96 static bool load(QGtk3Storage::PaletteMap &map, const QString &fileName);
97
98 // Load from a Json document
99 static bool load(QGtk3Storage::PaletteMap &map, const QJsonDocument &doc);
100};
101
102QT_END_NAMESPACE
103#endif // QGTK3JSON_P_H
The QGtk3Interface class centralizes communication with the GTK3 library.
static QLatin1String fromColorGroup(QPalette::ColorGroup group)
Definition qgtk3json.cpp:42
static QLatin1String fromWidgetType(QGtk3Interface::QGtkWidget widgetType)
Definition qgtk3json.cpp:52
static QLatin1String fromColorRole(QPalette::ColorRole role)
Definition qgtk3json.cpp:37
static constexpr QLatin1StringView cePalette
Definition qgtk3json_p.h:69
static constexpr QLatin1StringView ceColorGroup
Definition qgtk3json_p.h:74
static constexpr QLatin1StringView ceGreen
Definition qgtk3json_p.h:79
static constexpr QLatin1StringView ceBrush
Definition qgtk3json_p.h:83
static constexpr QLatin1StringView ceWidth
Definition qgtk3json_p.h:81
static GtkStateFlags toGtkState(const QString &type)
Definition qgtk3json.cpp:77
static QPalette::ColorRole toColorRole(const QString &role)
Definition qgtk3json.cpp:90
static constexpr QLatin1StringView ceBlue
Definition qgtk3json_p.h:80
static QPalette::ColorGroup toColorGroup(const QString &group)
Definition qgtk3json.cpp:95
static constexpr QLatin1StringView ceHeight
Definition qgtk3json_p.h:82
static constexpr QLatin1StringView ceColorScheme
Definition qgtk3json_p.h:86
static bool save(const QGtk3Storage::PaletteMap &map, const QString &fileName, QJsonDocument::JsonFormat format=QJsonDocument::Indented)
static constexpr QLatin1StringView ceColor
Definition qgtk3json_p.h:72
static constexpr QLatin1StringView ceGtkWidget
Definition qgtk3json_p.h:71
static constexpr QLatin1StringView ceLighter
Definition qgtk3json_p.h:77
static constexpr QLatin1StringView ceSourceType
Definition qgtk3json_p.h:76
static bool load(QGtk3Storage::PaletteMap &map, const QString &fileName)
static const QJsonDocument save(const QGtk3Storage::PaletteMap &map)
static constexpr QLatin1StringView ceData
Definition qgtk3json_p.h:84
static QLatin1String fromGdkSource(QGtk3Interface::QGtkColorSource source)
Definition qgtk3json.cpp:47
static QGtk3Interface::QGtkColorSource toGdkSource(const QString &source)
static constexpr QLatin1StringView cePalettes
Definition qgtk3json_p.h:68
static QLatin1String fromSourceType(QGtk3Storage::SourceType sourceType)
static constexpr QLatin1StringView ceRed
Definition qgtk3json_p.h:78
static QGtk3Storage::SourceType toSourceType(const QString &sourceType)
static constexpr QLatin1StringView ceColorRole
Definition qgtk3json_p.h:73
static QPlatformTheme::Palette toPalette(const QString &palette)
Definition qgtk3json.cpp:72
static QColor toColor(const QString &Color)
static QGtk3Interface::QGtkWidget toWidgetType(const QString &widgetType)
static Qt::ColorScheme toColorScheme(const QString &colorScheme)
Definition qgtk3json.cpp:67
static constexpr QLatin1StringView ceBrushes
Definition qgtk3json_p.h:85
static QLatin1String fromColorScheme(Qt::ColorScheme colorScheme)
Definition qgtk3json.cpp:57
static QLatin1String fromGtkState(GtkStateFlags type)
Definition qgtk3json.cpp:27
static constexpr QLatin1StringView ceGdkSource
Definition qgtk3json_p.h:75
static constexpr QLatin1StringView ceGtkState
Definition qgtk3json_p.h:70
static QLatin1String fromColor(const QColor &Color)
QFlatMap< QPlatformTheme::Palette, BrushMap > PaletteMap
QFlatMap< TargetBrush, Source > BrushMap
SourceType
This enum represents the type of a color source.
#define CONVERT
#define GETINT(obj, key, var)
QColor toColor(const QStringView &color)
Definition qgtk3json.cpp:85
#define GETSTR(obj, key)
QLatin1String fromColor(const QColor &color)
Definition qgtk3json.cpp:32