Commit 8d0c0c41 authored by Amy spark's avatar Amy spark 👉
Browse files

Paste into Active Layer: allow native pasting once again

This commit partially reverts commit
84dc357b.

CCBUG: 453247
(cherry picked from commit 6c5a713b)
parent bd5563ba
......@@ -283,8 +283,16 @@ void KisPasteIntoActionFactory::run(KisViewManager *viewManager)
KisImageSP image = viewManager->image();
if (!image) return;
KisPaintDeviceSP clip = KisClipboard::instance()->clip(image->bounds(), true, -1, nullptr);
if (!clip) return;
KisPaintDeviceSP clip =
KisClipboard::instance()->clipFromKritaLayers(image->bounds(),
image->colorSpace());
if (!clip)
clip =
KisClipboard::instance()->clip(image->bounds(), true, -1, nullptr);
if (!clip)
return;
KisImportCatcher::adaptClipToImageColorSpace(clip, image);
......
......@@ -311,6 +311,34 @@ KisClipboard::clipFromKritaSelection(const QMimeData *cbData, const QRect &image
return clip;
}
KisPaintDeviceSP KisClipboard::clipFromKritaLayers(const QRect &imageBounds,
const KoColorSpace *cs) const
{
const QMimeData *data = KisClipboard::instance()->layersMimeData();
if (!data) {
return nullptr;
}
const auto *mimedata = qobject_cast<const KisMimeData *>(data);
KIS_ASSERT_RECOVER_RETURN_VALUE(mimedata, nullptr);
KisNodeList nodes = mimedata->nodes();
KisImageSP tempImage = new KisImage(nullptr,
imageBounds.width(),
imageBounds.height(),
cs,
"ClipImage");
for (KisNodeSP node : nodes) {
tempImage->addNode(node, tempImage->root());
}
tempImage->refreshGraphAsync();
tempImage->waitForDone();
return tempImage->projection();
}
KisPaintDeviceSP KisClipboard::clipFromBoardContents(const QMimeData *cbData,
const QRect &imageBounds,
bool showPopup,
......@@ -567,7 +595,8 @@ void KisClipboard::setLayers(KisNodeList nodes, KisImageSP image, bool forceCopy
bool KisClipboard::hasLayers() const
{
return d->clipboard->mimeData()->hasFormat("application/x-krita-node");
const QByteArray mimeType = QByteArrayLiteral("application/x-krita-node");
return d->clipboard->mimeData()->hasFormat(mimeType);
}
bool KisClipboard::hasLayerStyles() const
......
......@@ -13,7 +13,6 @@
#include <QObject>
#include <QSize>
#include <KoColorProfile.h>
#include <kis_types.h>
#include <kritaui_export.h>
......@@ -21,6 +20,7 @@
class QRect;
class QMimeData;
class KisTimeSpan;
class KoColorSpace;
class KisClipboardPrivate;
......@@ -74,6 +74,9 @@ public:
KisTimeSpan *clipRange = nullptr,
bool useClipboardFallback = false) const;
KisPaintDeviceSP clipFromKritaLayers(const QRect &imageBounds,
const KoColorSpace *cs) const;
bool hasClip() const;
QSize clipSize() const;
......
Supports Markdown
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