|
Krita Source Code Documentation
|
#include <KoShapeFactoryBase.h>
Inheritance diagram for KoShapeFactoryBase:Public Member Functions | |
| virtual KoShape * | createDefaultShape (KoDocumentResourceManager *documentResources=0) const |
| virtual KoShape * | createShape (const KoProperties *params, KoDocumentResourceManager *documentResources=0) const |
| virtual QList< KoShapeConfigWidgetBase * > | createShapeOptionPanels () |
| 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) | |
| virtual bool | supports (const QDomElement &element, KoShapeLoadingContext &context) const =0 |
| QList< KoShapeTemplate > | templates () const |
| QString | toolTip () const |
| ~KoShapeFactoryBase () override | |
| ~Private () | |
Public Attributes | |
| KoDeferredShapeFactoryBase * | deferredFactory |
| QString | deferredPluginName |
| QString | family |
| bool | hidden |
| QString | iconName |
| const QString | id |
| int | loadingPriority |
| const QString | name |
| QMutex | pluginLoadingMutex |
| QList< QPointer< KoDocumentResourceManager > > | resourceManagers |
| QList< KoShapeTemplate > | templates |
| QString | tooltip |
| QList< QPair< QString, QStringList > > | xmlElements |
Protected Member Functions | |
| void | addTemplate (const KoShapeTemplate ¶ms) |
| 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) |
Private Slots | |
| void | pruneDocumentResourceManager (QObject *) |
| called whenever a document KoDocumentResourceManager is deleted | |
Private Member Functions | |
| void | getDeferredPlugin () |
Private Member Functions inherited from Private | |
| Private (KisCanvas2 *c) | |
Private Attributes | |
| Private *const | d |
Private Attributes inherited from Private | |
| KisCanvas2 * | canvas |
| int | displayedFrame |
| int | intendedFrame |
A factory for KoShape objects. The baseclass for all shape plugins. Each plugin that ships a KoShape should also ship a factory. That factory will extend this class and set variable data like a toolTip and icon in the constructor of that extending class.
An example usage would be:
After you created the factory you should create a plugin that can announce the factory to the KoShapeRegistry. See the KoPluginLoader as well.
Definition at line 31 of file KoShapeFactoryBase.cpp.
|
inline |
Definition at line 44 of file KoShapeFactoryBase.cpp.
References KoShapeTemplate::properties.
| KoShapeFactoryBase::KoShapeFactoryBase | ( | const QString & | id, |
| const QString & | name, | ||
| const QString & | deferredPluginName = QString() ) |
Create the new factory
| id | a string that will be used internally for referencing the shape |
| name | the user visible name of the shape this factory creates. |
Definition at line 66 of file KoShapeFactoryBase.cpp.
|
override |
|
protected |
Add a template with the properties of a specific type of shape this factory can generate using the createShape() method. The factory will take ownership of the properties object to which the member properties of params points to and destroy it only in its own destructor.
| params | the new template this factory knows to produce |
Definition at line 106 of file KoShapeFactoryBase.cpp.
References d, and KoShapeTemplate::id.
|
virtual |
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.
| documentResources | the resources manager that has all the document wide resources which can be used to create the object. |
Reimplemented in KoPathShapeFactory, KoSvgTextShapeFactory, KisShapeSelectionFactory, ImageShapeFactory, EllipseShapeFactory, EnhancedPathShapeFactory, RectangleShapeFactory, SpiralShapeFactory, StarShapeFactory, and KarbonCalligraphicShapeFactory.
Definition at line 170 of file KoShapeFactoryBase.cpp.
References d, and getDeferredPlugin().
|
virtual |
This method should be implemented by factories to create a shape based on a set of properties that are specifically made for this shape-type. This method should also set this factories shapeId on the shape using KoShape::setShapeId() The default implementation just ignores 'params' and calls createDefaultShape()
| params | the parameters to use when creating the shape |
| documentResources | the resources manager that has all the document wide resources which can be used to create the object. |
Reimplemented in ImageShapeFactory, KoSvgTextShapeFactory, EnhancedPathShapeFactory, RectangleShapeFactory, and StarShapeFactory.
Definition at line 182 of file KoShapeFactoryBase.cpp.
References createDefaultShape(), d, and getDeferredPlugin().
|
inlinevirtual |
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 in ImageShapeFactory, EllipseShapeFactory, RectangleShapeFactory, SpiralShapeFactory, and StarShapeFactory.
Definition at line 95 of file KoShapeFactoryBase.h.
| QString KoShapeFactoryBase::family | ( | ) | const |
return the non-visible name of the family the default shape belongs to.
|
private |
Definition at line 195 of file KoShapeFactoryBase.cpp.
References d, KoDeferredShapeFactoryBase::deferredPluginName(), KoJsonTrader::instance(), KoJsonTrader::Plugin::instance(), and KoJsonTrader::query().
| bool KoShapeFactoryBase::hidden | ( | ) | const |
The hidden boolean requests if the shape should be hidden in the shape selector or shown with all its templates. The default is false
| QString KoShapeFactoryBase::iconName | ( | ) | const |
return the basename of the icon for a selector of shapes
| QString KoShapeFactoryBase::id | ( | ) | const |
return the id for the shape this factory creates.
| int KoShapeFactoryBase::loadingPriority | ( | ) | const |
lower prio means the shape is more generic and will be checked later
| QString KoShapeFactoryBase::name | ( | ) | const |
return the user visible (and translated) name to be seen by the user.
|
virtual |
This method is called whenever there is a new document resource manager that is created. The factory may reimplement this in order to get existing resources or put factory specific resources in. In case the factory creates new resources it is advised to parent them to the manager (which is a QObject) for memory management purposes.
FIXME: this method is only used by Tables. We should refactor so it is no longer necessary.
NOTE: this actually is also used somehow to create the image collection for the picture shape?
NOTE: we store the documentmanagers in a list, and remove them from the list on delete.
| manager | the new manager |
Reimplemented in KoPathShapeFactory.
Definition at line 164 of file KoShapeFactoryBase.cpp.
References connect(), d, and pruneDocumentResourceManager().
| QList< QPair< QString, QStringList > > KoShapeFactoryBase::odfElements | ( | ) | const |
The list of namespaces to the supported elements the factory supports.
Definition at line 101 of file KoShapeFactoryBase.cpp.
References d.
|
inline |
Definition at line 34 of file KoShapeFactoryBase.cpp.
|
privateslot |
called whenever a document KoDocumentResourceManager is deleted
Definition at line 214 of file KoShapeFactoryBase.cpp.
References d.
|
protected |
Set the family name of the default shape
| family | the family name of the default shape this factory creates. for example "funny", "arrows", "geometrics". Use "" for default |
Definition at line 123 of file KoShapeFactoryBase.cpp.
|
protected |
|
protected |
Set an icon to be used in a selector of shapes
| iconName | the basename (without extension) of the icon |
Definition at line 118 of file KoShapeFactoryBase.cpp.
|
protected |
Set the loading priority for this icon; higher priority means the shape is more specific which means it will be earlier in the queue to try loading a particular odf element.
Definition at line 138 of file KoShapeFactoryBase.cpp.
References d.
|
protected |
Set the tooltip to be used for a selector of shapes
| tooltip | the tooltip |
Definition at line 113 of file KoShapeFactoryBase.cpp.
|
protected |
Set the namespace and element tags used for quick checking whether this shapefactory is able to create a shape from xml identified by this element name.
| nameSpace | the ODF name space (like urn:oasis:names:tc:opendocument:xmlns:text:1.0, take it from KoXmlNS.h) |
| elementNames | the name of the element itself, like "path" |
Definition at line 143 of file KoShapeFactoryBase.cpp.
References d.
|
protected |
Set the namespaces and according element tags used for quick checking whether this shapefactory is able to create a shape from xml identified by this element name.
| elementNamesList | containing a list of namespace (like urn:oasis:names:tc:opendocument:xmlns:text:1.0, take it from KoXmlNS.h) to a list of elementName of the element itself, like "path" |
Definition at line 149 of file KoShapeFactoryBase.cpp.
References d.
|
pure virtual |
returns true if this shapeFactory is able to load the ODF type started at argument element. ('draw:line' / 'draw:frame' / etc)
Implemented in KoSvgTextShapeFactory, KisShapeSelectionFactory, ImageShapeFactory, EllipseShapeFactory, EnhancedPathShapeFactory, RectangleShapeFactory, SpiralShapeFactory, StarShapeFactory, KarbonCalligraphicShapeFactory, and KoPathShapeFactory.
| QList< KoShapeTemplate > KoShapeFactoryBase::templates | ( | ) | const |
Return all the templates this factory knows about. Each template shows a different way to create a shape this factory is specialized in.
| QString KoShapeFactoryBase::toolTip | ( | ) | const |
return a translated tooltip Text for a selector of shapes
Definition at line 76 of file KoShapeFactoryBase.cpp.
References d.
|
private |
Definition at line 277 of file KoShapeFactoryBase.h.
| KoDeferredShapeFactoryBase* KoShapeFactoryBase::deferredFactory |
Definition at line 50 of file KoShapeFactoryBase.cpp.
| QString KoShapeFactoryBase::deferredPluginName |
Definition at line 52 of file KoShapeFactoryBase.cpp.
| QString KoShapeFactoryBase::family |
Definition at line 56 of file KoShapeFactoryBase.cpp.
| bool KoShapeFactoryBase::hidden |
Definition at line 61 of file KoShapeFactoryBase.cpp.
| QString KoShapeFactoryBase::iconName |
Definition at line 58 of file KoShapeFactoryBase.cpp.
| QString KoShapeFactoryBase::id |
Definition at line 54 of file KoShapeFactoryBase.cpp.
| int KoShapeFactoryBase::loadingPriority |
Definition at line 59 of file KoShapeFactoryBase.cpp.
| QString KoShapeFactoryBase::name |
Definition at line 55 of file KoShapeFactoryBase.cpp.
| QMutex KoShapeFactoryBase::pluginLoadingMutex |
Definition at line 51 of file KoShapeFactoryBase.cpp.
| QList<QPointer<KoDocumentResourceManager> > KoShapeFactoryBase::resourceManagers |
Definition at line 62 of file KoShapeFactoryBase.cpp.
| QList< KoShapeTemplate > KoShapeFactoryBase::templates |
Definition at line 53 of file KoShapeFactoryBase.cpp.
| QString KoShapeFactoryBase::tooltip |
Definition at line 57 of file KoShapeFactoryBase.cpp.
| QList<QPair<QString, QStringList> > KoShapeFactoryBase::xmlElements |
Definition at line 60 of file KoShapeFactoryBase.cpp.