Commit 5f783c40 authored by Dmitry Kazakov's avatar Dmitry Kazakov

Merge branch 'kazakov/vector-color-fix-381784'

parents 59d8e622 2d817ba7
......@@ -162,6 +162,11 @@ void KisAcyclicSignalConnector::unlock()
}
}
bool KisAcyclicSignalConnector::isLocked() const
{
return m_signalsBlocked;
}
void KisAcyclicSignalConnector::coordinatedLock()
{
m_signalsBlocked++;
......
......@@ -124,6 +124,12 @@ public:
*/
void unlock();
/**
* \return true if the connector is locked by some signal or manually.
* Used for debugging purposes mostly.
*/
bool isLocked() const;
/**
* @brief create a coordinated connector that can be used for extending
* the number of self-locking connection.
......
......@@ -201,14 +201,13 @@ public:
KisSignalCompressor shapeChangedCompressor;
KoFlake::FillVariant fillVariant;
QList<KoShape*> previousShapeSelected;/// container to see if the selection has actually changed
bool noSelectionTrackingMode;
Ui_KoFillConfigWidget *ui;
std::vector<KisAcyclicSignalConnector::Blocker> deactivationLocks;
boost::optional<KoColor> overriddenColorFromProvider;
};
KoFillConfigWidget::KoFillConfigWidget(KoCanvasBase *canvas, KoFlake::FillVariant fillVariant, bool trackShapeSelection, QWidget *parent)
......@@ -239,6 +238,10 @@ KoFillConfigWidget::KoFillConfigWidget(KoCanvasBase *canvas, KoFlake::FillVarian
this, SIGNAL(sigInternalRequestColorToResourceManager()),
this, SLOT(slotProposeCurrentColorToResourceManager()));
KisAcyclicSignalConnector *resetConnector = d->resourceManagerAcyclicConnector.createCoordinatedConnector();
resetConnector->connectForwardVoid(
this, SIGNAL(sigInternalRecoverColorInResourceManager()),
this, SLOT(slotRecoverColorInResourceManager()));
// configure GUI
......@@ -348,6 +351,8 @@ void KoFillConfigWidget::activate()
void KoFillConfigWidget::deactivate()
{
emit sigInternalRecoverColorInResourceManager();
KIS_SAFE_ASSERT_RECOVER_RETURN(d->deactivationLocks.empty());
d->deactivationLocks.push_back(KisAcyclicSignalConnector::Blocker(d->shapeChangedAcyclicConnector));
d->deactivationLocks.push_back(KisAcyclicSignalConnector::Blocker(d->resourceManagerAcyclicConnector));
......@@ -518,6 +523,8 @@ void KoFillConfigWidget::colorChanged()
return;
}
d->overriddenColorFromProvider = boost::none;
KoShapeFillWrapper wrapper(selectedShapes, d->fillVariant);
......@@ -573,6 +580,11 @@ void KoFillConfigWidget::slotProposeCurrentColorToResourceManager()
}
if (hasColor) {
if (!d->overriddenColorFromProvider) {
d->overriddenColorFromProvider =
d->canvas->resourceManager()->resource(colorSlot).value<KoColor>();
}
/**
* Don't let opacity leak to our resource manager system
*
......@@ -584,6 +596,19 @@ void KoFillConfigWidget::slotProposeCurrentColorToResourceManager()
}
}
void KoFillConfigWidget::slotRecoverColorInResourceManager()
{
if (d->overriddenColorFromProvider) {
KoCanvasResourceProvider::CanvasResource colorSlot = KoCanvasResourceProvider::ForegroundColor;
if (d->fillVariant == KoFlake::StrokeFill) {
colorSlot = KoCanvasResourceProvider::BackgroundColor;
}
d->canvas->resourceManager()->setResource(colorSlot, QVariant::fromValue(*d->overriddenColorFromProvider));
d->overriddenColorFromProvider = boost::none;
}
}
template <class ResourceServer>
QString findFirstAvailableResourceName(const QString &baseName, ResourceServer *server)
{
......@@ -770,12 +795,7 @@ void KoFillConfigWidget::shapeChanged()
QList<KoShape*> shapes = currentShapes();
// check to see if the shape actually changed...or is still the same shape
if (d->previousShapeSelected == shapes) {
return;
} else {
d->previousShapeSelected = shapes;
}
bool shouldUploadColorToResourceManager = false;
if (shapes.isEmpty() ||
(shapes.size() > 1 && KoShapeFillWrapper(shapes, d->fillVariant).isMixedFill())) {
......@@ -793,6 +813,8 @@ void KoFillConfigWidget::shapeChanged()
KoShape *shape = shapes.first();
updateFillIndexFromShape(shape);
updateFillColorFromShape(shape); // updates tool options fields
shouldUploadColorToResourceManager = true;
}
// updates the UI
......@@ -800,6 +822,12 @@ void KoFillConfigWidget::shapeChanged()
updateWidgetComponentVisbility();
slotUpdateFillTitle();
if (shouldUploadColorToResourceManager) {
emit sigInternalRequestColorToResourceManager();
} else {
emit sigInternalRecoverColorInResourceManager();
}
}
void KoFillConfigWidget::updateFillIndexFromShape(KoShape *shape)
......
......@@ -98,11 +98,13 @@ private Q_SLOTS:
void slotGradientRepeatChanged();
void slotProposeCurrentColorToResourceManager();
void slotRecoverColorInResourceManager();
Q_SIGNALS:
void sigFillChanged();
void sigInternalRequestColorToResourceManager();
void sigInternalRecoverColorInResourceManager();
private:
void uploadNewGradientBackground(const QGradient *gradient);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment