mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2026-10-13 08:14:13 +02:00
Cancel a picture's handle drag with Escape
Pressing Escape while a handle of a picture was dragged went to DiagramView, which clears the selection. That removed the handles under the mouse, so the drag stopped where it was: the picture kept the new size, angle or pivot, and since the release never arrived, no undo step was recorded and the change could not be undone. Diagram gets a keyboardItem: an item in a state Escape must end. While a resize, rotate, skew or pivot handle is dragged, the picture is that item; DiagramView sends each key to it first, and only keys it does not take reach the view's own shortcuts. Escape puts the picture back as it was when the handle was pressed (position, transform, and whether the pivot was placed by hand) and ignores the rest of the gesture, so no undo step is recorded. The drag also ends when the handles go away. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1155,6 +1155,17 @@ void DiagramView::keyPressEvent(QKeyEvent *e)
|
||||
if (m_event_interface && m_event_interface->keyPressEvent(e))
|
||||
return;
|
||||
|
||||
//An item in a state Escape must end -- a picture while one of its
|
||||
//handles is dragged -- sees each key before the shortcuts below,
|
||||
//which would otherwise clear the selection under it.
|
||||
QGraphicsObject *keyboard_item = m_diagram ? m_diagram->keyboardItem() : nullptr;
|
||||
if (keyboard_item && keyboard_item->scene() == m_diagram) {
|
||||
e->ignore();
|
||||
m_diagram->sendEvent(keyboard_item, e);
|
||||
if (e->isAccepted())
|
||||
return;
|
||||
}
|
||||
|
||||
ProjectView *current_project = this->diagramEditor()->currentProjectView();
|
||||
DiagramContent dc(m_diagram);
|
||||
switch(e -> key())
|
||||
|
||||
Reference in New Issue
Block a user