Krita Source Code Documentation
Loading...
Searching...
No Matches
Preset Class Reference

The Preset class Preset is a resource object that stores brush preset data. More...

#include <Preset.h>

+ Inheritance diagram for Preset:

Classes

struct  Private
 

Public Member Functions

void fromXML (const QString &xml)
 fromXML convert the preset settings into a preset formatted xml.
 
 Preset (Resource *resource)
 
QString toXML () const
 toXML convert the preset settings into a preset formatted xml.
 
 ~Preset () override
 

Private Member Functions

KisPaintOpPresetSP paintOpPreset ()
 paintOpPreset
 

Private Attributes

Private *const d
 

Detailed Description

The Preset class Preset is a resource object that stores brush preset data.

An example for printing the current brush preset and all its settings:

from krita import *
view = Krita.instance().activeWindow().activeView()
preset = Preset(view.currentBrushPreset())
print ( preset.toXML() )

Definition at line 34 of file Preset.h.

Constructor & Destructor Documentation

◆ Preset()

Preset::Preset ( Resource * resource)

Definition at line 13 of file Preset.cpp.

13 : d(new Private()) {
14 d->preset = resource->resource().dynamicCast<KisPaintOpPreset>();
15}
Private *const d
Definition Preset.h:56
KoResourceSP resource() const
Definition Resource.cpp:116
KisPaintOpPresetSP preset
Definition Preset.cpp:10

References d, Preset::Private::preset, and Resource::resource().

◆ ~Preset()

Preset::~Preset ( )
override

Definition at line 17 of file Preset.cpp.

18{
19 delete d;
20}

References d.

Member Function Documentation

◆ fromXML()

void Preset::fromXML ( const QString & xml)

fromXML convert the preset settings into a preset formatted xml.

Parameters
xmlvalid xml preset string.

Definition at line 35 of file Preset.cpp.

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}

References d, and Preset::Private::preset.

◆ paintOpPreset()

KisPaintOpPresetSP Preset::paintOpPreset ( )
private

paintOpPreset

Returns
gives a KisPaintOpPreset object back

◆ toXML()

QString Preset::toXML ( ) const

toXML convert the preset settings into a preset formatted xml.

Returns
the xml in a string.

Definition at line 23 of file Preset.cpp.

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}

References d, and Preset::Private::preset.

Member Data Documentation

◆ d

Private* const Preset::d
private

Definition at line 56 of file Preset.h.


The documentation for this class was generated from the following files: