Krita Source Code Documentation
Loading...
Searching...
No Matches
StarShapeConfigWidget.cpp
Go to the documentation of this file.
1/* This file is part of the KDE project
2 * SPDX-FileCopyrightText: 2007 Jan Hambrecht <jaham@gmx.net>
3 *
4 * SPDX-License-Identifier: LGPL-2.0-or-later
5 */
6
8#include "StarShape.h"
10
12
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}
23
25{
26 widget.innerRadius->setUnit(unit);
27 widget.outerRadius->setUnit(unit);
28}
29
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}
53
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}
65
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}
74
76{
77 if (widget.convex->checkState() == Qt::Checked) {
78 widget.innerRadius->setEnabled(false);
79 } else {
80 widget.innerRadius->setEnabled(true);
81 }
82}
connect(this, SIGNAL(optionsChanged()), this, SLOT(saveOptions()))
void propertyChanged()
is emitted after one of the config options has changed
The undo / redo command for configuring a star shape.
void save() override
reimplemented
KUndo2Command * createCommand() override
reimplemented
void open(KoShape *shape) override
reimplemented
Ui::StarShapeConfigWidget widget
void setUnit(const KoUnit &unit) override
reimplemented
uint cornerCount() const
Returns the number of corners.
Definition StarShape.cpp:70
void setBaseRadius(qreal baseRadius)
Definition StarShape.cpp:75
void setCornerCount(uint cornerCount)
Definition StarShape.cpp:57
bool convex() const
Returns if the star represents a regular polygon.
void setTipRadius(qreal tipRadius)
Definition StarShape.cpp:86
qreal baseRadius() const
Returns the base radius.
Definition StarShape.cpp:81
qreal tipRadius() const
Returns the tip radius.
Definition StarShape.cpp:92
void setConvex(bool convex)