diff --git a/src/plugins/modeleditor/actionhandler.cpp b/src/plugins/modeleditor/actionhandler.cpp index 284a1503ec4..f5796b3ada9 100644 --- a/src/plugins/modeleditor/actionhandler.cpp +++ b/src/plugins/modeleditor/actionhandler.cpp @@ -144,15 +144,18 @@ void ActionHandler::createActions() registerCommand(Constants::ACTION_ADD_COMPONENT, nullptr, Core::Context()); registerCommand(Constants::ACTION_ADD_CLASS, nullptr, Core::Context()); registerCommand(Constants::ACTION_ADD_CANVAS_DIAGRAM, nullptr, Core::Context()); -} -void ActionHandler::createEditPropertiesShortcut(const Core::Id &shortcutId) -{ - auto editAction = new QAction(tr("Edit Element Properties"), Core::ICore::mainWindow()); - Core::Command *editCommand = Core::ActionManager::registerAction( - editAction, shortcutId, d->context); - editCommand->setDefaultKeySequence(QKeySequence(tr("Return"))); - connect(editAction, &QAction::triggered, this, &ActionHandler::onEditProperties); + auto editPropertiesAction = new QAction(tr("Edit Element Properties"), Core::ICore::mainWindow()); + Core::Command *editPropertiesCommand = Core::ActionManager::registerAction( + editPropertiesAction, Constants::SHORTCUT_MODEL_EDITOR_EDIT_PROPERTIES, d->context); + editPropertiesCommand->setDefaultKeySequence(QKeySequence(tr("Shift+Return"))); + connect(editPropertiesAction, &QAction::triggered, this, &ActionHandler::onEditProperties); + + auto editItemAction = new QAction(tr("Edit Item on Diagram"), Core::ICore::mainWindow()); + Core::Command *editItemCommand = Core::ActionManager::registerAction( + editItemAction, Constants::SHORTCUT_MODEL_EDITOR_EDIT_ITEM, d->context); + editItemCommand->setDefaultKeySequence(QKeySequence(tr("Return"))); + connect(editItemAction, &QAction::triggered, this, &ActionHandler::onEditItem); } void ActionHandler::undo() @@ -225,6 +228,13 @@ void ActionHandler::onEditProperties() editor->editProperties(); } +void ActionHandler::onEditItem() +{ + auto editor = qobject_cast(Core::EditorManager::currentEditor()); + if (editor) + editor->editSelectedItem(); +} + Core::Command *ActionHandler::registerCommand(const Core::Id &id, const std::function &slot, const Core::Context &context, bool scriptable, const QString &title, const QKeySequence &keySequence) diff --git a/src/plugins/modeleditor/actionhandler.h b/src/plugins/modeleditor/actionhandler.h index 3f4f337c9e7..6455d1a70ee 100644 --- a/src/plugins/modeleditor/actionhandler.h +++ b/src/plugins/modeleditor/actionhandler.h @@ -71,7 +71,6 @@ public: QAction *openParentDiagramAction() const; void createActions(); - void createEditPropertiesShortcut(const Core::Id &shortcutId); private slots: void undo(); @@ -84,6 +83,7 @@ private slots: void selectAll(); void openParentDiagram(); void onEditProperties(); + void onEditItem(); private: Core::Command *registerCommand(const Core::Id &id, const std::function &slot, diff --git a/src/plugins/modeleditor/modeleditor.cpp b/src/plugins/modeleditor/modeleditor.cpp index a9cccd499de..44840bcc635 100644 --- a/src/plugins/modeleditor/modeleditor.cpp +++ b/src/plugins/modeleditor/modeleditor.cpp @@ -508,6 +508,11 @@ void ModelEditor::editProperties() d->propertiesView->editSelectedElement(); } +void ModelEditor::editSelectedItem() +{ + onEditSelectedElement(); +} + qmt::MPackage *ModelEditor::guessSelectedPackage() const { qmt::MPackage *package = 0; @@ -1184,6 +1189,7 @@ void ModelEditor::onEditSelectedElement() if (element) { qmt::DiagramSceneModel *diagramSceneModel = d->document->documentController()->diagramsManager()->diagramSceneModel(diagram); if (diagramSceneModel->isElementEditable(element)) { + d->diagramStack->currentWidget()->setFocus(); diagramSceneModel->editElement(element); return; } diff --git a/src/plugins/modeleditor/modeleditor.h b/src/plugins/modeleditor/modeleditor.h index 07ede048674..35bed419938 100644 --- a/src/plugins/modeleditor/modeleditor.h +++ b/src/plugins/modeleditor/modeleditor.h @@ -90,6 +90,7 @@ public: void selectAll(); void openParentDiagram(); void editProperties(); + void editSelectedItem(); qmt::MPackage *guessSelectedPackage() const; private: diff --git a/src/plugins/modeleditor/modeleditor_constants.h b/src/plugins/modeleditor/modeleditor_constants.h index df054ca977b..1cc8ff9c6b7 100644 --- a/src/plugins/modeleditor/modeleditor_constants.h +++ b/src/plugins/modeleditor/modeleditor_constants.h @@ -50,6 +50,8 @@ const char ACTION_EXPLORER_OPEN_DIAGRAM[] = "ModelEditor.Action.Explorer.OpenDia const char SHORTCUT_MODEL_EDITOR_EDIT_PROPERTIES[] = "ModelEditor.ModelEditor.Shortcut.EditProperties"; +const char SHORTCUT_MODEL_EDITOR_EDIT_ITEM[] = + "ModelEditor.ModelEditor.Shortcut.EditItem"; const char WIZARD_CATEGORY[] = "O.Model"; const char WIZARD_TR_CATEGORY[] = QT_TRANSLATE_NOOP("Modeling", "Modeling"); diff --git a/src/plugins/modeleditor/modeleditorfactory.cpp b/src/plugins/modeleditor/modeleditorfactory.cpp index acf1399aa4e..dbba4ae4d5b 100644 --- a/src/plugins/modeleditor/modeleditorfactory.cpp +++ b/src/plugins/modeleditor/modeleditorfactory.cpp @@ -71,8 +71,6 @@ Core::IEditor *ModelEditorFactory::createEditor() void ModelEditorFactory::extensionsInitialized() { d->actionHandler->createActions(); - d->actionHandler->createEditPropertiesShortcut( - Constants::SHORTCUT_MODEL_EDITOR_EDIT_PROPERTIES); } } // namespace Internal