aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Hartmann <thomas.hartmann@qt.io>2023-09-18 17:34:39 +0200
committerThomas Hartmann <thomas.hartmann@qt.io>2023-09-18 15:54:39 +0000
commit1b9ed62028a60a4cf155bca82cea553c8390952f (patch)
treea5e9c02f5b9cd11311d7b16db20a0d6fd0588091
parentffa4aba2c8d3b5cf30ddf609d7a9d8d6409551bd (diff)
QmlDesigner: Close dialog if target is removed
If the target is removed also the connection is removed and we close the dialog. Change-Id: I361e89ef64484e39bc0068e103f542cbc9dcbf78 Reviewed-by: Qt CI Patch Build Bot <ci_patchbuild_bot@qt.io> Reviewed-by: Aleksei German <aleksei.german@qt.io>
-rw-r--r--share/qtcreator/qmldesigner/connectionseditor/ConnectionsDialog.qml10
-rw-r--r--src/plugins/qmldesigner/components/connectioneditor/connectionmodel.cpp11
-rw-r--r--src/plugins/qmldesigner/components/connectioneditor/connectionmodel.h3
-rw-r--r--src/plugins/qmldesigner/components/connectioneditor/connectionview.cpp5
-rw-r--r--src/plugins/qmldesigner/components/connectioneditor/connectionview.h1
5 files changed, 29 insertions, 1 deletions
diff --git a/share/qtcreator/qmldesigner/connectionseditor/ConnectionsDialog.qml b/share/qtcreator/qmldesigner/connectionseditor/ConnectionsDialog.qml
index b880916e4d8..7405f82a47b 100644
--- a/share/qtcreator/qmldesigner/connectionseditor/ConnectionsDialog.qml
+++ b/share/qtcreator/qmldesigner/connectionseditor/ConnectionsDialog.qml
@@ -7,7 +7,7 @@ import StudioTheme 1.0 as StudioTheme
import HelperWidgets 2.0 as HelperWidgets
PopupDialog {
-
+ id: root
property alias backend: form.backend
titleBar: Row {
@@ -41,5 +41,13 @@ PopupDialog {
ConnectionsDialogForm {
id: form
+
+ Connections {
+ target: root.backend
+ onPopupTargetRemoved: {
+ root.close()
+ }
+ }
}
+
}
diff --git a/src/plugins/qmldesigner/components/connectioneditor/connectionmodel.cpp b/src/plugins/qmldesigner/components/connectioneditor/connectionmodel.cpp
index 9fca617e359..c0b819371a8 100644
--- a/src/plugins/qmldesigner/components/connectioneditor/connectionmodel.cpp
+++ b/src/plugins/qmldesigner/components/connectioneditor/connectionmodel.cpp
@@ -487,6 +487,17 @@ void ConnectionModel::selectProperty(const SignalHandlerProperty &property)
}
}
+void ConnectionModel::nodeAboutToBeRemoved(const ModelNode &removedNode)
+{
+ SignalHandlerProperty selectedSignal = signalHandlerPropertyForRow(currentIndex());
+ if (selectedSignal.isValid()) {
+ ModelNode targetNode = getTargetNodeForConnection(selectedSignal.parentModelNode());
+ if (targetNode == removedNode) {
+ emit m_delegate->popupTargetRemoved();
+ }
+ }
+}
+
void ConnectionModel::handleException()
{
QMessageBox::warning(nullptr, tr("Error"), m_exceptionError);
diff --git a/src/plugins/qmldesigner/components/connectioneditor/connectionmodel.h b/src/plugins/qmldesigner/components/connectioneditor/connectionmodel.h
index 03ee4e7144c..d9b13cb22d2 100644
--- a/src/plugins/qmldesigner/components/connectioneditor/connectionmodel.h
+++ b/src/plugins/qmldesigner/components/connectioneditor/connectionmodel.h
@@ -71,6 +71,8 @@ public:
void selectProperty(const SignalHandlerProperty &property);
+ void nodeAboutToBeRemoved(const ModelNode &removedNode);
+
signals:
void currentIndexChanged();
@@ -296,6 +298,7 @@ signals:
void hasConditionChanged();
void hasElseChanged();
void sourceChanged();
+ void popupTargetRemoved();
private:
int currentRow() const;
diff --git a/src/plugins/qmldesigner/components/connectioneditor/connectionview.cpp b/src/plugins/qmldesigner/components/connectioneditor/connectionview.cpp
index 41eee97be48..0b02ee0e34b 100644
--- a/src/plugins/qmldesigner/components/connectioneditor/connectionview.cpp
+++ b/src/plugins/qmldesigner/components/connectioneditor/connectionview.cpp
@@ -176,6 +176,11 @@ void ConnectionView::nodeCreated(const ModelNode & /*createdNode*/)
connectionModel()->resetModel();
}
+void ConnectionView::nodeAboutToBeRemoved(const ModelNode &removedNode)
+{
+ connectionModel()->nodeAboutToBeRemoved(removedNode);
+}
+
void ConnectionView::nodeRemoved(const ModelNode & /*removedNode*/,
const NodeAbstractProperty & /*parentProperty*/,
AbstractView::PropertyChangeFlags /*propertyChange*/)
diff --git a/src/plugins/qmldesigner/components/connectioneditor/connectionview.h b/src/plugins/qmldesigner/components/connectioneditor/connectionview.h
index b865bf51cc4..338d1fb14ed 100644
--- a/src/plugins/qmldesigner/components/connectioneditor/connectionview.h
+++ b/src/plugins/qmldesigner/components/connectioneditor/connectionview.h
@@ -39,6 +39,7 @@ public:
void modelAboutToBeDetached(Model *model) override;
void nodeCreated(const ModelNode &createdNode) override;
+ void nodeAboutToBeRemoved(const ModelNode &removedNode) override;
void nodeRemoved(const ModelNode &removedNode, const NodeAbstractProperty &parentProperty, PropertyChangeFlags propertyChange) override;
void nodeReparented(const ModelNode &node, const NodeAbstractProperty &newPropertyParent,
const NodeAbstractProperty &oldPropertyParent, AbstractView::PropertyChangeFlags propertyChange) override;