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 151 of file KoStrokeConfigWidget.cpp.

Constructor & Destructor Documentation

◆ KoStrokeConfigWidget()

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

Definition at line 187 of file KoStrokeConfigWidget.cpp.

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

323{
324 delete d;
325}

References d.

Member Function Documentation

◆ activate()

void KoStrokeConfigWidget::activate ( )

Definition at line 452 of file KoStrokeConfigWidget.cpp.

453{
454 KIS_SAFE_ASSERT_RECOVER_NOOP(!d->deactivationLocks.empty());
455 d->deactivationLocks.clear();
456 d->fillConfigWidget->activate();
457
458 if (!d->noSelectionTrackingMode) {
459 d->selectionChangedCompressor.start();
460 } else {
462 }
463}
#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 510 of file KoStrokeConfigWidget.cpp.

511{
513 d->canvas,
514 [this] (KoShapeStrokeSP stroke) {
515 stroke->setLineStyle(lineStyle(), lineDashes());
516 });
517
518 Q_EMIT sigStrokeChanged();
519}
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 532 of file KoStrokeConfigWidget.cpp.

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

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

◆ applyLineWidthChanges

void KoStrokeConfigWidget::applyLineWidthChanges ( )
privateslot

Definition at line 521 of file KoStrokeConfigWidget.cpp.

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

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

◆ applyMarkerChanges

void KoStrokeConfigWidget::applyMarkerChanges ( int rawPosition)
privateslot

apply marker changes to the selected shape

Definition at line 546 of file KoStrokeConfigWidget.cpp.

547{
549 if (!selection) {
550 Q_EMIT sigStrokeChanged();
551 return;
552 }
553
554 QList<KoShape*> shapes = selection->selectedEditableShapes();
555 QList<KoPathShape*> pathShapes;
556 Q_FOREACH (KoShape *shape, shapes) {
557 KoPathShape *pathShape = dynamic_cast<KoPathShape*>(shape);
558 if (pathShape) {
559 pathShapes << pathShape;
560 }
561 }
562
563 if (pathShapes.isEmpty()) {
564 Q_EMIT sigStrokeChanged();
565 return;
566 }
567
568
569 KoFlake::MarkerPosition position = KoFlake::MarkerPosition(rawPosition);
570 QScopedPointer<KoMarker> marker;
571
572 switch (position) {
574 if (d->startMarkerSelector->marker()) {
575 marker.reset(new KoMarker(*d->startMarkerSelector->marker()));
576 }
577 break;
579 if (d->midMarkerSelector->marker()) {
580 marker.reset(new KoMarker(*d->midMarkerSelector->marker()));
581 }
582 break;
584 if (d->endMarkerSelector->marker()) {
585 marker.reset(new KoMarker(*d->endMarkerSelector->marker()));
586 }
587 break;
588 }
589
590 KUndo2Command* command = new KoPathShapeMarkerCommand(pathShapes, marker.take(), position);
591 d->canvas->addCommand(command);
592
593 Q_EMIT sigStrokeChanged();
594}
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 474 of file KoStrokeConfigWidget.cpp.

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

References d.

◆ canvasResourceChanged

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

Definition at line 767 of file KoStrokeConfigWidget.cpp.

768{
769 switch (key) {
771 // we request the whole selection to reload because the
772 // unit of the stroke width depends on the selected shape
773 d->selectionChangedCompressor.start();
774 break;
776 if (d->noSelectionTrackingMode) {
777 d->ui->lineWidth->changeValue(d->canvas->unit().fromUserValue(value.toReal()));
778 }
779 break;
780 }
781}
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 370 of file KoStrokeConfigWidget.cpp.

371{
372 return static_cast<Qt::PenCapStyle>(d->capNJoinMenu->capGroup->checkedId());
373}

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 380 of file KoStrokeConfigWidget.cpp.

381{
382 KoShapeStrokeSP stroke(d->fillConfigWidget->createShapeStroke());
383
384 stroke->setLineWidth(lineWidth());
385 stroke->setCapStyle(capStyle());
386 stroke->setJoinStyle(joinStyle());
387 stroke->setMiterLimit(miterLimit());
388 stroke->setLineStyle(lineStyle(), lineDashes());
389
390 return stroke;
391}
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 465 of file KoStrokeConfigWidget.cpp.

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

References d, and KIS_SAFE_ASSERT_RECOVER_NOOP.

◆ endMarker()

KoMarker * KoStrokeConfigWidget::endMarker ( ) const

Definition at line 365 of file KoStrokeConfigWidget.cpp.

366{
367 return d->endMarkerSelector->marker();
368}

References d.

◆ joinStyle()

Qt::PenJoinStyle KoStrokeConfigWidget::joinStyle ( ) const

Definition at line 375 of file KoStrokeConfigWidget.cpp.

376{
377 return static_cast<Qt::PenJoinStyle>(d->capNJoinMenu->joinGroup->checkedId());
378}

References d.

◆ lineDashes()

QVector< qreal > KoStrokeConfigWidget::lineDashes ( ) const

Definition at line 345 of file KoStrokeConfigWidget.cpp.

346{
347 return d->ui->lineStyle->lineDashes();
348}

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 355 of file KoStrokeConfigWidget.cpp.

356{
357 return d->capNJoinMenu->miterLimit->value();
358}

References d.

◆ Private()

