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

#include <ImageShapeFactory.h>

+ Inheritance diagram for ImageShapeFactory:

Public Member Functions

KoShapecreateDefaultShape (KoDocumentResourceManager *documentResources=0) const override
 
KoShapecreateShape (const KoProperties *params, KoDocumentResourceManager *documentResources=0) const
 createShape
 
QList< KoShapeConfigWidgetBase * > createShapeOptionPanels () override
 
 ImageShapeFactory ()
 constructor
 
bool supports (const QDomElement &e, KoShapeLoadingContext &context) const override
 
 ~ImageShapeFactory () override
 
- Public Member Functions inherited from KoShapeFactoryBase
QString family () const
 
bool hidden () const
 
QString iconName () const
 
QString id () const
 
 KoShapeFactoryBase (const QString &id, const QString &name, const QString &deferredPluginName=QString())
 
int loadingPriority () const
 lower prio means the shape is more generic and will be checked later
 
QString name () const
 
virtual void newDocumentResourceManager (KoDocumentResourceManager *manager) const
 
QList< QPair< QString, QStringList > > odfElements () const
 
 Private (const QString &_id, const QString &_name, const QString &_deferredPluginName)
 
QList< KoShapeTemplatetemplates () const
 
QString toolTip () const
 
 ~KoShapeFactoryBase () override
 
 ~Private ()
 

Additional Inherited Members

- Public Attributes inherited from KoShapeFactoryBase
KoDeferredShapeFactoryBasedeferredFactory
 
QString deferredPluginName
 
QString family
 
bool hidden
 
QString iconName
 
const QString id
 
int loadingPriority
 
const QString name
 
QMutex pluginLoadingMutex
 
QList< QPointer< KoDocumentResourceManager > > resourceManagers
 
QList< KoShapeTemplatetemplates
 
QString tooltip
 
QList< QPair< QString, QStringList > > xmlElements
 
- Protected Member Functions inherited from KoShapeFactoryBase
void addTemplate (const KoShapeTemplate &params)
 
void setFamily (const QString &family)
 
void setHidden (bool hidden)
 
void setIconName (const char *iconName)
 
void setLoadingPriority (int priority)
 
void setToolTip (const QString &tooltip)
 
void setXmlElementNames (const QString &nameSpace, const QStringList &elementNames)
 
void setXmlElements (const QList< QPair< QString, QStringList > > &elementNamesList)
 

Detailed Description

Definition at line 16 of file ImageShapeFactory.h.

Constructor & Destructor Documentation

◆ ImageShapeFactory()

ImageShapeFactory::ImageShapeFactory ( )

constructor

Definition at line 25 of file ImageShapeFactory.cpp.

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}
#define ImageShapeId
Definition ImageShape.h:15
QList< QString > QStringList
void setToolTip(const QString &tooltip)
void setLoadingPriority(int priority)
void setIconName(const char *iconName)
void setXmlElements(const QList< QPair< QString, QStringList > > &elementNamesList)
KoShapeFactoryBase(const QString &id, const QString &name, const QString &deferredPluginName=QString())
static const QString svg
Definition KoXmlNS.h:39
static const QString draw
Definition KoXmlNS.h:27
#define koIconNameCStrNeededWithSubs(comment, neededName, substituteName)
Definition kis_icon.h:36

References KoXmlNS::draw, koIconNameCStrNeededWithSubs, KoShapeFactoryBase::setIconName(), KoShapeFactoryBase::setLoadingPriority(), KoShapeFactoryBase::setToolTip(), KoShapeFactoryBase::setXmlElements(), and KoXmlNS::svg.

◆ ~ImageShapeFactory()

ImageShapeFactory::~ImageShapeFactory ( )
inlineoverride

Definition at line 22 of file ImageShapeFactory.h.

22{}

Member Function Documentation

◆ createDefaultShape()

KoShape * ImageShapeFactory::createDefaultShape ( KoDocumentResourceManager * documentResources = 0) const
overridevirtual

This method should be implemented by factories to create a shape that the user gets when doing a base insert. For example from a script. The created shape should have its values set to good defaults that the user can then adjust further if needed. Including the KoShape:setShapeId(), with the Id from this factory The default shape position is not relevant, it will be moved by the caller.

Parameters
documentResourcesthe resources manager that has all the document wide resources which can be used to create the object.
Returns
a new shape
See also
createShape() newDocumentResourceManager()

Reimplemented from KoShapeFactoryBase.

Definition at line 38 of file ImageShapeFactory.cpp.

39{
40 ImageShape *shape = new ImageShape();
42
43 return shape;
44}
void setShapeId(const QString &id)
Definition KoShape.cpp:1062

References ImageShapeId, and KoShape::setShapeId().

◆ createShape()

KoShape * ImageShapeFactory::createShape ( const KoProperties * params,
KoDocumentResourceManager * documentResources = 0 ) const
virtual

createShape

Parameters
paramsThe parameters. Will look at keys...
  • "image" and retrieve as a QImage to set on the shape.
  • "viewboxTransform" and retrieve as a QTransform to set on the shape.
documentResources– unused.
Returns
ImageShape

Reimplemented from KoShapeFactoryBase.

Definition at line 47 of file ImageShapeFactory.cpp.

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}
QVariant value(const QString &key) const
#define KIS_SAFE_ASSERT_RECOVER(cond)
Definition kis_assert.h:126
void setImage(const QImage &img)
void setViewBoxTransform(const QTransform &tf)

References ImageShapeId, KIS_SAFE_ASSERT_RECOVER, ImageShape::setImage(), KoShape::setShapeId(), ImageShape::setViewBoxTransform(), and KoProperties::value().

◆ createShapeOptionPanels()

QList< KoShapeConfigWidgetBase * > ImageShapeFactory::createShapeOptionPanels ( )
overridevirtual

Create a list of option panels to show on creating a new shape. The shape type this factory creates may have general or specific setting panels that will be shown after inserting a new shape. The first item in the list will be shown as the first tab in the list of panels, behind all app specific panels. This is a separate list as set by setOptionPanels() and fetched by panelFactories()

Reimplemented from KoShapeFactoryBase.

Definition at line 71 of file ImageShapeFactory.cpp.

72{
74 //result.append(new ImageShapeConfigWidget());
75 return result;
76}

◆ supports()

bool ImageShapeFactory::supports ( const QDomElement & element,
KoShapeLoadingContext & context ) const
overridevirtual

returns true if this shapeFactory is able to load the ODF type started at argument element. ('draw:line' / 'draw:frame' / etc)

Implements KoShapeFactoryBase.

Definition at line 64 of file ImageShapeFactory.cpp.

65{
66 Q_UNUSED(context);
67 return e.localName() == "image" &&
68 (e.namespaceURI() == KoXmlNS::draw || e.namespaceURI() == KoXmlNS::svg);
69}

References KoXmlNS::draw, and KoXmlNS::svg.


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