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

Factory for ellipse shapes. More...

#include <EllipseShapeFactory.h>

+ Inheritance diagram for EllipseShapeFactory:

Public Member Functions

KoShapecreateDefaultShape (KoDocumentResourceManager *documentResources=0) const override
 
QList< KoShapeConfigWidgetBase * > createShapeOptionPanels () override
 
 EllipseShapeFactory ()
 constructor
 
bool supports (const QDomElement &e, KoShapeLoadingContext &context) const override
 
 ~EllipseShapeFactory () override
 
- Public Member Functions inherited from KoShapeFactoryBase
virtual KoShapecreateShape (const KoProperties *params, KoDocumentResourceManager *documentResources=0) const
 
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

Factory for ellipse shapes.

Definition at line 16 of file EllipseShapeFactory.h.

Constructor & Destructor Documentation

◆ EllipseShapeFactory()

EllipseShapeFactory::EllipseShapeFactory ( )

constructor

Definition at line 20 of file EllipseShapeFactory.cpp.

21 : KoShapeFactoryBase(EllipseShapeId, i18n("Ellipse"))
22{
23 setToolTip(i18n("An ellipse"));
24 setIconName(koIconNameCStr("ellipse-shape"));
25 setFamily("geometric");
27
28 QList<QPair<QString, QStringList> > elementNamesList;
29 elementNamesList.append(qMakePair(QString(KoXmlNS::draw), QStringList("circle")));
30 elementNamesList.append(qMakePair(QString(KoXmlNS::draw), QStringList("ellipse")));
31 elementNamesList.append(qMakePair(QString(KoXmlNS::svg), QStringList("circle")));
32 elementNamesList.append(qMakePair(QString(KoXmlNS::svg), QStringList("ellipse")));
33 elementNamesList.append(qMakePair(QString(KoXmlNS::svg), QStringList("sodipodi:arc")));
34 elementNamesList.append(qMakePair(QString(KoXmlNS::svg), QStringList("krita:arc")));
35 setXmlElements(elementNamesList);
36}
#define EllipseShapeId
QList< QString > QStringList
void setFamily(const QString &family)
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 koIconNameCStr(name)
Definition kis_icon.h:28

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

◆ ~EllipseShapeFactory()

EllipseShapeFactory::~EllipseShapeFactory ( )
inlineoverride

Definition at line 21 of file EllipseShapeFactory.h.

21{}

Member Function Documentation

◆ createDefaultShape()

KoShape * EllipseShapeFactory::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 EllipseShapeFactory.cpp.

39{
40 EllipseShape *ellipse = new EllipseShape();
41
42 ellipse->setStroke(toQShared(new KoShapeStroke(1.0)));
43 ellipse->setShapeId(KoPathShapeId);
44
45 QRadialGradient *gradient = new QRadialGradient(QPointF(0.5, 0.5), 0.5, QPointF(0.25, 0.25));
46 gradient->setCoordinateMode(QGradient::ObjectBoundingMode);
47 gradient->setColorAt(0.0, Qt::white);
48 gradient->setColorAt(1.0, Qt::green);
50
51 return ellipse;
52}
#define KoPathShapeId
Definition KoPathShape.h:20
A gradient shape background.
virtual void setStroke(KoShapeStrokeModelSP stroke)
Definition KoShape.cpp:1081
virtual void setBackground(QSharedPointer< KoShapeBackground > background)
Definition KoShape.cpp:918
void setShapeId(const QString &id)
Definition KoShape.cpp:1062
QSharedPointer< T > toQShared(T *ptr)

References KoPathShapeId, KoShape::setBackground(), KoShape::setShapeId(), KoShape::setStroke(), and toQShared().

◆ createShapeOptionPanels()

QList< KoShapeConfigWidgetBase * > EllipseShapeFactory::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 61 of file EllipseShapeFactory.cpp.

62{
64 panels.append(new EllipseShapeConfigWidget());
65 return panels;
66}

◆ supports()

bool EllipseShapeFactory::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 54 of file EllipseShapeFactory.cpp.

55{
56 Q_UNUSED(context);
57 return (e.localName() == "ellipse" || e.localName() == "circle")
58 && e.namespaceURI() == KoXmlNS::draw;
59}

References KoXmlNS::draw.


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