diff --git a/src/plugins/qmldesigner/components/componentcore/componentcore_constants.h b/src/plugins/qmldesigner/components/componentcore/componentcore_constants.h index 233dc87f6cf..cac7462d75f 100644 --- a/src/plugins/qmldesigner/components/componentcore/componentcore_constants.h +++ b/src/plugins/qmldesigner/components/componentcore/componentcore_constants.h @@ -72,6 +72,7 @@ const char resetPositionDisplayName[] = QT_TRANSLATE_NOOP("QmlDesignerContextMen const char goIntoComponentDisplayName[] = QT_TRANSLATE_NOOP("QmlDesignerContextMenu", "Go into Component"); const char goToImplementationDisplayName[] = QT_TRANSLATE_NOOP("QmlDesignerContextMenu", "Go to Implementation"); +const char addSignalHandlerDisplayName[] = QT_TRANSLATE_NOOP("QmlDesignerContextMenu", "Add New Signal Handler"); const char moveToComponentDisplayName[] = QT_TRANSLATE_NOOP("QmlDesignerContextMenu", "Move to Component"); const char setIdDisplayName[] = QT_TRANSLATE_NOOP("QmlDesignerContextMenu", "Set Id"); diff --git a/src/plugins/qmldesigner/components/componentcore/designeractionmanager.cpp b/src/plugins/qmldesigner/components/componentcore/designeractionmanager.cpp index 57f1ca61da6..ea79b5c62e8 100644 --- a/src/plugins/qmldesigner/components/componentcore/designeractionmanager.cpp +++ b/src/plugins/qmldesigner/components/componentcore/designeractionmanager.cpp @@ -509,10 +509,11 @@ void DesignerActionManager::createDefaultDesignerActions() addDesignerAction(new ModelNodeAction (goIntoComponentDisplayName, rootCategory, priorityGoIntoComponent, &goIntoComponent, &selectionIsComponent)); addDesignerAction(new ModelNodeAction - (goToImplementationDisplayName, rootCategory, 42, &gotoImplementation, &singleSelectedAndUiFile, &singleSelectedAndUiFile)); + (goToImplementationDisplayName, rootCategory, 42, &goImplementation, &singleSelectedAndUiFile, &singleSelectedAndUiFile)); + addDesignerAction(new ModelNodeAction + (addSignalHandlerDisplayName, rootCategory, 42, &addNewSignalHandler, &singleSelectedAndUiFile, &singleSelectedAndUiFile)); addDesignerAction(new ModelNodeAction (moveToComponentDisplayName, rootCategory, 44, &moveToComponent, &singleSelection, &singleSelection)); - } void DesignerActionManager::addDesignerAction(ActionInterface *newAction) diff --git a/src/plugins/qmldesigner/components/componentcore/modelnodeoperations.cpp b/src/plugins/qmldesigner/components/componentcore/modelnodeoperations.cpp index 7d3c89a2ee4..a13c86cc7c9 100644 --- a/src/plugins/qmldesigner/components/componentcore/modelnodeoperations.cpp +++ b/src/plugins/qmldesigner/components/componentcore/modelnodeoperations.cpp @@ -637,7 +637,7 @@ static QStringList getSortedSignalNameList(const ModelNode &modelNode) return signalNames; } -void gotoImplementation(const SelectionContext &selectionState) +void addSignalHandlerOrGotoImplementation(const SelectionContext &selectionState, bool addAlwaysNewSlot) { ModelNode modelNode; if (selectionState.singleNodeIsSelected()) @@ -687,7 +687,7 @@ void gotoImplementation(const SelectionContext &selectionState) Core::ModeManager::activateMode(Core::Constants::MODE_EDIT); - if (usages.count() == 1) { + if (usages.count() > 0 && (addAlwaysNewSlot || usages.count()< 2)) { Core::EditorManager::openEditorAt(usages.first().path, usages.first().line, usages.first().col); if (!signalNames.isEmpty()) { @@ -782,6 +782,16 @@ void moveToComponent(const SelectionContext &selectionContext) selectionContext.view()->model()->rewriterView()->moveToComponent(modelNode); } +void goImplementation(const SelectionContext &selectionState) +{ + addSignalHandlerOrGotoImplementation(selectionState, false); +} + +void addNewSignalHandler(const SelectionContext &selectionState) +{ + addSignalHandlerOrGotoImplementation(selectionState, true); +} + } // namespace Mode } //QmlDesigner diff --git a/src/plugins/qmldesigner/components/componentcore/modelnodeoperations.h b/src/plugins/qmldesigner/components/componentcore/modelnodeoperations.h index 560d54d218b..4c447cef23b 100644 --- a/src/plugins/qmldesigner/components/componentcore/modelnodeoperations.h +++ b/src/plugins/qmldesigner/components/componentcore/modelnodeoperations.h @@ -63,7 +63,9 @@ void layoutFlowPositioner(const SelectionContext &selectionState); void layoutRowLayout(const SelectionContext &selectionState); void layoutColumnLayout(const SelectionContext &selectionState); void layoutGridLayout(const SelectionContext &selectionState); -void gotoImplementation(const SelectionContext &selectionState); +void goImplementation(const SelectionContext &selectionState); +void addNewSignalHandler(const SelectionContext &selectionState); +void addSignalHandlerOrGotoImplementation(const SelectionContext &selectionState, bool addAlwaysNewSlot); void removeLayout(const SelectionContext &selectionContext); void removePositioner(const SelectionContext &selectionContext); void moveToComponent(const SelectionContext &selectionContext);