Krita Source Code Documentation
Loading...
Searching...
No Matches
KoShapeController::Private Class Reference

Public Member Functions

KUndo2CommandaddShape (KoShape *shape, bool showDialog, KoShapeContainer *parentShape, KUndo2Command *parent)
 
KUndo2CommandaddShapesDirect (const QList< KoShape * > shapes, KoShapeContainer *parentShape, KUndo2Command *parent)
 
 Private ()
 

Public Attributes

KoCanvasBasecanvas
 
KoShapeControllerBaseshapeController
 

Detailed Description

Definition at line 30 of file KoShapeController.cpp.

Constructor & Destructor Documentation

◆ Private()

KoShapeController::Private::Private ( )
inline

Definition at line 33 of file KoShapeController.cpp.

34 : canvas(0),
36 {
37 }
KoShapeControllerBase * shapeController

Member Function Documentation

◆ addShape()

KUndo2Command * KoShapeController::Private::addShape ( KoShape * shape,
bool showDialog,
KoShapeContainer * parentShape,
KUndo2Command * parent )
inline

Definition at line 42 of file KoShapeController.cpp.

42 {
43
44 if (canvas) {
45 if (showDialog && !shape->shapeId().isEmpty()) {
47 Q_ASSERT(factory);
48 qint16 z = 0;
49 Q_FOREACH (KoShape *sh, canvas->shapeManager()->shapes()) {
50 z = qMax(z, sh->zIndex());
51 }
52 shape->setZIndex(z + 1);
53
54 // show config dialog.
55 KPageDialog *dialog = new KPageDialog(canvas->canvasWidget());
56 dialog->setWindowTitle(i18n("%1 Options", factory->name()));
57
58 int pageCount = 0;
60 Q_FOREACH (KoShapeConfigWidgetBase* panel, factory->createShapeOptionPanels()) {
61 if (! panel->showOnShapeCreate())
62 continue;
63 panel->open(shape);
64 panel->connect(panel, SIGNAL(accept()), dialog, SLOT(accept()));
65 widgets.append(panel);
67 panel->setUnit(canvas->unit());
68 QString title = panel->windowTitle().isEmpty() ? panel->objectName() : panel->windowTitle();
69 dialog->addPage(panel, title);
70 pageCount ++;
71 }
72
73 if (pageCount > 0) {
74 if (pageCount > 1)
75 dialog->setFaceType(KPageDialog::Tabbed);
76 if (dialog->exec() != KPageDialog::Accepted) {
77 delete dialog;
78 return 0;
79 }
80 Q_FOREACH (KoShapeConfigWidgetBase *widget, widgets)
81 widget->save();
82 }
83 delete dialog;
84 }
85 }
86
87 return addShapesDirect({shape}, parentShape, parent);
88 }
virtual KoShapeManager * shapeManager() const =0
virtual KoUnit unit() const =0
virtual QWidget * canvasWidget()=0
QPointer< KoCanvasResourceProvider > resourceManager
const T value(const QString &id) const
virtual void open(KoShape *shape)=0
void setResourceManager(KoCanvasResourceProvider *rm)
called to set the canvas resource manager of the canvas the user used to insert the new shape.
virtual void setUnit(const KoUnit &unit)
virtual bool showOnShapeCreate()
Return true if the shape config panel should be shown after the shape is created.
KUndo2Command * addShapesDirect(const QList< KoShape * > shapes, KoShapeContainer *parentShape, KUndo2Command *parent)
virtual QList< KoShapeConfigWidgetBase * > createShapeOptionPanels()
QList< KoShape * > shapes
static KoShapeRegistry * instance()
void setZIndex(qint16 zIndex)
Definition KoShape.cpp:954
QString shapeId() const
Definition KoShape.cpp:1057
qint16 zIndex() const
Definition KoShape.cpp:600
ChildIterator< value_type, is_const > parent(const ChildIterator< value_type, is_const > &it)
Definition KisForest.h:327

References addShapesDirect(), canvas, KoCanvasBase::canvasWidget(), KoShapeFactoryBase::createShapeOptionPanels(), KoShapeRegistry::instance(), KoShapeFactoryBase::name, KoShapeConfigWidgetBase::open(), KoCanvasBase::resourceManager, KoShapeConfigWidgetBase::save(), KoShapeConfigWidgetBase::setResourceManager(), KoShapeConfigWidgetBase::setUnit(), KoShape::setZIndex(), KoShape::shapeId(), KoCanvasBase::shapeManager(), KoShapeManager::shapes, KoShapeConfigWidgetBase::showOnShapeCreate(), KoCanvasBase::unit(), KoGenericRegistry< T >::value(), and KoShape::zIndex().

◆ addShapesDirect()

KUndo2Command * KoShapeController::Private::addShapesDirect ( const QList< KoShape * > shapes,
KoShapeContainer * parentShape,
KUndo2Command * parent )
inline

Definition at line 90 of file KoShapeController.cpp.

91 {
92 KUndo2Command *resultCommand = 0;
93
94 if (!parentShape) {
95 resultCommand = new KUndo2Command(parent);
96 parentShape = shapeController->createParentForShapes(shapes, false, resultCommand);
97 KUndo2Command *addShapeCommand = new KoShapeCreateCommand(shapeController, shapes, parentShape, resultCommand);
98 resultCommand->setText(addShapeCommand->text());
99 } else {
100 resultCommand = new KoShapeCreateCommand(shapeController, shapes, parentShape, parent);
101 }
102
103 return resultCommand;
104 }
void setText(const KUndo2MagicString &text)
KUndo2MagicString text() const
virtual KoShapeContainer * createParentForShapes(const QList< KoShape * > shapes, bool forceNewLayer, KUndo2Command *parentCommand)
The undo / redo command for creating shapes.

References KoShapeControllerBase::createParentForShapes(), KUndo2Command::setText(), shapeController, and KUndo2Command::text().

Member Data Documentation

◆ canvas

KoCanvasBase* KoShapeController::Private::canvas

Definition at line 39 of file KoShapeController.cpp.

◆ shapeController

KoShapeControllerBase* KoShapeController::Private::shapeController

Definition at line 40 of file KoShapeController.cpp.


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