18#include <klocalizedstring.h>
43 int maxDim = qMax(rc.width(), rc.height());
47 const qreal margin = 0.05;
49 QImage image(size, size, QImage::Format_ARGB32_Premultiplied);
50 qreal symbolScale = (qreal)(size*(1.0 - 2*margin))/maxDim;
52 gc.setRenderHint(QPainter::Antialiasing,
true);
58 gc.translate(size*margin, size*margin);
59 gc.scale(symbolScale, symbolScale);
60 gc.translate(-rc.x(), -rc.y());
62 gc.translate((maxDim - rc.width())/2.0, (maxDim - rc.height())/2.0);
110 qDeleteAll(
d->symbols);
115 Q_UNUSED(resourcesInterface);
117 if (!dev->isOpen()) {
118 dev->open(QIODevice::ReadOnly);
121 d->data = dev->readAll();
134 <<
" In line: " << errorLine <<
", column: " << errorColumn << Qt::endl
135 <<
" Error message: " << errorMsg << Qt::endl;
136 errKrita << i18n(
"Parsing error in the main document at line %1, column %2\nError message: %3"
137 , errorLine , errorColumn , errorMsg);
146 qDeleteAll(parser.
parseSvg(doc.documentElement(), &fragmentSize));
156 if (
d->title.isEmpty()) {
162 if (
d->symbols.size() < 1) {
173 dev->open(QIODevice::WriteOnly);
181 return QString(
".svg");
191 return d->description;
QList< QString > QStringList
static QString generateHash(const QString &filename)
generateHash reads the given file and generates a hex-encoded md5sum for the file.
QRectF boundingRect() const override
a group's boundingRect
static void renderSingleShape(KoShape *shape, QPainter &painter)
renderSingleShape renders a shape on painter. This method includes all the needed steps for painting ...
~KoSvgSymbolCollectionResource() override
KoResourceSP clone() const override
KoSvgSymbolCollectionResource()
Create an empty color set.
QStringList subjects() const
bool loadFromDevice(QIODevice *dev, KisResourcesInterfaceSP resourcesInterface) override
QString defaultFileExtension() const override
QVector< KoSvgSymbol * > symbols() const
QString description() const
const QScopedPointer< Private > d
bool saveToDevice(QIODevice *dev) const override
QStringList permits() const
static QDomDocument createDocumentFromSvg(QIODevice *device, QString *errorMsg=0, int *errorLine=0, int *errorColumn=0)
QVector< KoSvgSymbol * > takeSymbols()
QString documentTitle() const
QList< KoShape * > parseSvg(const QDomElement &e, QSizeF *fragmentSize=0)
Parses a svg fragment, returning the list of top level child shapes.
void setResolution(const QRectF boundsInPixels, qreal pixelsPerInch)
QString documentDescription() const
#define KIS_SAFE_ASSERT_RECOVER_RETURN_VALUE(cond, val)
QSharedPointer< KoResource > KoResourceSP
void setValid(bool valid)
void setName(const QString &name)
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 setImage(const QImage &image)
QVector< KoSvgSymbol * > symbols