From c32a4f60b0147e6c221deda21567049a5c631333 Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Mon, 6 Sep 2021 18:29:59 +0300 Subject: [PATCH] Place a piece according to margins values. --- src/app/puzzle/carousel/vpcarrouselpiecelist.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/app/puzzle/carousel/vpcarrouselpiecelist.cpp b/src/app/puzzle/carousel/vpcarrouselpiecelist.cpp index c39fa26cc..b4538f0a7 100644 --- a/src/app/puzzle/carousel/vpcarrouselpiecelist.cpp +++ b/src/app/puzzle/carousel/vpcarrouselpiecelist.cpp @@ -210,9 +210,15 @@ void VPCarrouselPieceList::contextMenuEvent(QContextMenuEvent *event) if (selectedAction == moveAction) { - piece->ClearTransformations(); - auto *command = new VPUndoMovePieceOnSheet(layout->GetFocusedSheet(), piece); - layout->UndoStack()->push(command); + VPSheetPtr sheet = layout->GetFocusedSheet(); + if (not sheet.isNull()) + { + piece->ClearTransformations(); + QRectF rect = sheet->GetMarginsRect(); + piece->SetPosition(QPointF(rect.topLeft().x() + 1, rect.topLeft().y() + 1)); + auto *command = new VPUndoMovePieceOnSheet(layout->GetFocusedSheet(), piece); + layout->UndoStack()->push(command); + } } else if (selectedAction == deleteAction) {