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

Resource for storing of workspaces. More...

#include <kis_workspace_resource.h>

+ Inheritance diagram for KisWorkspaceResource:

Public Member Functions

KoResourceSP clone () const override
 
QString defaultFileExtension () const override
 
QByteArray dockerState ()
 
 KisWorkspaceResource (const KisWorkspaceResource &rhs)
 
 KisWorkspaceResource (const QString &filename)
 
bool loadFromDevice (QIODevice *dev, KisResourcesInterfaceSP resourcesInterface) override
 
KisWorkspaceResourceoperator= (const KisWorkspaceResource &rhs)=delete
 
QPair< QString, QString > resourceType () const override
 
bool saveToDevice (QIODevice *dev) const override
 
void setDockerState (const QByteArray &state)
 
 ~KisWorkspaceResource () override
 
- Public Member Functions inherited from KoResource
bool active () const
 
void addMetaData (QString key, QVariant value)
 store the given key, value pair in the resource
 
virtual void clearSideLoadedResources ()
 
virtual QList< KoResourceLoadResultembeddedResources (KisResourcesInterfaceSP globalResourcesInterface) const
 
QString filename () const
 
QImage image () const
 
bool isDirty () const
 
virtual bool isEphemeral () const
 
virtual bool isSerializable () const
 
 KoResource ()
 
 KoResource (const KoResource &rhs)
 
 KoResource (const QString &filename)
 
virtual QList< KoResourceLoadResultlinkedResources (KisResourcesInterfaceSP globalResourcesInterface) const
 
bool load (KisResourcesInterfaceSP resourcesInterface)
 
QString md5Sum (bool generateIfEmpty=true) const
 
QMap< QString, QVariant > metadata () const
 get a map with all the metadata
 
virtual QString name () const
 
KoResourceoperator= (const KoResource &rhs)=delete
 
bool permanent () const
 
virtual QList< int > requiredCanvasResources () const
 
QList< KoResourceLoadResultrequiredResources (KisResourcesInterfaceSP globalResourcesInterface) const
 
int resourceId () const
 
bool save ()
 
void setActive (bool active)
 
void setDirty (bool value)
 Mark the preset as modified but not saved.
 
void setFilename (const QString &filename)
 
void setImage (const QImage &image)
 
void setMD5Sum (const QString &md5sum)
 Set the md5sum of this resource. It must be in hex-encoded string format.
 
void setName (const QString &name)
 
void setPermanent (bool permanent)
 
void setResourceId (int id)
 
void setStorageLocation (const QString &location)
 
void setValid (bool valid)
 
void setVersion (int version)
 
virtual QList< KoResourceLoadResultsideLoadedResources (KisResourcesInterfaceSP globalResourcesInterface) const
 
KoResourceSignature signature () const
 
QString storageLocation () const
 
QList< KoResourceLoadResulttakeSideLoadedResources (KisResourcesInterfaceSP globalResourcesInterface)
 
virtual QImage thumbnail () const
 thumbnail the thumbnail image to use in resource selectors
 
virtual QString thumbnailPath () const
 thumbnailPath returns the path to a separate thumbnail image, outside the actual resource file itself. If the path is relative, it is supposed start in the same location as the resource itself. If it's absolute, that is, it starts with "/", it is from the root of the storage.
 
virtual void updateThumbnail ()
 updateThumbnail updates the thumbnail for this resource. Reimplement if your thumbnail is something else than the image set with setImage.
 
bool valid () const
 
int version () const
 Get the version of the resource.
 
virtual ~KoResource ()
 
- Public Member Functions inherited from Private
 Private (KisCanvas2 *c)
 
- Public Member Functions inherited from KisPropertiesConfiguration
void clearProperties ()
 Clear the map of properties.
 
virtual bool compareTo (const KisPropertiesConfiguration *rhs) const
 
virtual void dump () const
 
void fromXML (const QDomElement &) override
 
bool fromXML (const QString &xml, bool clear=true) override
 
bool getBool (const QString &name, bool def=false) const
 
KoColor getColor (const QString &name, const KoColor &color=KoColor()) const
 getColor fetch the given property as a KoColor.
 
KisCubicCurve getCubicCurve (const QString &name, const KisCubicCurve &curve=KisCubicCurve()) const
 
double getDouble (const QString &name, double def=0.0) const
 
float getFloat (const QString &name, float def=0.0) const
 
