16#include <QtCore/QFile>
23 return QLatin1String(QMetaEnum::fromType<QPlatformTheme::Palette>().valueToKey(
static_cast<int>(
palette)));
38 return QLatin1String(QMetaEnum::fromType<QPalette::ColorRole>().valueToKey(
static_cast<int>(role)));
43 return QLatin1String(QMetaEnum::fromType<QPalette::ColorGroup>().valueToKey(
static_cast<int>(
group)));
48 return QLatin1String(QMetaEnum::fromType<QGtk3Interface::QGtkColorSource>().valueToKey(
static_cast<int>(
source)));
53 return QLatin1String(QMetaEnum::fromType<QGtk3Interface::QGtkWidget>().valueToKey(
static_cast<int>(widgetType)));
58 return QLatin1String(QMetaEnum::fromType<Qt::ColorScheme>().valueToKey(
static_cast<int>(
app)));
61#define CONVERT(type, key, def)\
63 const int intVal = QMetaEnum::fromType<type>().keyToValue(key.toLatin1().constData(), &ok);\
64 return ok ? static_cast<type>(intVal) : type::def
80 return GTK_STATE_FLAG_NORMAL;
81 return static_cast<GtkStateFlags
>(
i);
106 return QLatin1String(QMetaEnum::fromType<QGtk3Storage::SourceType>().valueToKey(
static_cast<int>(sourceType)));
137 qWarning() <<
"Unable to serialize Json document.";
157 brushMaps.
value(role).insert(brushIterator.key(), brushIterator.value());
160 newMap.
insert(brushIterator.key(), brushIterator.value());
161 brushMaps.
insert(role, newMap);
166 for (
auto brushMapIterator = brushMaps.
constBegin();
167 brushMapIterator != brushMaps.
constEnd(); ++brushMapIterator) {
182 switch (
s.sourceType) {
219 brushArray.
insert(brushIndex, brushObject);
243 qWarning(lcQGtk3Interface) <<
"Unable to parse Json document from" <<
fileName
249 qInfo() <<
"GTK mapping successfully imported from" <<
fileName;
259#define GETSTR(obj, key)\
260 if (!obj.contains(key)) {\
261 qCInfo(lcQGtk3Interface) << key << "missing for palette" << paletteName\
262 << ", Brush" << colorRoleName;\
265 value = obj[key].toString()
267#define GETINT(obj, key, var) GETSTR(obj, key);\
268 if (!obj[key].isDouble()) {\
269 qCInfo(lcQGtk3Interface) << key << "type mismatch" << value\
270 << "is not an integer!"\
271 << "(Palette" << paletteName << "), Brush" << colorRoleName;\
274 const int var = obj[key].toInt()
279 qCInfo(lcQGtk3Interface) <<
"Document does not contain Palettes.";
284 for (
const QString &paletteName : paletteList) {
286 const int intVal = QMetaEnum::fromType<QPlatformTheme::Palette>().keyToValue(paletteName
287 .toLatin1().constData(), &
ok);
289 qCInfo(lcQGtk3Interface) <<
"Invalid Palette name:" << paletteName;
294 if (brushList.isEmpty()) {
295 qCInfo(lcQGtk3Interface) <<
"Palette" << paletteName <<
"does not contain brushes";
302 for (
const QString &colorRoleName : colorRoles) {
303 const int intVal = QMetaEnum::fromType<QPalette::ColorRole>().keyToValue(colorRoleName
304 .toLatin1().constData(), &
ok);
306 qCInfo(lcQGtk3Interface) <<
"Palette" << paletteName
307 <<
"contains invalid color role" << colorRoleName;
311 const QJsonArray &brushArray = paletteObject[colorRoleName].toArray();
312 for (
int brushIndex = 0; brushIndex < brushArray.
size(); ++brushIndex) {
315 qCInfo(lcQGtk3Interface) <<
"Brush specification missing at for palette"
316 << paletteName <<
", Brush" << colorRoleName;
331 qCInfo(lcQGtk3Interface) <<
"Source specification missing for palette" << paletteName
332 <<
"Brush" << colorRoleName;
337 switch (sourceType) {
353 qCInfo(lcQGtk3Interface) <<
"Fixed brush specification missing for palette" << paletteName
354 <<
"Brush" << colorRoleName;
362 if (!
color.isValid()) {
363 qCInfo(lcQGtk3Interface) <<
"Color" <<
value <<
"can't be parsed for:" << paletteName
364 <<
"Brush" << colorRoleName;
391 qInfo(lcQGtk3Interface) <<
"Invalid source type for palette" << paletteName
392 <<
"Brush." << colorRoleName;
The QColor class provides colors based on RGB, HSV or CMYK values.
static QColor fromString(QAnyStringView name) noexcept
void close() override
Calls QFileDevice::flush() and closes the file.
bool open(OpenMode flags) override
Opens the file using OpenMode mode, returning true if successful; otherwise false.
bool contains(const Key &key) const
const_iterator constBegin() const
const_iterator constEnd() const
std::pair< iterator, bool > insert(const Key &key, const T &value)
T value(const Key &key, const T &defaultValue) const
static const QLatin1String fromGtkState(GtkStateFlags state)
Returns.
static int toGtkState(const QString &state)
Converts a string into the GtkStateFlags enum.
static QLatin1String fromColorGroup(QPalette::ColorGroup group)
static QLatin1String fromWidgetType(QGtk3Interface::QGtkWidget widgetType)
static QLatin1String fromColorRole(QPalette::ColorRole role)
static constexpr QLatin1StringView ceColorGroup
static constexpr QLatin1StringView ceGreen
static constexpr QLatin1StringView ceBrush
static constexpr QLatin1StringView ceWidth
static GtkStateFlags toGtkState(const QString &type)
static QPalette::ColorRole toColorRole(const QString &role)
static constexpr QLatin1StringView ceBlue
static QPalette::ColorGroup toColorGroup(const QString &group)
static constexpr QLatin1StringView ceHeight
static constexpr QLatin1StringView ceColorScheme
static bool save(const QGtk3Storage::PaletteMap &map, const QString &fileName, QJsonDocument::JsonFormat format=QJsonDocument::Indented)
static constexpr QLatin1StringView ceColor
static constexpr QLatin1StringView ceGtkWidget
static constexpr QLatin1StringView ceLighter
static constexpr QLatin1StringView ceSourceType
static bool load(QGtk3Storage::PaletteMap &map, const QString &fileName)
static constexpr QLatin1StringView ceData
static QLatin1String fromGdkSource(QGtk3Interface::QGtkColorSource source)
static QGtk3Interface::QGtkColorSource toGdkSource(const QString &source)
static constexpr QLatin1StringView cePalettes
static QLatin1String fromSourceType(QGtk3Storage::SourceType sourceType)
static QLatin1String fromPalette(QPlatformTheme::Palette palette)
static constexpr QLatin1StringView ceRed
static QGtk3Storage::SourceType toSourceType(const QString &sourceType)
static constexpr QLatin1StringView ceColorRole
static QPlatformTheme::Palette toPalette(const QString &palette)
static QGtk3Interface::QGtkWidget toWidgetType(const QString &widgetType)
static Qt::ColorScheme toColorScheme(const QString &colorScheme)
static QLatin1String fromColorScheme(Qt::ColorScheme colorScheme)
static QLatin1String fromGtkState(GtkStateFlags type)
static constexpr QLatin1StringView ceGdkSource
static constexpr QLatin1StringView ceGtkState
SourceType
This enum represents the type of a color source.
QByteArray readAll()
Reads all remaining data from the device, and returns it as a byte array.
qint64 write(const char *data, qint64 len)
Writes at most maxSize bytes of data from data to the device.
\inmodule QtCore\reentrant
void insert(qsizetype i, const QJsonValue &value)
Inserts value at index position i in the array.
qsizetype size() const
Returns the number of values stored in the array.
QJsonValue at(qsizetype i) const
Returns a QJsonValue representing the value for index i.
\inmodule QtCore\reentrant
QByteArray toJson(JsonFormat format=Indented) const
QJsonObject object() const
Returns the QJsonObject contained in the document.
bool isEmpty() const
Returns true if the document doesn't contain any data.
static QJsonDocument fromJson(const QByteArray &json, QJsonParseError *error=nullptr)
Parses json as a UTF-8 encoded JSON document, and creates a QJsonDocument from it.
\inmodule QtCore\reentrant
QStringList keys() const
Returns a list of all keys in this object.
iterator insert(const QString &key, const QJsonValue &value)
Inserts a new item with the key key and a value of value.
bool contains(const QString &key) const
Returns true if the object contains key key.
bool isEmpty() const
Returns true if the object is empty.
QJsonObject toObject() const
This is an overloaded member function, provided for convenience. It differs from the above function o...
iterator insert(const Key &key, const T &value)
const_iterator constBegin() const
const_iterator constEnd() const
ColorGroup
\value Disabled \value Active \value Inactive \value Normal synonym for Active
Returns a copy of the pixmap that is transformed using the given transformation transform and transfo...
\macro QT_RESTRICTED_CAST_FROM_ASCII
QMap< QString, QString > map
[6]
Combined button and popup list for selecting options.
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
#define GETINT(obj, key, var)
QColor toColor(const QStringView &color)
QLatin1String fromColor(const QColor &color)
#define qCInfo(category,...)
#define qCWarning(category,...)
GLint GLsizei GLsizei height
GLdouble GLdouble GLdouble GLdouble top
GLint GLsizei GLsizei GLenum format
GLsizei GLsizei GLchar * source
QLatin1StringView QLatin1String
QApplication app(argc, argv)
[0]
QPalette::ColorGroup colorGroup
Qt::ColorScheme colorScheme
\inmodule QtCore\reentrant
QString errorString() const
\variable QJsonParseError::error