Changeset View
Changeset View
Standalone View
Standalone View
libs/ui/widgets/KoStrokeConfigWidget.cpp
| Context not available. | |||||
| 69 | #include <KoFillConfigWidget.h> | 69 | #include <KoFillConfigWidget.h> | ||
|---|---|---|---|---|---|
| 70 | #include "kis_canvas_resource_provider.h" | 70 | #include "kis_canvas_resource_provider.h" | ||
| 71 | #include "kis_acyclic_signal_connector.h" | 71 | #include "kis_acyclic_signal_connector.h" | ||
| 72 | #include <kis_signal_compressor.h> | ||||
| 72 | 73 | | |||
| 73 | // Krita | 74 | // Krita | ||
| 74 | #include "kis_double_parse_unit_spin_box.h" | 75 | #include "kis_double_parse_unit_spin_box.h" | ||
| Context not available. | |||||
| 169 | active(true), | 170 | active(true), | ||
| 170 | allowLocalUnitManagement(true), | 171 | allowLocalUnitManagement(true), | ||
| 171 | fillConfigWidget(0), | 172 | fillConfigWidget(0), | ||
| 172 | noSelectionTrackingMode(false) | 173 | noSelectionTrackingMode(false), | ||
| 174 | selectionChangedCompressor(200, KisSignalCompressor::FIRST_ACTIVE) | ||||
| 173 | { | 175 | { | ||
| 174 | } | 176 | } | ||
| 175 | 177 | | |||
| Context not available. | |||||
| 193 | 195 | | |||
| 194 | KisAcyclicSignalConnector shapeChangedAcyclicConnector; | 196 | KisAcyclicSignalConnector shapeChangedAcyclicConnector; | ||
| 195 | KisAcyclicSignalConnector resourceManagerAcyclicConnector; | 197 | KisAcyclicSignalConnector resourceManagerAcyclicConnector; | ||
| 198 | KisSignalCompressor selectionChangedCompressor; | ||||
| 199 | | ||||
| 196 | 200 | | |||
| 197 | std::vector<KisAcyclicSignalConnector::Blocker> deactivationLocks; | 201 | std::vector<KisAcyclicSignalConnector::Blocker> deactivationLocks; | ||
| 198 | 202 | | |||
| Context not available. | |||||
| 213 | { // connect the canvas | 217 | { // connect the canvas | ||
| 214 | d->shapeChangedAcyclicConnector.connectBackwardVoid( | 218 | d->shapeChangedAcyclicConnector.connectBackwardVoid( | ||
| 215 | canvas->selectedShapesProxy(), SIGNAL(selectionChanged()), | 219 | canvas->selectedShapesProxy(), SIGNAL(selectionChanged()), | ||
| 216 | this, SLOT(selectionChanged())); | 220 | &d->selectionChangedCompressor, SLOT(start())); | ||
| 217 | 221 | | |||
| 218 | d->shapeChangedAcyclicConnector.connectBackwardVoid( | 222 | d->shapeChangedAcyclicConnector.connectBackwardVoid( | ||
| 219 | canvas->selectedShapesProxy(), SIGNAL(selectionContentChanged()), | 223 | canvas->selectedShapesProxy(), SIGNAL(selectionContentChanged()), | ||
| 220 | this, SLOT(selectionChanged())); | 224 | &d->selectionChangedCompressor, SLOT(start())); | ||
| 225 | | ||||
| 226 | connect(&d->selectionChangedCompressor, SIGNAL(timeout()), this, SLOT(selectionChanged())); | ||||
| 221 | 227 | | |||
| 222 | d->resourceManagerAcyclicConnector.connectBackwardResourcePair( | 228 | d->resourceManagerAcyclicConnector.connectBackwardResourcePair( | ||
| 223 | canvas->resourceManager(), SIGNAL(canvasResourceChanged(int,QVariant)), | 229 | canvas->resourceManager(), SIGNAL(canvasResourceChanged(int,QVariant)), | ||
| Context not available. | |||||
| 226 | d->canvas = canvas; | 232 | d->canvas = canvas; | ||
| 227 | } | 233 | } | ||
| 228 | 234 | | |||
| 229 | | ||||
| 230 | { | 235 | { | ||
| 231 | 236 | | |||
| 232 | d->fillConfigWidget = new KoFillConfigWidget(canvas, KoFlake::StrokeFill, false, this); | 237 | d->fillConfigWidget = new KoFillConfigWidget(canvas, KoFlake::StrokeFill, true, this); | ||
| 233 | d->fillConfigWidget->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::MinimumExpanding); | 238 | d->fillConfigWidget->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::MinimumExpanding); | ||
| 234 | d->ui->fillConfigWidgetLayout->addWidget(d->fillConfigWidget); | 239 | d->ui->fillConfigWidgetLayout->addWidget(d->fillConfigWidget); | ||
| 235 | connect(d->fillConfigWidget, SIGNAL(sigFillChanged()), SIGNAL(sigStrokeChanged())); | 240 | connect(d->fillConfigWidget, SIGNAL(sigFillChanged()), SIGNAL(sigStrokeChanged())); | ||
| Context not available. | |||||
| 239 | d->ui->thicknessLabel->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); | 244 | d->ui->thicknessLabel->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); | ||
| 240 | 245 | | |||
| 241 | // set min/max/step and value in points, then set actual unit | 246 | // set min/max/step and value in points, then set actual unit | ||
| 242 | d->ui->lineWidth->setMinMaxStep(0.0, 1000.0, 0.5); | 247 | d->ui->lineWidth->setMinMaxStep(0.5, 1000.0, 0.5); // if someone wants 0, just set to "none" on UI | ||
| 243 | d->ui->lineWidth->setDecimals(2); | 248 | d->ui->lineWidth->setDecimals(2); | ||
| 244 | d->ui->lineWidth->setUnit(KoUnit(KoUnit::Point)); | 249 | d->ui->lineWidth->setUnit(KoUnit(KoUnit::Point)); | ||
| 245 | d->ui->lineWidth->setToolTip(i18n("Set line width of actual selection")); | 250 | d->ui->lineWidth->setToolTip(i18n("Set line width of actual selection")); | ||
| Context not available. | |||||
| 322 | } | 327 | } | ||
| 323 | } | 328 | } | ||
| 324 | 329 | | |||
| 325 | selectionChanged(); | 330 | d->selectionChangedCompressor.start(); | ||
| 326 | 331 | | |||
| 327 | d->fillConfigWidget->activate(); | 332 | d->fillConfigWidget->activate(); | ||
| 328 | deactivate(); | 333 | deactivate(); | ||
| Context not available. | |||||
| 338 | d->fillConfigWidget->setNoSelectionTrackingMode(value); | 343 | d->fillConfigWidget->setNoSelectionTrackingMode(value); | ||
| 339 | d->noSelectionTrackingMode = value; | 344 | d->noSelectionTrackingMode = value; | ||
| 340 | if (!d->noSelectionTrackingMode) { | 345 | if (!d->noSelectionTrackingMode) { | ||
| 341 | selectionChanged(); | 346 | d->selectionChangedCompressor.start(); | ||
| 342 | } | 347 | } | ||
| 343 | } | 348 | } | ||
| 344 | 349 | | |||
| Context not available. | |||||
| 465 | d->fillConfigWidget->activate(); | 470 | d->fillConfigWidget->activate(); | ||
| 466 | 471 | | |||
| 467 | if (!d->noSelectionTrackingMode) { | 472 | if (!d->noSelectionTrackingMode) { | ||
| 468 | selectionChanged(); | 473 | // selectionChanged(); | ||
| 474 | d->selectionChangedCompressor.start(); | ||||
| 469 | } else { | 475 | } else { | ||
| 470 | loadCurrentStrokeFillFromResourceServer(); | 476 | loadCurrentStrokeFillFromResourceServer(); | ||
| 471 | } | 477 | } | ||
| Context not available. | |||||
| 668 | 674 | | |||
| 669 | // we need to linearize update order, and force the child widget to update | 675 | // we need to linearize update order, and force the child widget to update | ||
| 670 | // before we start doing it | 676 | // before we start doing it | ||
| 671 | d->fillConfigWidget->forceUpdateOnSelectionChanged(); | | |||
| 672 | | ||||
| 673 | 677 | | |||
| 674 | QList<KoShape*> shapes = selection->selectedEditableShapes(); | 678 | QList<KoShape*> shapes = selection->selectedEditableShapes(); | ||
| 675 | 679 | | |||
| 680 | d->fillConfigWidget->forceUpdateOnSelectionChanged(); // calls shapeChanged() logic | ||||
| 681 | | ||||
| 676 | KoShape *shape = !shapes.isEmpty() ? shapes.first() : 0; | 682 | KoShape *shape = !shapes.isEmpty() ? shapes.first() : 0; | ||
| 677 | 683 | | |||
| 678 | const KoShapeStrokeSP stroke = shape ? qSharedPointerDynamicCast<KoShapeStroke>(shape->stroke()) : KoShapeStrokeSP(); | 684 | const KoShapeStrokeSP stroke = shape ? qSharedPointerDynamicCast<KoShapeStroke>(shape->stroke()) : KoShapeStrokeSP(); | ||
| Context not available. | |||||
| 781 | case KoCanvasResourceProvider::Unit: | 787 | case KoCanvasResourceProvider::Unit: | ||
| 782 | // we request the whole selection to reload because the | 788 | // we request the whole selection to reload because the | ||
| 783 | // unit of the stroke width depends on the selected shape | 789 | // unit of the stroke width depends on the selected shape | ||
| 784 | selectionChanged(); | 790 | d->selectionChangedCompressor.start(); | ||
| 785 | break; | 791 | break; | ||
| 786 | case KisCanvasResourceProvider::Size: | 792 | case KisCanvasResourceProvider::Size: | ||
| 787 | if (d->noSelectionTrackingMode) { | 793 | if (d->noSelectionTrackingMode) { | ||
| Context not available. | |||||