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

#include <PathToolOptionWidget.h>

+ Inheritance diagram for PathToolOptionWidget:

Public Types

enum  Type { PlainPath = 1 , ParametricShape = 2 }
 

Public Slots

void setCurrentShape (KoPathShape *pathShape)
 
void setSelectionType (int type)
 

Signals

void sigRequestUpdateActions ()
 

Public Member Functions

 PathToolOptionWidget (KoPathTool *tool, QWidget *parent=0)
 
 ~PathToolOptionWidget () override
 

Protected Member Functions

void showEvent (QShowEvent *event) override
 

Private Slots

void slotShapePropertyChanged ()
 

Private Attributes

KoCanvasBasem_canvas
 
KoShapeConfigWidgetBasem_currentPanel
 
KoPathShapem_currentShape
 
QString m_currentShapeId
 
Ui::PathToolOptionWidgetBase widget
 

Detailed Description

Definition at line 20 of file PathToolOptionWidget.h.

Member Enumeration Documentation

◆ Type

Enumerator
PlainPath 
ParametricShape 

Definition at line 24 of file PathToolOptionWidget.h.

Constructor & Destructor Documentation

◆ PathToolOptionWidget()

PathToolOptionWidget::PathToolOptionWidget ( KoPathTool * tool,
QWidget * parent = 0 )
explicit

Definition at line 21 of file PathToolOptionWidget.cpp.

22 : QWidget(parent),
25 m_canvas(tool->canvas())
26
27{
28 widget.setupUi(this);
29 widget.corner->setDefaultAction(tool->action("pathpoint-corner"));
30 widget.smooth->setDefaultAction(tool->action("pathpoint-smooth"));
31 widget.symmetric->setDefaultAction(tool->action("pathpoint-symmetric"));
32 widget.lineSegment->setDefaultAction(tool->action("pathsegment-line"));
33 widget.curveSegment->setDefaultAction(tool->action("pathsegment-curve"));
34 widget.linePoint->setDefaultAction(tool->action("pathpoint-line"));
35 widget.curvePoint->setDefaultAction(tool->action("pathpoint-curve"));
36 widget.addPoint->setDefaultAction(tool->action("pathpoint-insert"));
37 widget.removePoint->setDefaultAction(tool->action("pathpoint-remove"));
38 widget.breakPoint->setDefaultAction(tool->action("path-break-point"));
39 widget.breakSegment->setDefaultAction(tool->action("path-break-segment"));
40 widget.joinSegment->setDefaultAction(tool->action("pathpoint-join"));
41 widget.mergePoints->setDefaultAction(tool->action("pathpoint-merge"));
42
43 widget.wdgShapeProperties->setVisible(false);
44 widget.lineShapeProperties->setVisible(false);
45
46 connect(widget.convertToPath, SIGNAL(released()), tool->action("convert-to-path"), SLOT(trigger()));
47}
connect(this, SIGNAL(optionsChanged()), this, SLOT(saveOptions()))
KoCanvasBase * canvas() const
Returns the canvas the tool is working on.
QAction * action(const QString &name) const
KoShapeConfigWidgetBase * m_currentPanel
Ui::PathToolOptionWidgetBase widget

References KoToolBase::action(), connect(), and widget.

◆ ~PathToolOptionWidget()

PathToolOptionWidget::~PathToolOptionWidget ( )
override

Definition at line 49 of file PathToolOptionWidget.cpp.

50{
51}

Member Function Documentation

◆ setCurrentShape

void PathToolOptionWidget::setCurrentShape ( KoPathShape * pathShape)
slot

Definition at line 76 of file PathToolOptionWidget.cpp.

