Commit 420e7aeb authored by Amy spark's avatar Amy spark 👉
Browse files

Consistently position native and bitmap pastes at cursor center

BUG: 453247
parent 6c5a713b
......@@ -213,27 +213,43 @@ void KisPasteActionFactory::run(bool pasteAtCursorPosition, KisViewManager *view
return;
}
const QRect fittingBounds =
pasteAtCursorPosition ? QRect() : image->bounds();
// If no shapes, check for layers
if (KisClipboard::instance()->hasLayers() && !pasteAtCursorPosition) {
view->nodeManager()->pasteLayersFromClipboard();
if (KisClipboard::instance()->hasLayers()) {
const QPointF offsetTopLeft = [&]() -> QPointF {
if (pasteAtCursorPosition) {
KisPaintDeviceSP clip =
KisClipboard::instance()->clipFromKritaLayers(
fittingBounds,
image->colorSpace());
KIS_ASSERT(clip);
const QPointF imagePos =
view->canvasBase()->coordinatesConverter()->documentToImage(
docPos);
const QPointF offset =
(imagePos - QRectF(clip->exactBounds()).center()).toPoint();
return offset;
} else {
return {};
}
}();
view->nodeManager()->pasteLayersFromClipboard(pasteAtCursorPosition,
offsetTopLeft);
return;
}
KisTimeSpan range;
const QRect fittingBounds = pasteAtCursorPosition ? QRect() : image->bounds();
KisPaintDeviceSP clip = KisClipboard::instance()->clip(fittingBounds, true, -1, &range);
if (clip) {
if (pasteAtCursorPosition) {
const QPointF imagePos = view->canvasBase()->coordinatesConverter()->documentToImage(docPos);
const QPointF offset = (imagePos - QRectF(clip->exactBounds()).center()).toPoint();
const QPointF offsetTopLeft = (offset + QRectF(clip->exactBounds()).topLeft()).toPoint();
if (KisClipboard::instance()->hasLayers()) {
view->nodeManager()->pasteLayersFromClipboard(pasteAtCursorPosition, offsetTopLeft);
return;
}
const QPoint offset =
(imagePos - QRectF(clip->exactBounds()).center()).toPoint();
clip->setX(clip->x() + offset.x());
clip->setY(clip->y() + offset.y());
......
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