Krita Source Code Documentation
Loading...
Searching...
No Matches
ImageShapeFactory.cpp
Go to the documentation of this file.
1/* This file is part of the KDE project
2 *
3 * SPDX-FileCopyrightText: 2009 Inge Wallin <inge@lysator.liu.se>
4 *
5 * SPDX-License-Identifier: LGPL-2.0-or-later
6 */
7
8// Own
9#include "ImageShapeFactory.h"
10
11// ImageShape
12#include "ImageShape.h"
13//#include "ImageShapeConfigWidget.h"
14
15// Calligra
16#include <KoXmlNS.h>
18#include <KoIcon.h>
19#include <KoProperties.h>
20#include <kis_assert.h>
21
22// KDE
23#include <klocalizedstring.h>
24
26 : KoShapeFactoryBase(ImageShapeId, i18n("Image shape"))
27{
28 setToolTip(i18n("A shape that shows an image (PNG/JPG/TIFF)"));
29 setIconName(koIconNameCStrNeededWithSubs("a generic image icon", "x-shape-vectorimage", "application-x-wmf"));
30
31 QList<QPair<QString, QStringList> > elementNamesList;
32 elementNamesList.append(qMakePair(QString(KoXmlNS::draw), QStringList("image")));
33 elementNamesList.append(qMakePair(QString(KoXmlNS::svg), QStringList("image")));
34 setXmlElements(elementNamesList);
36}
37
39{
40 ImageShape *shape = new ImageShape();
42
43 return shape;
44}
45
46
48{
49 ImageShape *shape = new ImageShape();
51
52 QVariant var = params->value("image");
53
54 KIS_SAFE_ASSERT_RECOVER(var.type() == QVariant::Image);
55 shape->setImage(var.value<QImage>());
56
57 var = params->value("viewboxTransform");
58 if (var.type() == QVariant::Transform) {
59 shape->setViewBoxTransform(var.value<QTransform>());
60 }
61 return shape;
62}
63
64bool ImageShapeFactory::supports(const QDomElement &e, KoShapeLoadingContext &context) const
65{
66 Q_UNUSED(context);
67 return e.localName() == "image" &&
68 (e.namespaceURI() == KoXmlNS::draw || e.namespaceURI() == KoXmlNS::svg);
69}
70
72{
74 //result.append(new ImageShapeConfigWidget());
75 return result;
76}
#define ImageShapeId
Definition ImageShape.h:15
QList< QString > QStringList
KoShape * createShape(const KoProperties *params, KoDocumentResourceManager *documentResources=0) const
createShape
bool supports(const QDomElement &e, KoShapeLoadingContext &context) const override
ImageShapeFactory()
constructor
QList< KoShapeConfigWidgetBase * > createShapeOptionPanels() override
KoShape * createDefaultShape(KoDocumentResourceManager *documentResources=0) const override
QVariant value(const QString &key) const
void setToolTip(const QString &tooltip)
void setLoadingPriority(int priority)
void setIconName(const char *iconName)
void setXmlElements(const QList< QPair< QString, QStringList > > &elementNamesList)
void setShapeId(const QString &id)
Definition KoShape.cpp:1062
static const QString svg
Definition KoXmlNS.h:39
static const QString draw
Definition KoXmlNS.h:27
#define KIS_SAFE_ASSERT_RECOVER(cond)
Definition kis_assert.h:126
#define koIconNameCStrNeededWithSubs(comment, neededName, substituteName)
Definition kis_icon.h:36
void setImage(const QImage &img)
void setViewBoxTransform(const QTransform &tf)