77{
78 const QString newShapeId = shapeIdFromShape(pathShape);
79 if (pathShape == m_currentShape && m_currentShapeId == newShapeId) return;
80
81 if (m_currentShape) {
83 if (m_currentPanel) {
84 m_currentPanel->deleteLater();
86 m_currentShapeId.clear();
87 }
88 }
89
90 if (pathShape) {
91 m_currentShape = pathShape;
92 m_currentShapeId = newShapeId;
93
96
98 if (!panels.isEmpty()) {
99 KoShapeConfigWidgetBase *activePanel = 0;
100
101 Q_FOREACH (KoShapeConfigWidgetBase *panel, panels) {
102 if (!activePanel && panel->showOnShapeSelect()) {
103 activePanel = panel;
104 } else {
105 delete panel;
106 }
107 }
108
109 if (activePanel) {
111 m_currentPanel = activePanel;
113
114 QLayout *baseLayout = widget.wdgShapeProperties->layout();
115 QVBoxLayout *layout = dynamic_cast<QVBoxLayout*>(widget.wdgShapeProperties->layout());
116
117 if (!layout) {
118 KIS_SAFE_ASSERT_RECOVER(!baseLayout) {
119 delete baseLayout;
120 }
121 layout = new QVBoxLayout(widget.wdgShapeProperties);
122 }
123
124
125 KIS_ASSERT_RECOVER_RETURN(widget.wdgShapeProperties->layout());
126 layout->addWidget(m_currentPanel);
127 connect(m_currentPanel, SIGNAL(propertyChanged()), SLOT(slotShapePropertyChanged()));
129 }
130 }
131 }
132
133 widget.wdgShapeProperties->setVisible(m_currentPanel);
134 widget.lineShapeProperties->setVisible(m_currentPanel);
135}
QString shapeIdFromShape(KoPathShape *pathShape)
virtual KoUnit unit() const =0
const T value(const QString &id) const
virtual void open(KoShape *shape)=0
virtual void setUnit(const KoUnit &unit)
virtual bool showOnShapeSelect()
Return true if the shape config panel should be shown when the shape is selected.
virtual QList< KoShapeConfigWidgetBase * > createShapeOptionPanels()
static KoShapeRegistry * instance()
#define KIS_SAFE_ASSERT_RECOVER(cond)
Definition kis_assert.h:126
#define KIS_SAFE_ASSERT_RECOVER_RETURN(cond)
Definition kis_assert.h:128
#define KIS_ASSERT_RECOVER_RETURN(cond)
Definition kis_assert.h:75

References connect(), KoShapeFactoryBase::createShapeOptionPanels(), KoShapeRegistry::instance(), KIS_ASSERT_RECOVER_RETURN, KIS_SAFE_ASSERT_RECOVER, KIS_SAFE_ASSERT_RECOVER_RETURN, m_canvas, m_currentPanel, m_currentShape, m_currentShapeId, KoShapeConfigWidgetBase::open(), KoShapeConfigWidgetBase::setUnit(), shapeIdFromShape(), KoShapeConfigWidgetBase::showOnShapeSelect(), slotShapePropertyChanged(), KoCanvasBase::unit(), KoGenericRegistry< T >::value(), and widget.

◆ setSelectionType

void PathToolOptionWidget::setSelectionType ( int type)
slot

Definition at line 53 of file PathToolOptionWidget.cpp.

54{
55 const bool plain = type & PlainPath;
56 if (plain)
57 widget.stackedWidget->setCurrentIndex(0);
58 else
59 widget.stackedWidget->setCurrentIndex(1);
60}

References PlainPath, and widget.

◆ showEvent()

void PathToolOptionWidget::showEvent ( QShowEvent * event)
overrideprotected

Definition at line 147 of file PathToolOptionWidget.cpp.

148{
150 QWidget::showEvent(event);
151}
void sigRequestUpdateActions()

References sigRequestUpdateActions().

◆ sigRequestUpdateActions

void PathToolOptionWidget::sigRequestUpdateActions ( )
signal

◆ slotShapePropertyChanged

void PathToolOptionWidget::slotShapePropertyChanged ( )
privateslot

Definition at line 137 of file PathToolOptionWidget.cpp.

138{
140
142 if (command) {
143 m_canvas->addCommand(command);
144 }
145}
virtual void addCommand(KUndo2Command *command)=0
virtual KUndo2Command * createCommand()
Creates a command which applies all changes to the opened shape.

References KoCanvasBase::addCommand(), KoShapeConfigWidgetBase::createCommand(), KIS_SAFE_ASSERT_RECOVER_RETURN, m_canvas, and m_currentPanel.

Member Data Documentation

◆ m_canvas

KoCanvasBase* PathToolOptionWidget::m_canvas
private

Definition at line 52 of file PathToolOptionWidget.h.

◆ m_currentPanel

KoShapeConfigWidgetBase* PathToolOptionWidget::m_currentPanel
private

Definition at line 51 of file PathToolOptionWidget.h.

◆ m_currentShape

KoPathShape* PathToolOptionWidget::m_currentShape
private

Definition at line 49 of file PathToolOptionWidget.h.

◆ m_currentShapeId

QString PathToolOptionWidget::m_currentShapeId
private

Definition at line 50 of file PathToolOptionWidget.h.

◆ widget

Ui::PathToolOptionWidgetBase PathToolOptionWidget::widget
private

Definition at line 47 of file PathToolOptionWidget.h.


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