From a8074ba1f23b8297f98f60e88429d6a1d7d30b9d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Basile=20Cl=C3=A9ment?= Date: Thu, 1 May 2025 21:22:20 +0200 Subject: [PATCH] fix: Prevent dragged cards getting stuck Update the position of the card even if it is not above any zone. --- cockatrice/src/game/board/card_drag_item.cpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/cockatrice/src/game/board/card_drag_item.cpp b/cockatrice/src/game/board/card_drag_item.cpp index d21e9168b..298c5f59e 100644 --- a/cockatrice/src/game/board/card_drag_item.cpp +++ b/cockatrice/src/game/board/card_drag_item.cpp @@ -47,8 +47,19 @@ void CardDragItem::updatePosition(const QPointF &cursorScenePos) cursorZone = zoneViewZone; else if (cardZone) cursorZone = cardZone; - if (!cursorZone) + if (!cursorZone) { + // Temporary fix: avoid the cards getting stuck visually when not over + // any zone. + QPointF newPos = cursorScenePos - hotSpot; + + if (newPos != pos()) { + for (int i = 0; i < childDrags.size(); i++) + childDrags[i]->setPos(newPos + childDrags[i]->getHotSpot()); + setPos(newPos); + } + return; + } currentZone = cursorZone; QPointF zonePos = currentZone->scenePos();