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

A widget for configuring the stroke of a shape. More...

#include <KoStrokeConfigWidget.h>

+ Inheritance diagram for KoStrokeConfigWidget:

Signals

void sigStrokeChanged ()
 

Public Member Functions

void activate ()
 
Qt::PenCapStyle capStyle () const
 
QColor color () const
 
KoShapeStrokeSP createShapeStroke ()
 
void deactivate ()
 
KoMarkerendMarker () const
 
Qt::PenJoinStyle joinStyle () const
 
 KoStrokeConfigWidget (KoCanvasBase *canvas, QWidget *parent)
 
QVector< qreal > lineDashes () const
 
Qt::PenStyle lineStyle () const
 
qreal lineWidth () const
 
qreal miterLimit () const
 
 Private ()
 
void setActive (bool active)
 
void setNoSelectionTrackingMode (bool value)
 
void setUnitManagers (KisSpinBoxUnitManager *managerLineWidth, KisSpinBoxUnitManager *managerMitterLimit)
 
KoMarkerstartMarker () const
 
void updateStyleControlsAvailability (bool enabled)
 
 ~KoStrokeConfigWidget () override
 

Public Attributes

bool active {true}
 
bool allowLocalUnitManagement {false}
 
KoCanvasBasecanvas {0}
 
CapNJoinMenucapNJoinMenu {0}
 
std::vector< KisAcyclicSignalConnector::BlockerdeactivationLocks
 
KoMarkerSelectorendMarkerSelector {0}
 
KoFillConfigWidgetfillConfigWidget {0}
 
KoLineStyleSelectorlineStyle {0}
 
KisDoubleParseUnitSpinBoxlineWidth {0}
 
KoMarkerSelectormidMarkerSelector {0}
 
bool noSelectionTrackingMode {false}
 
KisAcyclicSignalConnector resourceManagerAcyclicConnector
 
KisSignalCompressor selectionChangedCompressor
 
QFrame * separatorLine
 
KisAcyclicSignalConnector shapeChangedAcyclicConnector
 
QWidget * spacer {0}
 
KoMarkerSelectorstartMarkerSelector {0}
 
QLabel * strokeStyleLabel
 
QLabel * thicknessLabel
 
QScopedPointer< Ui_KoStrokeConfigWidget > ui
 

Private Slots

void applyDashStyleChanges ()
 apply line changes to the selected shapes
 
void applyJoinCapChanges ()
 
void applyLineWidthChanges ()
 
void applyMarkerChanges (int rawPosition)
 apply marker changes to the selected shape
 
void canvasResourceChanged (int key, const QVariant &value)
 
void selectionChanged ()
 selection has changed
 
void updateMarkers (const QList< KoMarker * > &markers)
 

Private Member Functions

void blockChildSignals (bool block)
 
void loadCurrentStrokeFillFromResourceServer ()
 
void setUnit (const KoUnit &unit, KoShape *representativeShape)
 
- Private Member Functions inherited from Private
 Private (KisCanvas2 *c)
 

Private Attributes

Private *const d
 
- Private Attributes inherited from Private
KisCanvas2canvas
 
int displayedFrame
 
int intendedFrame
 

Detailed Description

A widget for configuring the stroke of a shape.

Definition at line 154 of file KoStrokeConfigWidget.cpp.

Constructor & Destructor Documentation

◆ KoStrokeConfigWidget()

KoStrokeConfigWidget::KoStrokeConfigWidget ( KoCanvasBase * canvas,
QWidget * parent )
explicit

Definition at line 190 of file KoStrokeConfigWidget.cpp.

191 : QWidget(parent)
192 , d(new Private())
193{
194 // configure GUI
195 d->ui.reset(new Ui_KoStrokeConfigWidget());
196 d->ui->setupUi(this);
197
198 setObjectName("Stroke widget");
199
200 { // connect the canvas
201 d->shapeChangedAcyclicConnector.connectBackwardVoid(
203 &d->selectionChangedCompressor, SLOT(start()));
204
205 d->shapeChangedAcyclicConnector.connectBackwardVoid(
206 canvas->selectedShapesProxy(), SIGNAL(selectionContentChanged()),
207 &d->selectionChangedCompressor, SLOT(start()));
208
209 connect(&d->selectionChangedCompressor, SIGNAL(timeout()), this, SLOT(selectionChanged()));
210
211 d->resourceManagerAcyclicConnector.connectBackwardResourcePair(
212 canvas->resourceManager(), SIGNAL(canvasResourceChanged(int,QVariant)),
213 this, SLOT(canvasResourceChanged(int,QVariant)));
214
215 d->canvas = canvas;
216 }
217
218 {
219
220 d->fillConfigWidget = new KoFillConfigWidget(canvas, KoFlake::StrokeFill, true, this);
221 d->fillConfigWidget->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::MinimumExpanding);
222 d->ui->fillConfigWidgetLayout->addWidget(d->fillConfigWidget);
223 connect(d->fillConfigWidget, SIGNAL(sigFillChanged()), SIGNAL(sigStrokeChanged()));
224 }
225
226 d->ui->thicknessLabel->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
227 d->ui->thicknessLabel->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
228
229 // set min/max/step and value in points, then set actual unit
230 d->ui->lineWidth->preventDecimalsChangeFromUnitManager(true);
231 d->ui->lineWidth->setUnit(KoUnit(KoUnit::Point));
232 // if someone wants 0, just set to "none" on UI
233 // note: when initialized, there's probably no document opened or even if some documents are opened, the resolution
234 // of document may not be the same...
235 // min/max/step are then defined in Pt - values here are considered @600dpi; 0.10px = 0.03Pt / 1000px = 240.00pt
236 d->ui->lineWidth->setMinMaxStep(0.03, 240.0, 0.01);
237 d->ui->lineWidth->setDecimals(2);
238 d->ui->lineWidth->setToolTip(i18n("Set line width of actual selection"));
239
240 d->ui->capNJoinButton->setMinimumHeight(25);
241 d->capNJoinMenu = new CapNJoinMenu(this);
242 d->ui->capNJoinButton->setMenu(d->capNJoinMenu);
243 d->ui->capNJoinButton->setText("...");
244 d->ui->capNJoinButton->setPopupMode(QToolButton::InstantPopup);
245
246
247 {
248 // Line style
249 d->ui->strokeStyleLabel->setText(i18n("Line Style:"));
250 d->ui->strokeStyleLabel->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
251
252 d->ui->lineStyle->setToolTip(i18nc("@info:tooltip", "Line style"));
253 d->ui->lineStyle->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum);
254 d->ui->lineStyle->setLineStyle(Qt::SolidLine, QVector<qreal>());
255 }
256
257
258 {
259 QList<KoMarker*> emptyMarkers;
260
261
262 d->startMarkerSelector = new KoMarkerSelector(KoFlake::StartMarker, this);
263 d->startMarkerSelector->setToolTip(i18nc("@info:tooltip", "Start marker"));
264 d->startMarkerSelector->updateMarkers(emptyMarkers);
265 d->startMarkerSelector->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred );
266 d->ui->markerLayout->addWidget(d->startMarkerSelector);
267
268
269 d->midMarkerSelector = new KoMarkerSelector(KoFlake::MidMarker, this);
270 d->midMarkerSelector->setToolTip(i18nc("@info:tooltip", "Node marker"));
271 d->midMarkerSelector->updateMarkers(emptyMarkers);
272 d->midMarkerSelector->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred );
273 d->ui->markerLayout->addWidget(d->midMarkerSelector);
274
275
276 d->endMarkerSelector = new KoMarkerSelector(KoFlake::EndMarker, this);
277 d->endMarkerSelector->setToolTip(i18nc("@info:tooltip", "End marker"));
278 d->endMarkerSelector->updateMarkers(emptyMarkers);
279 d->endMarkerSelector->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred );
280
281 d->ui->markerLayout->addWidget(d->endMarkerSelector);
282 }
283
284 // Spacer
285 d->spacer = new QWidget();
286 d->spacer->setObjectName("SpecialSpacer");
287
288 d->ui->markerLayout->addWidget(d->spacer);
289
290 connect(d->ui->lineStyle, SIGNAL(currentIndexChanged(int)), this, SLOT(applyDashStyleChanges()));
291 connect(d->ui->lineWidth, SIGNAL(valueChangedPt(qreal)), this, SLOT(applyLineWidthChanges()));
292
293 connect(d->capNJoinMenu->capGroup, SIGNAL(idClicked(int)), this, SLOT(applyJoinCapChanges()));
294 connect(d->capNJoinMenu->joinGroup, SIGNAL(idClicked(int)), this, SLOT(applyJoinCapChanges()));
295 connect(d->capNJoinMenu->miterLimit, SIGNAL(valueChangedPt(qreal)), this, SLOT(applyJoinCapChanges()));
296
297 { // Map the marker signals correctly
298 KisSignalMapper *mapper = new KisSignalMapper(this);
299 connect(mapper, SIGNAL(mapped(int)), SLOT(applyMarkerChanges(int)));
300
301 connect(d->startMarkerSelector, SIGNAL(currentIndexChanged(int)), mapper, SLOT(map()));
302 connect(d->midMarkerSelector, SIGNAL(currentIndexChanged(int)), mapper, SLOT(map()));
303 connect(d->endMarkerSelector, SIGNAL(currentIndexChanged(int)), mapper, SLOT(map()));
304
305 mapper->setMapping(d->startMarkerSelector, KoFlake::StartMarker);
306 mapper->setMapping(d->midMarkerSelector, KoFlake::MidMarker);
307 mapper->setMapping(d->endMarkerSelector, KoFlake::EndMarker);
308 }
309
310 KoDocumentResourceManager *resourceManager = canvas->shapeController()->resourceManager();
311 if (resourceManager) {
313 if (collection) {
314 updateMarkers(collection->markers());
315 }
316 }
317
318 d->selectionChangedCompressor.start();
319
320 // initialize deactivation locks
321 d->deactivationLocks.push_back(KisAcyclicSignalConnector::Blocker(d->shapeChangedAcyclicConnector));
322 d->deactivationLocks.push_back(KisAcyclicSignalConnector::Blocker(d->resourceManagerAcyclicConnector));
323}
std::unique_lock< KisAcyclicSignalConnector > Blocker
The KisSignalMapper class bundles signals from identifiable senders.
void setMapping(QObject *sender, int id)
QPointer< KoShapeController > shapeController
QPointer< KoCanvasResourceProvider > resourceManager
virtual KoSelectedShapesProxy * selectedShapesProxy() const =0
selectedShapesProxy() is a special interface for keeping a persistent connections to selectionChanged...
@ MarkerCollection
The collection holding all markers.
A widget for configuring the fill of a shape.
QList< QExplicitlySharedDataPointer< KoMarker > > markers
void updateMarkers(const QList< KoMarker * > &markers)
void applyMarkerChanges(int rawPosition)
apply marker changes to the selected shape
void selectionChanged()
selection has changed
void applyDashStyleChanges()
apply line changes to the selected shapes
void canvasResourceChanged(int key, const QVariant &value)
@ Point
Postscript point, 1/72th of an Inco.
Definition KoUnit.h:76
@ EndMarker
Definition KoFlake.h:44
@ StartMarker
Definition KoFlake.h:42
@ MidMarker
Definition KoFlake.h:43
@ StrokeFill
Definition KoFlake.h:30
KisCanvas2 * canvas

