Krita Source Code Documentation
Loading...
Searching...
No Matches
KisPasteShapeStyleActionFactory Struct Reference

#include <KisPasteActionFactories.h>

+ Inheritance diagram for KisPasteShapeStyleActionFactory:

Public Member Functions

 KisPasteShapeStyleActionFactory ()
 
void run (KisViewManager *view) override
 
- Public Member Functions inherited from KisNoParameterActionFactory
 KisNoParameterActionFactory (const QString &id)
 
void runFromXML (KisViewManager *view, const KisOperationConfiguration &config) override
 
- Public Member Functions inherited from KisOperation
QString id () const
 
 KisOperation (const QString &id)
 
virtual ~KisOperation ()
 

Additional Inherited Members

- Public Types inherited from KisOperation
enum  Flag { Normal = 0x0 , ReadOnly = 0x1 }
 
- Protected Member Functions inherited from KisOperation
KisProcessingApplicator * beginAction (KisViewManager *view, const KUndo2MagicString &actionName, Flags flags=Normal)
 
void endAction (KisProcessingApplicator *applicator, const QString &xmlData)
 

Detailed Description

Definition at line 51 of file KisPasteActionFactories.h.

Constructor & Destructor Documentation

◆ KisPasteShapeStyleActionFactory()

KisPasteShapeStyleActionFactory::KisPasteShapeStyleActionFactory ( )
inline

Definition at line 52 of file KisPasteActionFactories.h.

52: KisNoParameterActionFactory("paste-shape-style-action") {}

Member Function Documentation

◆ run()

void KisPasteShapeStyleActionFactory::run ( KisViewManager * view)
overridevirtual

Implements KisNoParameterActionFactory.

Definition at line 361 of file KisPasteActionFactories.cpp.

362{
364
365 KisCanvas2 *canvas = view->canvasBase();
366
367 KoShapeManager *shapeManager = canvas->shapeManager();
368 QList<KoShape*> selectedShapes = shapeManager->selection()->selectedEditableShapes();
369
370 if (selectedShapes.isEmpty()) return;
371
372 if (paste.hasShapes()) {
373 KoCanvasBase *canvas = view->canvasBase();
374
375 QSizeF fragmentSize;
376 QList<KoShape*> shapes =
377 paste.fetchShapes(canvas->shapeController()->documentRectInPixels(),
378 canvas->shapeController()->pixelsPerInch(), &fragmentSize);
379
380 if (!shapes.isEmpty()) {
381 KoShape *referenceShape = shapes.first();
382
383
384 KUndo2Command *parentCommand = new KUndo2Command(kundo2_i18n("Paste Style"));
385
386 new KoShapeBackgroundCommand(selectedShapes, referenceShape->background(), parentCommand);
387 new KoShapeStrokeCommand(selectedShapes, referenceShape->stroke(), parentCommand);
388
389
390 canvas->addCommand(parentCommand);
391 }
392
393 qDeleteAll(shapes);
394 }
395}
KoShapeManager shapeManager
KisCanvas2 * canvasBase() const
Return the canvas base class.
QPointer< KoShapeController > shapeController
virtual void addCommand(KUndo2Command *command)=0
const QList< KoShape * > selectedEditableShapes() const
The undo / redo command for setting the shape background.
KoSelection * selection
The undo / redo command for setting the shape stroke.
virtual KoShapeStrokeModelSP stroke() const
Definition KoShape.cpp:888
virtual QSharedPointer< KoShapeBackground > background() const
Definition KoShape.cpp:754
KUndo2MagicString kundo2_i18n(const char *text)
QAction * paste(const QObject *recvr, const char *slot, QObject *parent)

References KoCanvasBase::addCommand(), KoShape::background(), KisViewManager::canvasBase(), kundo2_i18n(), KoSelection::selectedEditableShapes(), KoShapeManager::selection, KoCanvasBase::shapeController, KisCanvas2::shapeManager, and KoShape::stroke().


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