int getInt (const QString &name, int def=0) const
 
void getPrefixedProperties (const QString &prefix, KisPropertiesConfiguration *config) const
 
void getPrefixedProperties (const QString &prefix, KisPropertiesConfigurationSP config) const
 
virtual QMap< QString, QVariant > getProperties () const
 
virtual QList< QString > getPropertiesKeys () const
 
virtual QVariant getProperty (const QString &name) const
 
virtual bool getProperty (const QString &name, QVariant &value) const
 
QString getPropertyLazy (const QString &name, const char *defaultValue) const
 
QStringList getPropertyLazy (const QString &name, const QStringList &defaultValue) const
 
template<typename T >
getPropertyLazy (const QString &name, const T &defaultValue) const
 
QString getString (const QString &name, const QString &def=QString()) const
 
QStringList getStringList (const QString &name, const QStringList &defaultValue=QStringList()) const
 
virtual bool hasProperty (const QString &name) const
 
 KisPropertiesConfiguration ()
 
 KisPropertiesConfiguration (const KisPropertiesConfiguration &rhs)
 
KisPropertiesConfigurationoperator= (const KisPropertiesConfiguration &rhs)
 
void removeProperty (const QString &name)
 
void setPrefixedProperties (const QString &prefix, const KisPropertiesConfiguration *config)
 
void setPrefixedProperties (const QString &prefix, const KisPropertiesConfigurationSP config)
 
void setProperty (const QString &name, const QStringList &value)
 
virtual void setProperty (const QString &name, const QVariant &value)
 
void setPropertyNotSaved (const QString &name)
 Marks a property that should not be saved by toXML.
 
QString toXML () const override
 
void toXML (QDomDocument &, QDomElement &) const override
 
 ~KisPropertiesConfiguration () override
 
- Public Member Functions inherited from KisSerializableConfiguration
 KisSerializableConfiguration ()
 
 KisSerializableConfiguration (const KisSerializableConfiguration &rhs)
 
virtual ~KisSerializableConfiguration ()
 
- Public Member Functions inherited from KisShared
bool deref ()
 
bool ref ()
 
int refCount ()
 
QAtomicInt * sharedWeakReference ()
 

Private Attributes

QByteArray m_dockerState
 

Additional Inherited Members

- Static Public Member Functions inherited from KisPropertiesConfiguration
static QString escapeString (const QString &string)
 
static QString extractedPrefixKey ()
 
static QString unescapeString (const QString &string)
 
- Public Attributes inherited from KoResource
bool active {true}
 
QString filename
 
QImage image
 
QString md5sum
 
QMap< QString, QVariant > metadata
 
bool modified {false}
 
QString name
 
bool permanent {false}
 
int resourceId {-1}
 
QString storageLocation
 
bool valid {false}
 
int version {-1}
 
- Public Attributes inherited from Private
KisCanvas2canvas
 
int displayedFrame
 
int intendedFrame
 
- Public Attributes inherited from KisPropertiesConfiguration
QSet< QString > notSavedProperties
 
QMap< QString, QVariant > properties
 
- Protected Member Functions inherited from KisShared
 KisShared ()
 
 ~KisShared ()
 

Detailed Description

Resource for storing of workspaces.

Definition at line 15 of file kis_workspace_resource.h.

Constructor & Destructor Documentation

◆ KisWorkspaceResource() [1/2]

KisWorkspaceResource::KisWorkspaceResource ( const QString & filename)

Definition at line 18 of file kis_workspace_resource.cpp.

19{
20}
QString filename

◆ ~KisWorkspaceResource()

KisWorkspaceResource::~KisWorkspaceResource ( )
override

Definition at line 22 of file kis_workspace_resource.cpp.

23{
24}

◆ KisWorkspaceResource() [2/2]

KisWorkspaceResource::KisWorkspaceResource ( const KisWorkspaceResource & rhs)

Member Function Documentation

◆ clone()

KoResourceSP KisWorkspaceResource::clone ( ) const
overridevirtual

Implements KoResource.

Definition at line 33 of file kis_workspace_resource.cpp.

34{
35 return KoResourceSP(new KisWorkspaceResource(*this));
36}
KisWorkspaceResource(const QString &filename)
QSharedPointer< KoResource > KoResourceSP

References KisWorkspaceResource().

◆ defaultFileExtension()