References applyDashStyleChanges(), applyJoinCapChanges(), applyLineWidthChanges(), applyMarkerChanges(), Private::canvas, canvas, canvasResourceChanged(), d, KoFlake::EndMarker, KoDocumentResourceManager::MarkerCollection, KoMarkerCollection::markers, KoFlake::MidMarker, KoUnit::Point, KoDocumentResourceManager::resource(), KoCanvasBase::resourceManager, KoCanvasBase::selectedShapesProxy(), selectionChanged(), KisSignalMapper::setMapping(), KoCanvasBase::shapeController, sigStrokeChanged(), KoFlake::StartMarker, KoFlake::StrokeFill, and updateMarkers().

◆ ~KoStrokeConfigWidget()

KoStrokeConfigWidget::~KoStrokeConfigWidget ( )
override

Definition at line 325 of file KoStrokeConfigWidget.cpp.

326{
327 delete d;
328}

References d.

Member Function Documentation

◆ activate()

void KoStrokeConfigWidget::activate ( )

Definition at line 455 of file KoStrokeConfigWidget.cpp.

456{
457 KIS_SAFE_ASSERT_RECOVER_NOOP(!d->deactivationLocks.empty());
458 d->deactivationLocks.clear();
459 d->fillConfigWidget->activate();
460
461 if (!d->noSelectionTrackingMode) {
462 d->selectionChangedCompressor.start();
463 } else {
465 }
466}
#define KIS_SAFE_ASSERT_RECOVER_NOOP(cond)
Definition kis_assert.h:130

References d, KIS_SAFE_ASSERT_RECOVER_NOOP, and loadCurrentStrokeFillFromResourceServer().

◆ applyDashStyleChanges

void KoStrokeConfigWidget::applyDashStyleChanges ( )
privateslot

apply line changes to the selected shapes

Definition at line 513 of file KoStrokeConfigWidget.cpp.

514{
516 d->canvas,
517 [this] (KoShapeStrokeSP stroke) {
518 stroke->setLineStyle(lineStyle(), lineDashes());
519 });
520
521 Q_EMIT sigStrokeChanged();
522}
auto applyChangeToStrokes(KoCanvasBase *canvas, ModifyFunction modifyFunction) -> decltype(modifyFunction(KoShapeStrokeSP()), void())

