From f2343b417e7fe22ab6d78365f7ccb49b773771be Mon Sep 17 00:00:00 2001 From: Thomas Hartmann Date: Tue, 19 Sep 2023 18:17:01 +0200 Subject: [PATCH] QmlDesigner: Close the popup when model is detached This happens when leaving the edit mode or the document is changed. Task-number: QDS-10707 Change-Id: I4b4e2511674d38c2d733db29070c01252c27c386 Reviewed-by: Aleksei German --- .../qmldesigner/connectionseditor/ConnectionsDialog.qml | 2 +- .../components/connectioneditor/connectionmodel.cpp | 7 ++++++- .../components/connectioneditor/connectionmodel.h | 3 ++- .../components/connectioneditor/connectionview.cpp | 1 + 4 files changed, 10 insertions(+), 3 deletions(-) diff --git a/share/qtcreator/qmldesigner/connectionseditor/ConnectionsDialog.qml b/share/qtcreator/qmldesigner/connectionseditor/ConnectionsDialog.qml index 131ae6cee99..53eaad0adf4 100644 --- a/share/qtcreator/qmldesigner/connectionseditor/ConnectionsDialog.qml +++ b/share/qtcreator/qmldesigner/connectionseditor/ConnectionsDialog.qml @@ -43,7 +43,7 @@ PopupDialog { Connections { target: root.backend - function onPopupTargetRemoved() { + function onPopupShouldClose() { root.close() } } diff --git a/src/plugins/qmldesigner/components/connectioneditor/connectionmodel.cpp b/src/plugins/qmldesigner/components/connectioneditor/connectionmodel.cpp index c0b819371a8..54965013a44 100644 --- a/src/plugins/qmldesigner/components/connectioneditor/connectionmodel.cpp +++ b/src/plugins/qmldesigner/components/connectioneditor/connectionmodel.cpp @@ -493,7 +493,7 @@ void ConnectionModel::nodeAboutToBeRemoved(const ModelNode &removedNode) if (selectedSignal.isValid()) { ModelNode targetNode = getTargetNodeForConnection(selectedSignal.parentModelNode()); if (targetNode == removedNode) { - emit m_delegate->popupTargetRemoved(); + emit m_delegate->popupShouldClose(); } } } @@ -2103,4 +2103,9 @@ ConnectionEditorStatements::ComparativeStatement ConditionListModel::toStatement return {}; } +void QmlDesigner::ConnectionModel::modelAboutToBeDetached() +{ + emit m_delegate->popupShouldClose(); +} + } // namespace QmlDesigner diff --git a/src/plugins/qmldesigner/components/connectioneditor/connectionmodel.h b/src/plugins/qmldesigner/components/connectioneditor/connectionmodel.h index d9b13cb22d2..d25d5aa2d3b 100644 --- a/src/plugins/qmldesigner/components/connectioneditor/connectionmodel.h +++ b/src/plugins/qmldesigner/components/connectioneditor/connectionmodel.h @@ -72,6 +72,7 @@ public: void selectProperty(const SignalHandlerProperty &property); void nodeAboutToBeRemoved(const ModelNode &removedNode); + void modelAboutToBeDetached(); signals: void currentIndexChanged(); @@ -298,7 +299,7 @@ signals: void hasConditionChanged(); void hasElseChanged(); void sourceChanged(); - void popupTargetRemoved(); + void popupShouldClose(); private: int currentRow() const; diff --git a/src/plugins/qmldesigner/components/connectioneditor/connectionview.cpp b/src/plugins/qmldesigner/components/connectioneditor/connectionview.cpp index 0b02ee0e34b..b96afd69665 100644 --- a/src/plugins/qmldesigner/components/connectioneditor/connectionview.cpp +++ b/src/plugins/qmldesigner/components/connectioneditor/connectionview.cpp @@ -169,6 +169,7 @@ void ConnectionView::modelAboutToBeDetached(Model *model) bindingModel()->reset(); dynamicPropertiesModel()->reset(); connectionModel()->resetModel(); + connectionModel()->modelAboutToBeDetached(); } void ConnectionView::nodeCreated(const ModelNode & /*createdNode*/)