From a81e90a7f4cabc31b81df96d68bc55c0afb529a0 Mon Sep 17 00:00:00 2001 From: Thomas Hartmann Date: Wed, 25 Oct 2023 17:34:00 +0200 Subject: [PATCH] QmlDesigner: Implement JumpToCode in states editor MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Task-number: QDS-10867 Change-Id: I90975ad70567261899f047f2f02236bb993cfd2b Reviewed-by: Henning Gründl Reviewed-by: Reviewed-by: Qt CI Patch Build Bot --- share/qtcreator/qmldesigner/stateseditor/StateMenu.qml | 9 +++++++++ .../qmldesigner/stateseditor/StateThumbnail.qml | 3 +++ .../components/stateseditor/stateseditormodel.cpp | 6 ++++++ .../components/stateseditor/stateseditormodel.h | 1 + 4 files changed, 19 insertions(+) diff --git a/share/qtcreator/qmldesigner/stateseditor/StateMenu.qml b/share/qtcreator/qmldesigner/stateseditor/StateMenu.qml index d26572ebde6..c30538e31ed 100644 --- a/share/qtcreator/qmldesigner/stateseditor/StateMenu.qml +++ b/share/qtcreator/qmldesigner/stateseditor/StateMenu.qml @@ -44,6 +44,7 @@ StudioControls.Menu { signal remove() signal toggle() signal resetWhenCondition() + signal jumpToCode() signal editAnnotation() signal removeAnnotation() @@ -84,6 +85,14 @@ StudioControls.Menu { StudioControls.MenuSeparator {} + StudioControls.MenuItem { + enabled: !root.isBaseState + text: qsTr("Jump To Code") + onTriggered: root.jumpToCode() + } + + StudioControls.MenuSeparator {} + StudioControls.MenuItem { enabled: !root.isBaseState && root.hasWhenCondition text: qsTr("Reset when Condition") diff --git a/share/qtcreator/qmldesigner/stateseditor/StateThumbnail.qml b/share/qtcreator/qmldesigner/stateseditor/StateThumbnail.qml index 1d8147d0425..781ddc4601f 100644 --- a/share/qtcreator/qmldesigner/stateseditor/StateThumbnail.qml +++ b/share/qtcreator/qmldesigner/stateseditor/StateThumbnail.qml @@ -736,6 +736,9 @@ Item { onRemove: root.remove() onToggle: root.setPropertyChangesVisible(!root.propertyChangesVisible) onResetWhenCondition: statesEditorModel.resetWhenCondition(root.internalNodeId) + + onJumpToCode: StatesEditorBackend.statesEditorModel.jumpToCode() + onEditAnnotation: { StatesEditorBackend.statesEditorModel.setAnnotation(root.internalNodeId) stateMenu.hasAnnotation = root.checkAnnotation() diff --git a/src/plugins/qmldesigner/components/stateseditor/stateseditormodel.cpp b/src/plugins/qmldesigner/components/stateseditor/stateseditormodel.cpp index 0b53af121b8..2ec6f0e6a02 100644 --- a/src/plugins/qmldesigner/components/stateseditor/stateseditormodel.cpp +++ b/src/plugins/qmldesigner/components/stateseditor/stateseditormodel.cpp @@ -6,6 +6,7 @@ #include #include +#include #include #include #include @@ -246,6 +247,11 @@ bool StatesEditorModel::hasDefaultState() const return m_statesEditorView->hasDefaultState(); } +void StatesEditorModel::jumpToCode() +{ + ModelNodeOperations::jumpToCode(m_statesEditorView->currentState().modelNode()); +} + void StatesEditorModel::setAnnotation(int internalNodeId) { m_statesEditorView->setAnnotation(internalNodeId); diff --git a/src/plugins/qmldesigner/components/stateseditor/stateseditormodel.h b/src/plugins/qmldesigner/components/stateseditor/stateseditormodel.h index 8eff287c869..0e228e46bd8 100644 --- a/src/plugins/qmldesigner/components/stateseditor/stateseditormodel.h +++ b/src/plugins/qmldesigner/components/stateseditor/stateseditormodel.h @@ -50,6 +50,7 @@ public: Q_INVOKABLE void setStateAsDefault(int internalNodeId); Q_INVOKABLE void resetDefaultState(); Q_INVOKABLE bool hasDefaultState() const; + Q_INVOKABLE void jumpToCode(); Q_INVOKABLE void setAnnotation(int internalNodeId); Q_INVOKABLE void removeAnnotation(int internalNodeId); Q_INVOKABLE bool hasAnnotation(int internalNodeId) const;