24 qRegisterMetaType<KoResourceSP>(
"KoResourceSP");
32 bool permanent {
false};
33 bool modified {
false};
69 qWarning() <<
"Resource file doesn't exist: " <<
filename();
73 if (file.size() == 0) {
74 qWarning() <<
"Resource file is empty: " <<
filename();
78 if (!file.open(QIODevice::ReadOnly)) {
79 qWarning() <<
"Cannot open resource file for reading" <<
filename();
86 qWarning() <<
"Could not load resource file" <<
filename();
96 if (
filename().isEmpty())
return false;
100 if (!file.open(QIODevice::WriteOnly | QIODevice::Truncate)) {
146 if (
d->md5sum.isEmpty() && generateIfEmpty) {
151 buf.open(QFile::WriteOnly);
166 Q_ASSERT(!
md5sum.isEmpty());
178 d->filename = QFileInfo(
filename).fileName();
229 return d->resourceId;
242 Q_UNUSED(globalResourcesInterface);
248 Q_UNUSED(globalResourcesInterface);
261 Q_UNUSED(globalResourcesInterface);
276 return d->storageLocation;
300 d->metadata.insert(key,
value);
340 d->storageLocation = location;
float value(const T *src, size_t ch)
KIS_DECLARE_STATIC_INITIALIZER
static QString generateHash(const QString &filename)
generateHash reads the given file and generates a hex-encoded md5sum for the file.
A simple wrapper object for the main information about the resource.
#define KIS_SAFE_ASSERT_RECOVER_RETURN_VALUE(cond, val)
#define KIS_SAFE_ASSERT_RECOVER_RETURN(cond)
#define KIS_SAFE_ASSERT_RECOVER_NOOP(cond)
QList< KoResourceLoadResult > takeSideLoadedResources(KisResourcesInterfaceSP globalResourcesInterface)
void setValid(bool valid)
QList< KoResourceLoadResult > requiredResources(KisResourcesInterfaceSP globalResourcesInterface) const
virtual QList< KoResourceLoadResult > embeddedResources(KisResourcesInterfaceSP globalResourcesInterface) const
void setName(const QString &name)
virtual QPair< QString, QString > resourceType() const =0
virtual bool isSerializable() const
virtual void clearSideLoadedResources()
virtual QList< int > requiredCanvasResources() const
void addMetaData(QString key, QVariant value)
store the given key, value pair in the resource
void setMD5Sum(const QString &md5sum)
Set the md5sum of this resource. It must be in hex-encoded string format.
void setFilename(const QString &filename)
void setPermanent(bool permanent)
virtual QString defaultFileExtension() const
virtual QString thumbnailPath() const
thumbnailPath returns the path to a separate thumbnail image, outside the actual resource file itself...
void setStorageLocation(const QString &location)
void setResourceId(int id)
void setDirty(bool value)
Mark the preset as modified but not saved.
virtual bool saveToDevice(QIODevice *dev) const
void setImage(const QImage &image)
virtual bool isEphemeral() const
QString md5Sum(bool generateIfEmpty=true) const
virtual void updateThumbnail()
updateThumbnail updates the thumbnail for this resource. Reimplement if your thumbnail is something e...
QMap< QString, QVariant > metadata
KoResourceSignature signature() const
void setActive(bool active)
virtual QImage thumbnail() const
thumbnail the thumbnail image to use in resource selectors
virtual bool loadFromDevice(QIODevice *dev, KisResourcesInterfaceSP resourcesInterface)=0
void setVersion(int version)
bool load(KisResourcesInterfaceSP resourcesInterface)
virtual QList< KoResourceLoadResult > sideLoadedResources(KisResourcesInterfaceSP globalResourcesInterface) const
virtual QList< KoResourceLoadResult > linkedResources(KisResourcesInterfaceSP globalResourcesInterface) const