Krita

Preset.cpp
1/*
2 * SPDX-FileCopyrightText: 2017 Wolthera van Hövell tot Westerflier <griffinvalley@gmail.com>
3 *
4 * SPDX-License-Identifier: LGPL-2.0-or-later
5 */
6#include "Preset.h"
7#include <QDomDocument>
8
9struct Preset::Private {
10 KisPaintOpPresetSP preset {0};
11};
12
13Preset::Preset(Resource *resource): d(new Private()) {
14 d->preset = resource->resource().dynamicCast<KisPaintOpPreset>();
15}
16
17Preset::~Preset()
18{
19 delete d;
20}
21
22
24{
25 QDomDocument xmlDoc;
26 QDomElement root = xmlDoc.createElement("Preset");
27
28 d->preset->toXML(xmlDoc,root);
29
30 xmlDoc.appendChild(root);
31
32 return xmlDoc.toString();
33}
34
35void Preset::fromXML(const QString &xml)
36{
37 QDomDocument xmlDoc;
38
39 if (!xmlDoc.setContent(xml)) {
40 qWarning() << "XML string format is invalid!";
41 return;
42 }
43
44 d->preset->fromXML(xmlDoc.documentElement(),d->preset->resourcesInterface());
45 d->preset->setDirty(true);
46}
void fromXML(const QString &xml)
fromXML convert the preset settings into a preset formatted xml.
Definition Preset.cpp:35
QString toXML() const
toXML convert the preset settings into a preset formatted xml.
Definition Preset.cpp:23
A Resource represents a gradient, pattern, brush tip, brush preset, palette or workspace definition.
Definition Resource.h:31
QDomElement createElement(const QString &tagName)
QDomElement documentElement() const const
ParseResult setContent(QAnyStringView text, ParseOptions options)
QString toString(int indent) const const
QDomNode appendChild(const QDomNode &newChild)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 4 2024 16:35:00 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.