References applyChangeToStrokes(), Private::canvas, d, and sigStrokeChanged().

◆ applyJoinCapChanges

void KoStrokeConfigWidget::applyJoinCapChanges ( )
privateslot

Definition at line 535 of file KoStrokeConfigWidget.cpp.

536{
538 d->canvas,
539 [this] (KoShapeStrokeSP stroke) {
540
541 stroke->setCapStyle(static_cast<Qt::PenCapStyle>(d->capNJoinMenu->capGroup->checkedId()));
542 stroke->setJoinStyle(static_cast<Qt::PenJoinStyle>(d->capNJoinMenu->joinGroup->checkedId()));
543 stroke->setMiterLimit(miterLimit());
544 });
545
546 Q_EMIT sigStrokeChanged();
547}

References applyChangeToStrokes(), Private::canvas, d, and sigStrokeChanged().

◆ applyLineWidthChanges

void KoStrokeConfigWidget::applyLineWidthChanges ( )
privateslot

Definition at line 524 of file KoStrokeConfigWidget.cpp.

525{
527 d->canvas,
528 [this] (KoShapeStrokeSP stroke) {
529 stroke->setLineWidth(lineWidth());
530 });
531
532 Q_EMIT sigStrokeChanged();
533}

References applyChangeToStrokes(), Private::canvas, d, and sigStrokeChanged().

◆ applyMarkerChanges

void KoStrokeConfigWidget::applyMarkerChanges ( int rawPosition)
privateslot

apply marker changes to the selected shape

Definition at line 549 of file KoStrokeConfigWidget.cpp.

550{
552 if (!selection) {
553 Q_EMIT sigStrokeChanged();
554 return;
555 }
556
557 QList<KoShape*> shapes = selection->selectedEditableShapes();
558 QList<KoPathShape*> pathShapes;
559 Q_FOREACH (KoShape *shape, shapes) {
560 KoPathShape *pathShape = dynamic_cast<KoPathShape*>(shape);
561 if (pathShape) {
562 pathShapes << pathShape;
563 }
564 }
565
566 if (pathShapes.isEmpty()) {
567 Q_EMIT sigStrokeChanged();
568 return;
569 }
570
571
572 KoFlake::MarkerPosition position = KoFlake::MarkerPosition(rawPosition);
573 std::unique_ptr<KoMarker> marker;
574
575 switch (position) {
577 if (d->startMarkerSelector->marker()) {
578 marker.reset(new KoMarker(*d->startMarkerSelector->marker()));
579 }
580 break;
582 if (d->midMarkerSelector->marker()) {
583 marker.reset(new KoMarker(*d->midMarkerSelector->marker()));
584 }
585 break;
587 if (d->endMarkerSelector->marker()) {
588 marker.reset(new KoMarker(*d->endMarkerSelector->marker()));
589 }
590 break;
591 }
592
593 KUndo2Command* command = new KoPathShapeMarkerCommand(pathShapes, marker.release(), position);
594 d->canvas->addCommand(command);
595
596 Q_EMIT sigStrokeChanged();
597}
KisSelectedShapesProxy selectedShapesProxy
void addCommand(KUndo2Command *command) override
KoSelection * selection() override
The position of a path point within a path shape.
Definition KoPathShape.h:63
const QList< KoShape * > selectedEditableShapes() const
MarkerPosition
Definition KoFlake.h:41
The undo / redo command for setting the shape marker.

References KisCanvas2::addCommand(), Private::canvas, d, KoFlake::EndMarker, KoFlake::MidMarker, KoSelection::selectedEditableShapes(), KisCanvas2::selectedShapesProxy, KisSelectedShapesProxy::selection(), sigStrokeChanged(), and KoFlake::StartMarker.

◆ blockChildSignals()

void KoStrokeConfigWidget::blockChildSignals ( bool block)
private

Definition at line 477 of file KoStrokeConfigWidget.cpp.

478{
479 d->ui->lineWidth->blockSignals(block);
480 d->capNJoinMenu->capGroup->blockSignals(block);
481 d->capNJoinMenu->joinGroup->blockSignals(block);
482 d->capNJoinMenu->miterLimit->blockSignals(block);
483 d->ui->lineStyle->blockSignals(block);
484 d->startMarkerSelector->blockSignals(block);
485 d->midMarkerSelector->blockSignals(block);
486 d->endMarkerSelector->blockSignals(block);
487}

References d.

◆ canvasResourceChanged

void KoStrokeConfigWidget::canvasResourceChanged ( int key,
const QVariant & value )
privateslot

Definition at line 770 of file KoStrokeConfigWidget.cpp.

771{
772 switch (key) {
774 // we request the whole selection to reload because the
775 // unit of the stroke width depends on the selected shape
776 d->selectionChangedCompressor.start();
777 break;
779 if (d->noSelectionTrackingMode) {
780 d->ui->lineWidth->changeValue(d->canvas->unit().fromUserValue(value.toReal()));
781 }
782 break;
783 }
784}
float value(const T *src, size_t ch)
KoUnit unit() const override
qreal fromUserValue(qreal value) const
Definition KoUnit.cpp:201
@ Unit
The unit of this canvas.

References Private::canvas, d, KoUnit::fromUserValue(), KoCanvasResource::Size, KoCanvasResource::Unit, KisCanvas2::unit(), and value().

◆ capStyle()

Qt::PenCapStyle KoStrokeConfigWidget::capStyle ( ) const

Definition at line 373 of file KoStrokeConfigWidget.cpp.

374{
375 return static_cast<Qt::PenCapStyle>(d->capNJoinMenu->capGroup->checkedId());
376}

References d.

◆ color()

QColor KoStrokeConfigWidget::color ( ) const

◆ createShapeStroke()

KoShapeStrokeSP KoStrokeConfigWidget::createShapeStroke ( )

Creates KoShapeStroke object filled with the options configured by the widget. The caller is in charge of deletion of the returned object

Definition at line 383 of file KoStrokeConfigWidget.cpp.

384{
385 KoShapeStrokeSP stroke(d->fillConfigWidget->createShapeStroke());
386
387 stroke->setLineWidth(lineWidth());
388 stroke->setCapStyle(capStyle());
389 stroke->setJoinStyle(joinStyle());
390 stroke->setMiterLimit(miterLimit());
391 stroke->setLineStyle(lineStyle(), lineDashes());
392
393 return stroke;
394}
Qt::PenCapStyle capStyle() const
Qt::PenJoinStyle joinStyle() const
KisDoubleParseUnitSpinBox * lineWidth
KoLineStyleSelector * lineStyle
QVector< qreal > lineDashes() const

References capStyle(), d, joinStyle(), lineDashes(), lineStyle, lineWidth, and miterLimit().

◆ deactivate()

void KoStrokeConfigWidget::deactivate ( )

Definition at line 468 of file KoStrokeConfigWidget.cpp.

469{
470 KIS_SAFE_ASSERT_RECOVER_NOOP(d->deactivationLocks.empty());
471
472 d->deactivationLocks.push_back(KisAcyclicSignalConnector::Blocker(d->shapeChangedAcyclicConnector));
473 d->deactivationLocks.push_back(KisAcyclicSignalConnector::Blocker(d->resourceManagerAcyclicConnector));
474 d->fillConfigWidget->deactivate();
475}

References d, and KIS_SAFE_ASSERT_RECOVER_NOOP.

◆ endMarker()

KoMarker * KoStrokeConfigWidget::endMarker ( ) const

Definition at line 368 of file KoStrokeConfigWidget.cpp.

369{
370 return d->endMarkerSelector->marker();
371}

References d.

◆ joinStyle()

Qt::PenJoinStyle KoStrokeConfigWidget::joinStyle ( ) const

Definition at line 378 of file KoStrokeConfigWidget.cpp.

379{
380 return static_cast<Qt::PenJoinStyle>(d->capNJoinMenu->joinGroup->checkedId());
381}

References d.

◆ lineDashes()

QVector< qreal > KoStrokeConfigWidget::lineDashes ( ) const

Definition at line 348 of file KoStrokeConfigWidget.cpp.

349{
350 return d->ui->lineStyle->lineDashes();
351}

References d.

◆ lineStyle()

Qt::PenStyle KoStrokeConfigWidget::lineStyle ( ) const

◆ lineWidth()

qreal KoStrokeConfigWidget::lineWidth ( ) const

◆ loadCurrentStrokeFillFromResourceServer()

void KoStrokeConfigWidget::loadCurrentStrokeFillFromResourceServer ( )
private

◆ miterLimit()

qreal KoStrokeConfigWidget::miterLimit ( ) const

Definition at line 358 of file KoStrokeConfigWidget.cpp.

359{
360 return d->capNJoinMenu->miterLimit->value();
361}

References d.

◆ Private()

KoStrokeConfigWidget::Private ( )
inline

◆ selectionChanged

void KoStrokeConfigWidget::selectionChanged ( )
privateslot

selection has changed

Definition at line 656 of file KoStrokeConfigWidget.cpp.

657{
658 if (d->noSelectionTrackingMode) return;
659
661 if (!selection) return;
662
663 // we need to linearize update order, and force the child widget to update
664 // before we start doing it
665
666 QList<KoShape*> shapes = selection->selectedEditableShapes();
667
668 KoShape *shape = !shapes.isEmpty() ? shapes.first() : 0;
669
670 const KoShapeStrokeSP stroke = shape ? qSharedPointerDynamicCast<KoShapeStroke>(shape->stroke()) : KoShapeStrokeSP();
671
672 // setUnit uses blockChildSignals() so take care not to use it inside the block
673 setUnit(d->canvas->unit(), shape);
674
675 blockChildSignals(true);
676
677 // line width
678 if (stroke && KoFlake::compareShapePropertiesEqual<CheckShapeStrokeWidthPolicy>(shapes)) {
679 d->ui->lineWidth->changeValue(stroke->lineWidth());
680 } else {
681 d->ui->lineWidth->changeValue(0);
682 }
683
684
685 // caps & joins
686 if (stroke && KoFlake::compareShapePropertiesEqual<CheckShapeStrokeCapJoinPolicy>(shapes)) {
687 Qt::PenCapStyle capStyle = stroke->capStyle() >= 0 ? stroke->capStyle() : Qt::FlatCap;
688 Qt::PenJoinStyle joinStyle = stroke->joinStyle() >= 0 ? stroke->joinStyle() : Qt::MiterJoin;
689
690 {
691 QAbstractButton *button = d->capNJoinMenu->capGroup->button(capStyle);
693 button->setChecked(true);
694 }
695
696 {
697 QAbstractButton *button = d->capNJoinMenu->joinGroup->button(joinStyle);
699 button->setChecked(true);
700 }
701
702 d->capNJoinMenu->miterLimit->changeValue(stroke->miterLimit());
703 d->capNJoinMenu->miterLimit->setEnabled(joinStyle == Qt::MiterJoin);
704 } else {
705 d->capNJoinMenu->capGroup->button(Qt::FlatCap)->setChecked(true);
706 d->capNJoinMenu->joinGroup->button(Qt::MiterJoin)->setChecked(true);
707 d->capNJoinMenu->miterLimit->changeValue(0.0);
708 d->capNJoinMenu->miterLimit->setEnabled(true);
709 }
710
711
712 // dashes style
713 if (stroke && KoFlake::compareShapePropertiesEqual<CheckShapeStrokeDashesPolicy>(shapes)) {
714 d->ui->lineStyle->setLineStyle(stroke->lineStyle(), stroke->lineDashes());
715 } else {
716 d->ui->lineStyle->setLineStyle(Qt::SolidLine, QVector<qreal>());
717 }
718
719 // markers
720 KoPathShape *pathShape = dynamic_cast<KoPathShape *>(shape);
721 if (pathShape) {
723 d->startMarkerSelector->setMarker(pathShape->marker(KoFlake::StartMarker));
724 }
726 d->midMarkerSelector->setMarker(pathShape->marker(KoFlake::MidMarker));
727 }
729 d->endMarkerSelector->setMarker(pathShape->marker(KoFlake::EndMarker));
730 }
731 }
732
733 const bool lineOptionsVisible = (d->fillConfigWidget->selectedFillIndex() != 0);
734
735 // This switch statement is to help the tab widget "pages" to be closer to the correct size
736 // if we don't do this the internal widgets get rendered, then the tab page has to get resized to
737 // fill up the space, then the internal widgets have to resize yet again...causing flicker
738 switch(d->fillConfigWidget->selectedFillIndex()) {
739 case 0: // no fill
740 this->setMinimumHeight(130);
741 break;
742 case 1: // solid fill
743 this->setMinimumHeight(200);
744 break;
745 case 2: // gradient fill
746 this->setMinimumHeight(350);
747 case 3: // pattern fill
748 break;
749 }
750
751
752 d->ui->thicknessLineBreak->setVisible(lineOptionsVisible);
753 d->ui->lineWidth->setVisible(lineOptionsVisible);
754 d->ui->capNJoinButton->setVisible(lineOptionsVisible);
755 d->ui->lineStyle->setVisible(lineOptionsVisible);
756 d->startMarkerSelector->setVisible(lineOptionsVisible);
757 d->midMarkerSelector->setVisible(lineOptionsVisible);
758 d->endMarkerSelector->setVisible(lineOptionsVisible);
759 d->ui->thicknessLabel->setVisible(lineOptionsVisible);
760 d->ui->strokeStyleLabel->setVisible(lineOptionsVisible);
761
762
763
764 blockChildSignals(false);
765
766 updateStyleControlsAvailability(!shapes.isEmpty());
767
768}
KoMarker * marker(KoFlake::MarkerPosition pos) const
virtual KoShapeStrokeModelSP stroke() const
Definition KoShape.cpp:885
void blockChildSignals(bool block)
void setUnit(const KoUnit &unit, KoShape *representativeShape)
#define KIS_SAFE_ASSERT_RECOVER_RETURN(cond)
Definition kis_assert.h:128
QString button(const QWheelEvent &ev)
bool compareShapePropertiesEqual(const QList< KoShape * > shapes, const Policy &policy)

References blockChildSignals(), button(), Private::canvas, capStyle(), KoFlake::compareShapePropertiesEqual(), d, KoFlake::EndMarker, joinStyle(), KIS_SAFE_ASSERT_RECOVER_RETURN, KoPathShape::marker(), KoFlake::MidMarker, KoSelection::selectedEditableShapes(), KisCanvas2::selectedShapesProxy, KisSelectedShapesProxy::selection(), setUnit(), KoFlake::StartMarker, KoShape::stroke(), KisCanvas2::unit(), and updateStyleControlsAvailability().

◆ setActive()

void KoStrokeConfigWidget::setActive ( bool active)

Definition at line 489 of file KoStrokeConfigWidget.cpp.

490{
491 d->active = active;
492}

References active, and d.

◆ setNoSelectionTrackingMode()

void KoStrokeConfigWidget::setNoSelectionTrackingMode ( bool value)

Definition at line 330 of file KoStrokeConfigWidget.cpp.

331{
332 d->fillConfigWidget->setNoSelectionTrackingMode(value);
333 d->noSelectionTrackingMode = value;
334 if (!d->noSelectionTrackingMode) {
335 d->selectionChangedCompressor.start();
336 }
337}

References d, and value().

◆ setUnit()

void KoStrokeConfigWidget::setUnit ( const KoUnit & unit,
KoShape * representativeShape )
private

KoStrokeShape knows nothing about the transformations applied to the shape, which doesn't prevent the shape to apply them and display the stroke differently. So just take that into account and show the user correct values using the multiplier in KoUnit.

Definition at line 410 of file KoStrokeConfigWidget.cpp.

411{
412 if (!d->allowLocalUnitManagement) {
413 return; //the unit management is completely transferred to the unitManagers.
414 }
415
416 blockChildSignals(true);
417
424 KoUnit newUnit(unit);
425 if (representativeShape) {
426 newUnit.adjustByPixelTransform(representativeShape->absoluteTransformation());
427 }
428
429 d->ui->lineWidth->setUnit(newUnit);
430 d->capNJoinMenu->miterLimit->setUnit(newUnit);
431
432 d->ui->lineWidth->setLineStep(1.0);
433 d->capNJoinMenu->miterLimit->setLineStep(1.0);
434
435 blockChildSignals(false);
436}
QTransform absoluteTransformation() const
Definition KoShape.cpp:330

References KoShape::absoluteTransformation(), KoUnit::adjustByPixelTransform(), blockChildSignals(), and d.

◆ setUnitManagers()

void KoStrokeConfigWidget::setUnitManagers ( KisSpinBoxUnitManager * managerLineWidth,
KisSpinBoxUnitManager * managerMitterLimit )

Definition at line 438 of file KoStrokeConfigWidget.cpp.

440{
441 blockChildSignals(true);
442 d->allowLocalUnitManagement = false;
443 d->ui->lineWidth->setUnitManager(managerLineWidth);
444 d->capNJoinMenu->miterLimit->setUnitManager(managerMitterLimit);
445 blockChildSignals(false);
446}

References blockChildSignals(), and d.

◆ sigStrokeChanged

void KoStrokeConfigWidget::sigStrokeChanged ( )
signal

◆ startMarker()

KoMarker * KoStrokeConfigWidget::startMarker ( ) const

Definition at line 363 of file KoStrokeConfigWidget.cpp.

364{
365 return d->startMarkerSelector->marker();
366}

References d.

◆ updateMarkers

void KoStrokeConfigWidget::updateMarkers ( const QList< KoMarker * > & markers)
privateslot

Definition at line 448 of file KoStrokeConfigWidget.cpp.

449{
450 d->startMarkerSelector->updateMarkers(markers);
451 d->midMarkerSelector->updateMarkers(markers);
452 d->endMarkerSelector->updateMarkers(markers);
453}

References d.

◆ updateStyleControlsAvailability()

void KoStrokeConfigWidget::updateStyleControlsAvailability ( bool enabled)

Definition at line 399 of file KoStrokeConfigWidget.cpp.

400{
401 d->ui->lineWidth->setEnabled(enabled);
402 d->capNJoinMenu->setEnabled(enabled);
403 d->ui->lineStyle->setEnabled(enabled);
404
405 d->startMarkerSelector->setEnabled(enabled);
406 d->midMarkerSelector->setEnabled(enabled);
407 d->endMarkerSelector->setEnabled(enabled);
408}

References d.

Member Data Documentation

◆ active

bool KoStrokeConfigWidget::active {true}

Definition at line 174 of file KoStrokeConfigWidget.cpp.

174{true};

◆ allowLocalUnitManagement

bool KoStrokeConfigWidget::allowLocalUnitManagement {false}

Definition at line 175 of file KoStrokeConfigWidget.cpp.

175{false};

◆ canvas

KoCanvasBase* KoStrokeConfigWidget::canvas {0}

Definition at line 172 of file KoStrokeConfigWidget.cpp.

172{0};

◆ capNJoinMenu

CapNJoinMenu* KoStrokeConfigWidget::capNJoinMenu {0}

Definition at line 168 of file KoStrokeConfigWidget.cpp.

168{0};

◆ d

Private* const KoStrokeConfigWidget::d
private

Definition at line 102 of file KoStrokeConfigWidget.h.

◆ deactivationLocks

std::vector<KisAcyclicSignalConnector::Blocker> KoStrokeConfigWidget::deactivationLocks

Definition at line 184 of file KoStrokeConfigWidget.cpp.

◆ endMarkerSelector

KoMarkerSelector* KoStrokeConfigWidget::endMarkerSelector {0}

Definition at line 166 of file KoStrokeConfigWidget.cpp.

166{0};

◆ fillConfigWidget

KoFillConfigWidget* KoStrokeConfigWidget::fillConfigWidget {0}

Definition at line 177 of file KoStrokeConfigWidget.cpp.

177{0};

◆ lineStyle

Qt::PenStyle KoStrokeConfigWidget::lineStyle {0}

Definition at line 162 of file KoStrokeConfigWidget.cpp.

162{0};

◆ lineWidth

qreal KoStrokeConfigWidget::lineWidth {0}

Definition at line 163 of file KoStrokeConfigWidget.cpp.

163{0};

◆ midMarkerSelector

KoMarkerSelector* KoStrokeConfigWidget::midMarkerSelector {0}

Definition at line 165 of file KoStrokeConfigWidget.cpp.

165{0};

◆ noSelectionTrackingMode

bool KoStrokeConfigWidget::noSelectionTrackingMode {false}

Definition at line 178 of file KoStrokeConfigWidget.cpp.

178{false};

◆ resourceManagerAcyclicConnector

KisAcyclicSignalConnector KoStrokeConfigWidget::resourceManagerAcyclicConnector

Definition at line 181 of file KoStrokeConfigWidget.cpp.

◆ selectionChangedCompressor

KisSignalCompressor KoStrokeConfigWidget::selectionChangedCompressor

Definition at line 182 of file KoStrokeConfigWidget.cpp.

◆ separatorLine

QFrame* KoStrokeConfigWidget::separatorLine

Definition at line 58 of file KoStrokeConfigWidget.h.

◆ shapeChangedAcyclicConnector

KisAcyclicSignalConnector KoStrokeConfigWidget::shapeChangedAcyclicConnector

Definition at line 180 of file KoStrokeConfigWidget.cpp.

◆ spacer

QWidget* KoStrokeConfigWidget::spacer {0}

Definition at line 170 of file KoStrokeConfigWidget.cpp.

170{0};

◆ startMarkerSelector

KoMarkerSelector* KoStrokeConfigWidget::startMarkerSelector {0}

Definition at line 164 of file KoStrokeConfigWidget.cpp.

164{0};

◆ strokeStyleLabel

QLabel* KoStrokeConfigWidget::strokeStyleLabel

Definition at line 57 of file KoStrokeConfigWidget.h.

◆ thicknessLabel

QLabel* KoStrokeConfigWidget::thicknessLabel

Definition at line 56 of file KoStrokeConfigWidget.h.

◆ ui

QScopedPointer<Ui_KoStrokeConfigWidget> KoStrokeConfigWidget::ui

Definition at line 186 of file KoStrokeConfigWidget.cpp.


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