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

#include <StarShapeConfigWidget.h>

+ Inheritance diagram for StarShapeConfigWidget:

Public Member Functions

KUndo2CommandcreateCommand () override
 reimplemented
 
void open (KoShape *shape) override
 reimplemented
 
void save () override
 reimplemented
 
void setUnit (const KoUnit &unit) override
 reimplemented
 
bool showOnShapeCreate () override
 reimplemented
 
 StarShapeConfigWidget ()
 
- Public Member Functions inherited from KoShapeConfigWidgetBase
 KoShapeConfigWidgetBase ()
 
void setResourceManager (KoCanvasResourceProvider *rm)
 called to set the canvas resource manager of the canvas the user used to insert the new shape.
 
virtual bool showOnShapeSelect ()
 Return true if the shape config panel should be shown when the shape is selected.
 
 ~KoShapeConfigWidgetBase () override
 

Private Slots

void typeChanged ()
 

Private Attributes

StarShapem_star {nullptr}
 
Ui::StarShapeConfigWidget widget
 

Additional Inherited Members

- Signals inherited from KoShapeConfigWidgetBase
void accept ()
 is emitted when the dialog should be accepted ie a file double clicked in a filebrowser
 
void propertyChanged ()
 is emitted after one of the config options has changed
 
- Protected Attributes inherited from KoShapeConfigWidgetBase
KoCanvasResourceProviderm_resourceManager
 the resource provider with data for this canvas
 

Detailed Description

Definition at line 16 of file StarShapeConfigWidget.h.

Constructor & Destructor Documentation

◆ StarShapeConfigWidget()

StarShapeConfigWidget::StarShapeConfigWidget ( )

Definition at line 13 of file StarShapeConfigWidget.cpp.

14{
15 widget.setupUi(this);
16
17 connect(widget.corners, SIGNAL(valueChanged(int)), this, SIGNAL(propertyChanged()));
18 connect(widget.innerRadius, SIGNAL(editingFinished()), this, SIGNAL(propertyChanged()));
19 connect(widget.outerRadius, SIGNAL(editingFinished()), this, SIGNAL(propertyChanged()));
20 connect(widget.convex, SIGNAL(stateChanged(int)), this, SIGNAL(propertyChanged()));
21 connect(widget.convex, SIGNAL(clicked()), this, SLOT(typeChanged()));
22}
connect(this, SIGNAL(optionsChanged()), this, SLOT(saveOptions()))
void propertyChanged()
is emitted after one of the config options has changed
Ui::StarShapeConfigWidget widget

References connect(), KoShapeConfigWidgetBase::propertyChanged(), typeChanged(), and widget.

Member Function Documentation

◆ createCommand()

KUndo2Command * StarShapeConfigWidget::createCommand ( )
overridevirtual

reimplemented

Reimplemented from KoShapeConfigWidgetBase.

Definition at line 66 of file StarShapeConfigWidget.cpp.

67{
68 if (!m_star) {
69 return 0;
70 } else
71 return new StarShapeConfigCommand(m_star, widget.corners->value(), widget.innerRadius->value(),
72 widget.outerRadius->value(), widget.convex->checkState() == Qt::Checked);
73}
The undo / redo command for configuring a star shape.
bool convex() const
Returns if the star represents a regular polygon.

References StarShape::convex(), m_star, and widget.

◆ open()

void StarShapeConfigWidget::open ( KoShape * shape)
overridevirtual

reimplemented

Implements KoShapeConfigWidgetBase.

Definition at line 30 of file StarShapeConfigWidget.cpp.

31{
32 m_star = dynamic_cast<StarShape *>(shape);
33 if (!m_star) {
34 return;
35 }
36
37 widget.corners->blockSignals(true);
38 widget.innerRadius->blockSignals(true);
39 widget.outerRadius->blockSignals(true);
40 widget.convex->blockSignals(true);
41
42 widget.corners->setValue(m_star->cornerCount());
43 widget.innerRadius->changeValue(m_star->baseRadius());
44 widget.outerRadius->changeValue(m_star->tipRadius());
45 widget.convex->setCheckState(m_star->convex() ? Qt::Checked : Qt::Unchecked);
47
48 widget.corners->blockSignals(false);
49 widget.innerRadius->blockSignals(false);
50 widget.outerRadius->blockSignals(false);
51 widget.convex->blockSignals(false);
52}
uint cornerCount() const
Returns the number of corners.
Definition StarShape.cpp:70
qreal baseRadius() const
Returns the base radius.
Definition StarShape.cpp:81
qreal tipRadius() const
Returns the tip radius.
Definition StarShape.cpp:92

References StarShape::baseRadius(), StarShape::convex(), StarShape::cornerCount(), m_star, StarShape::tipRadius(), typeChanged(), and widget.

◆ save()

void StarShapeConfigWidget::save ( )
overridevirtual

reimplemented

Implements KoShapeConfigWidgetBase.

Definition at line 54 of file StarShapeConfigWidget.cpp.

55{
56 if (!m_star) {
57 return;
58 }
59
60 m_star->setCornerCount(widget.corners->value());
61 m_star->setBaseRadius(widget.innerRadius->value());
62 m_star->setTipRadius(widget.outerRadius->value());
63 m_star->setConvex(widget.convex->checkState() == Qt::Checked);
64}
void setBaseRadius(qreal baseRadius)
Definition StarShape.cpp:75
void setCornerCount(uint cornerCount)
Definition StarShape.cpp:57
void setTipRadius(qreal tipRadius)
Definition StarShape.cpp:86
void setConvex(bool convex)

References m_star, StarShape::setBaseRadius(), StarShape::setConvex(), StarShape::setCornerCount(), StarShape::setTipRadius(), and widget.

◆ setUnit()

void StarShapeConfigWidget::setUnit ( const KoUnit & unit)
overridevirtual

reimplemented

Reimplemented from KoShapeConfigWidgetBase.

Definition at line 24 of file StarShapeConfigWidget.cpp.

25{
26 widget.innerRadius->setUnit(unit);
27 widget.outerRadius->setUnit(unit);
28}

References widget.

◆ showOnShapeCreate()

bool StarShapeConfigWidget::showOnShapeCreate ( )
inlineoverridevirtual

reimplemented

Reimplemented from KoShapeConfigWidgetBase.

Definition at line 28 of file StarShapeConfigWidget.h.

29 {
30 return false;
31 }

◆ typeChanged

void StarShapeConfigWidget::typeChanged ( )
privateslot

Definition at line 75 of file StarShapeConfigWidget.cpp.

76{
77 if (widget.convex->checkState() == Qt::Checked) {
78 widget.innerRadius->setEnabled(false);
79 } else {
80 widget.innerRadius->setEnabled(true);
81 }
82}

References widget.

Member Data Documentation

◆ m_star

StarShape* StarShapeConfigWidget::m_star {nullptr}
private

Definition at line 39 of file StarShapeConfigWidget.h.

39{nullptr};

◆ widget

Ui::StarShapeConfigWidget StarShapeConfigWidget::widget
private

Definition at line 38 of file StarShapeConfigWidget.h.


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