fix: Prevent dragged cards getting stuck (#5896)

* fix: Prevent dragged cards getting stuck

Update the position of the card even if it is not above any zone.

* Also update the currentZone
This commit is contained in:
Basile Clement 2025-05-02 18:58:21 +02:00 committed by GitHub
parent 77d13090b5
commit 24e27d3c31
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -47,10 +47,25 @@ void CardDragItem::updatePosition(const QPointF &cursorScenePos)
cursorZone = zoneViewZone;
else if (cardZone)
cursorZone = cardZone;
if (!cursorZone)
return;
// Always update the current zone, even if its null, to cancel the drag
// instead of dropping cards into an non-intuitive location.
currentZone = cursorZone;
if (!cursorZone) {
// 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;
}
QPointF zonePos = currentZone->scenePos();
QPointF cursorPosInZone = cursorScenePos - zonePos;