QString KisWorkspaceResource::defaultFileExtension ( ) const
overridevirtual
Returns
the default file extension which should be used when saving the resource

Reimplemented from KoResource.

Definition at line 107 of file kis_workspace_resource.cpp.

108{
109 return QString(".kws");
110}

◆ dockerState()

QByteArray KisWorkspaceResource::dockerState ( )

Definition at line 117 of file kis_workspace_resource.cpp.

118{
119 return m_dockerState;
120}

References m_dockerState.

◆ loadFromDevice()

bool KisWorkspaceResource::loadFromDevice ( QIODevice * dev,
KisResourcesInterfaceSP resourcesInterface )
overridevirtual

Implements KoResource.

Definition at line 73 of file kis_workspace_resource.cpp.

74{
75 Q_UNUSED(resourcesInterface);
76
77 QDomDocument doc;
78 if (!doc.setContent(dev)) {
79 return false;
80 }
81
82 QDomElement element = doc.documentElement();
83 setName(element.attribute("name"));
84
85 QDomElement state = element.firstChildElement("state");
86
87 if (!state.isNull()) {
88 m_dockerState = QByteArray::fromBase64(state.text().toLatin1());
89 }
90
91 QDomElement settings = element.firstChildElement("settings");
92 if (!settings.isNull()) {
94 }
95
96 QDomElement thumb = element.firstChildElement("image");
97 if (!thumb.isNull()) {
98 QImage img;
99 img.loadFromData(QByteArray::fromBase64(thumb.text().toLatin1()));
100 this->setImage(img);
101 }
102
103 setValid(true);
104 return true;
105}
bool fromXML(const QString &xml, bool clear=true) override
void setValid(bool valid)
void setName(const QString &name)
void setImage(const QImage &image)

References KisPropertiesConfiguration::fromXML(), m_dockerState, KoResource::setImage(), KoResource::setName(), and KoResource::setValid().

◆ operator=()

KisWorkspaceResource & KisWorkspaceResource::operator= ( const KisWorkspaceResource & rhs)
delete

◆ resourceType()

QPair< QString, QString > KisWorkspaceResource::resourceType ( ) const
inlineoverridevirtual
Returns
the resource type

Implements KoResource.

Definition at line 28 of file kis_workspace_resource.h.

29 {
30 return QPair<QString, QString>(ResourceType::Workspaces, "");
31 }
const QString Workspaces

References ResourceType::Workspaces.

◆ saveToDevice()

bool KisWorkspaceResource::saveToDevice ( QIODevice * dev) const
overridevirtual

Reimplemented from KoResource.

Definition at line 38 of file kis_workspace_resource.cpp.

39{
40 QDomDocument doc;
41 QDomElement root = doc.createElement("Workspace");
42 root.setAttribute("name", name() );
43 root.setAttribute("version", WORKSPACE_VERSION);
44 QDomElement state = doc.createElement("state");
45 state.appendChild(doc.createCDATASection(m_dockerState.toBase64()));
46 root.appendChild(state);
47
48 // Save KisPropertiesConfiguration settings
49 QDomElement settings = doc.createElement("settings");
51 root.appendChild(settings);
52
53 if (!image().isNull()) {
54 QDomElement thumb = doc.createElement("image");
55 QBuffer buffer;
56 buffer.open(QIODevice::WriteOnly);
57 image().save(&buffer, "PNG");
58 buffer.close();
59 thumb.appendChild(doc.createCDATASection(buffer.data().toBase64()));
60 root.appendChild(thumb);
61 }
62
63 doc.appendChild(root);
64
65 QTextStream textStream(dev);
67 doc.save(textStream, 4);
68
69 return true;
70
71}
#define WORKSPACE_VERSION
void setUtf8OnStream(QTextStream &stream)
QImage image
QString name

References KoResource::image, m_dockerState, KoResource::name, KisPortingUtils::setUtf8OnStream(), KisPropertiesConfiguration::toXML(), and WORKSPACE_VERSION.

◆ setDockerState()

void KisWorkspaceResource::setDockerState ( const QByteArray & state)

Definition at line 112 of file kis_workspace_resource.cpp.

113{
114 m_dockerState = state;
115}

References m_dockerState.

Member Data Documentation

◆ m_dockerState

QByteArray KisWorkspaceResource::m_dockerState
private

Definition at line 37 of file kis_workspace_resource.h.


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