KoStrokeConfigWidget::Private ( )
inline

◆ selectionChanged

void KoStrokeConfigWidget::selectionChanged ( )
privateslot

selection has changed

Definition at line 653 of file KoStrokeConfigWidget.cpp.

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

487{
488 d->active = active;
489}

References active, and d.

◆ setNoSelectionTrackingMode()

void KoStrokeConfigWidget::setNoSelectionTrackingMode ( bool value)

Definition at line 327 of file KoStrokeConfigWidget.cpp.

328{
329 d->fillConfigWidget->setNoSelectionTrackingMode(value);
330 d->noSelectionTrackingMode = value;
331 if (!d->noSelectionTrackingMode) {
332 d->selectionChangedCompressor.start();
333 }
334}

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 407 of file KoStrokeConfigWidget.cpp.

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

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

◆ setUnitManagers()

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

Definition at line 435 of file KoStrokeConfigWidget.cpp.

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

References blockChildSignals(), and d.

◆ sigStrokeChanged

void KoStrokeConfigWidget::sigStrokeChanged ( )
signal

◆ startMarker()

KoMarker * KoStrokeConfigWidget::startMarker ( ) const

Definition at line 360 of file KoStrokeConfigWidget.cpp.

361{
362 return d->startMarkerSelector->marker();
363}

References d.

◆ updateMarkers

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

Definition at line 445 of file KoStrokeConfigWidget.cpp.

446{
447 d->startMarkerSelector->updateMarkers(markers);
448 d->midMarkerSelector->updateMarkers(markers);
449 d->endMarkerSelector->updateMarkers(markers);
450}

References d.

◆ updateStyleControlsAvailability()

void KoStrokeConfigWidget::updateStyleControlsAvailability ( bool enabled)

Definition at line 396 of file KoStrokeConfigWidget.cpp.

397{
398 d->ui->lineWidth->setEnabled(enabled);
399 d->capNJoinMenu->setEnabled(enabled);
400 d->ui->lineStyle->setEnabled(enabled);
401
402 d->startMarkerSelector->setEnabled(enabled);
403 d->midMarkerSelector->setEnabled(enabled);
404 d->endMarkerSelector->setEnabled(enabled);
405}

References d.

Member Data Documentation

◆ active

bool KoStrokeConfigWidget::active {true}

Definition at line 171 of file KoStrokeConfigWidget.cpp.

171{true};

◆ allowLocalUnitManagement

bool KoStrokeConfigWidget::allowLocalUnitManagement {false}

Definition at line 172 of file KoStrokeConfigWidget.cpp.

172{false};

◆ canvas

KoCanvasBase* KoStrokeConfigWidget::canvas {0}

Definition at line 169 of file KoStrokeConfigWidget.cpp.

169{0};

◆ capNJoinMenu

CapNJoinMenu* KoStrokeConfigWidget::capNJoinMenu {0}

Definition at line 165 of file KoStrokeConfigWidget.cpp.

165{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 181 of file KoStrokeConfigWidget.cpp.

◆ endMarkerSelector

KoMarkerSelector* KoStrokeConfigWidget::endMarkerSelector {0}

Definition at line 163 of file KoStrokeConfigWidget.cpp.

163{0};

◆ fillConfigWidget

KoFillConfigWidget* KoStrokeConfigWidget::fillConfigWidget {0}

Definition at line 174 of file KoStrokeConfigWidget.cpp.

174{0};

◆ lineStyle

Qt::PenStyle KoStrokeConfigWidget::lineStyle {0}

Definition at line 159 of file KoStrokeConfigWidget.cpp.

159{0};

◆ lineWidth

qreal KoStrokeConfigWidget::lineWidth {0}

Definition at line 160 of file KoStrokeConfigWidget.cpp.

160{0};

◆ midMarkerSelector

KoMarkerSelector* KoStrokeConfigWidget::midMarkerSelector {0}

Definition at line 162 of file KoStrokeConfigWidget.cpp.

162{0};

◆ noSelectionTrackingMode

bool KoStrokeConfigWidget::noSelectionTrackingMode {false}

Definition at line 175 of file KoStrokeConfigWidget.cpp.

175{false};

◆ resourceManagerAcyclicConnector

KisAcyclicSignalConnector KoStrokeConfigWidget::resourceManagerAcyclicConnector

Definition at line 178 of file KoStrokeConfigWidget.cpp.

◆ selectionChangedCompressor

KisSignalCompressor KoStrokeConfigWidget::selectionChangedCompressor

Definition at line 179 of file KoStrokeConfigWidget.cpp.

◆ separatorLine

QFrame* KoStrokeConfigWidget::separatorLine

Definition at line 58 of file KoStrokeConfigWidget.h.

◆ shapeChangedAcyclicConnector

KisAcyclicSignalConnector KoStrokeConfigWidget::shapeChangedAcyclicConnector

Definition at line 177 of file KoStrokeConfigWidget.cpp.

◆ spacer

QWidget* KoStrokeConfigWidget::spacer {0}

Definition at line 167 of file KoStrokeConfigWidget.cpp.

167{0};

◆ startMarkerSelector

KoMarkerSelector* KoStrokeConfigWidget::startMarkerSelector {0}

Definition at line 161 of file KoStrokeConfigWidget.cpp.

161{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 183 of file KoStrokeConfigWidget.cpp.


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