Commit ca727831 authored by Tusooa Zhu's avatar Tusooa Zhu 🔼

Implement the cloning of reference images

There is still a display bug. After switching to another snapshots,
the reference images are not visible but are selectable.
parent bc54383d
......@@ -489,6 +489,9 @@ KisDocument::KisDocument(const KisDocument &rhs)
d->preActivatedNode =
KisLayerUtils::findNodeByUuid(d->image->root(), rhs.d->preActivatedNode->uuid());
}
KisNodeSP foundNode = KisLayerUtils::recursiveFindNode(image()->rootLayer(), [](KisNodeSP node) -> bool { return dynamic_cast<KisReferenceImagesLayer *>(node.data()); });
KisReferenceImagesLayer *refLayer = dynamic_cast<KisReferenceImagesLayer *>(foundNode.data());
setReferenceImagesLayer(refLayer, /* updateImage = */ false);
}
KisDocument::~KisDocument()
......@@ -823,6 +826,9 @@ void KisDocument::copyFromDocument(const KisDocument &rhs)
}
});
}
KisNodeSP foundNode = KisLayerUtils::recursiveFindNode(image()->rootLayer(), [](KisNodeSP node) -> bool { return dynamic_cast<KisReferenceImagesLayer *>(node.data()); });
KisReferenceImagesLayer *refLayer = dynamic_cast<KisReferenceImagesLayer *>(foundNode.data());
setReferenceImagesLayer(refLayer, /* updateImage = */ false);
}
bool KisDocument::exportDocumentSync(const QUrl &url, const QByteArray &mimeType, KisPropertiesConfigurationSP exportConfiguration)
......@@ -1957,6 +1963,10 @@ KisSharedPtr<KisReferenceImagesLayer> KisDocument::referenceImagesLayer() const
void KisDocument::setReferenceImagesLayer(KisSharedPtr<KisReferenceImagesLayer> layer, bool updateImage)
{
if (d->referenceImagesLayer == layer) {
return;
}
if (d->referenceImagesLayer) {
d->referenceImagesLayer->disconnect(this);
}
......@@ -1975,6 +1985,7 @@ void KisDocument::setReferenceImagesLayer(KisSharedPtr<KisReferenceImagesLayer>
connect(d->referenceImagesLayer, SIGNAL(sigUpdateCanvas(QRectF)),
this, SIGNAL(sigReferenceImagesChanged()));
}
emit sigReferenceImagesLayerChanged(layer);
}
void KisDocument::setPreActivatedNode(KisNodeSP activatedNode)
......
......@@ -465,6 +465,8 @@ Q_SIGNALS:
void sigGridConfigChanged(const KisGridConfig &config);
void sigReferenceImagesLayerChanged(KisSharedPtr<KisReferenceImagesLayer> layer);
private Q_SLOTS:
void finishExportInBackground();
void slotChildCompletedSavingInBackground(KisImportExportErrorCode status, const QString &errorMessage);
......
......@@ -122,7 +122,10 @@ public:
void rerenderAfterBeingInvisible() override {}
void resetCache() override {}
void setImage(KisImageWSP /*image*/) override {}
void setImage(KisImageWSP image) override
{
m_viewConverter->setImage(image);
}
private:
KisReferenceImagesLayer *m_layer;
......
......@@ -57,6 +57,7 @@ void ToolReferenceImages::activate(ToolActivation toolActivation, const QSet<KoS
auto kisCanvas = dynamic_cast<KisCanvas2*>(canvas());
connect(kisCanvas->image(), SIGNAL(sigNodeAddedAsync(KisNodeSP)), this, SLOT(slotNodeAdded(KisNodeSP)));
connect(kisCanvas->imageView()->document(), &KisDocument::sigReferenceImagesLayerChanged, this, &ToolReferenceImages::slotNodeAdded);
auto referenceImageLayer = document()->referenceImagesLayer();
if (referenceImageLayer) {
......
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