From 1d816f432c6135d048cd2e3449f081b1458deafd Mon Sep 17 00:00:00 2001 From: ispyisail Date: Tue, 29 Sep 2026 23:09:57 +1300 Subject: [PATCH] Fix the right-click menu offering Group again after grouping (#1144) Group and Ungroup are enabled in slot_updateComplexActions(), which ran only when the selection changed. Grouping, ungrouping and undoing either leave the selection as it is, and so does right-clicking an item that is already selected, so the actions kept the state from before. The right-click menu hides disabled actions, so it went on showing Group on a selection that was now one group (and Ungroup after ungrouping), and the one that would work was not in the menu at all. Diagram::setItemGroup() is the one place an item's group changes (group, ungroup, undo, redo, paste), so it now emits itemGroupChanged() and the editor refreshes its actions on it, beside the selectionChanged connection. Checked in the GUI on two free texts, saving after each step: right-click > Group, right-click again, Ctrl+Z, right-click again. Before, the second and third right-clicks offered Group again and did nothing (both saves still grouped). After, they offered Ungroup and ungrouped (0 grouped texts in both saves); Group, Ungroup, Group also round-trips. Co-Authored-By: Claude Opus 5.5 (1M context) --- sources/diagram.cpp | 1 + sources/diagram.h | 4 ++++ sources/qetdiagrameditor.cpp | 6 ++++++ 3 files changed, 11 insertions(+) diff --git a/sources/diagram.cpp b/sources/diagram.cpp index 3bb984338..f7c336ed6 100644 --- a/sources/diagram.cpp +++ b/sources/diagram.cpp @@ -2279,6 +2279,7 @@ void Diagram::setItemGroup(QGraphicsItem *item, const QUuid &group) if (m_project) { m_project->dataBase()->itemGroupChanged(item); } + emit itemGroupChanged(); } /** diff --git a/sources/diagram.h b/sources/diagram.h index 96299d036..ff7ff1f9b 100644 --- a/sources/diagram.h +++ b/sources/diagram.h @@ -325,6 +325,10 @@ class Diagram : public QGraphicsScene void diagramActivated(); void diagramInformationChanged(); + + /// Emitted by setItemGroup(): an item joined or left a group + /// without the selection changing (#1144) + void itemGroupChanged(); }; Q_DECLARE_METATYPE(Diagram *) diff --git a/sources/qetdiagrameditor.cpp b/sources/qetdiagrameditor.cpp index e28927dcd..46cec2c5d 100644 --- a/sources/qetdiagrameditor.cpp +++ b/sources/qetdiagrameditor.cpp @@ -3185,6 +3185,12 @@ void QETDiagramEditor::diagramWasAdded(DiagramView *dv) this, &QETDiagramEditor::selectionChanged, Qt::DirectConnection); + //Grouping leaves the selection as it is, so without this Group + //and Ungroup would keep the state from before (#1144) + connect(dv->diagram(), + &Diagram::itemGroupChanged, + this, + &QETDiagramEditor::slot_updateComplexActions); connect(dv, &DiagramView::modeChanged, this, &QETDiagramEditor::slot_updateModeActions); connect(dv, &DiagramView::elementPlacementStarted, this, &QETDiagramEditor::rememberPlacedElement); }