diff options
author | Jochen Becher <jochen_becher@gmx.de> | 2015-12-25 19:16:09 +0100 |
---|---|---|
committer | Jochen Becher <jochen_becher@gmx.de> | 2016-01-04 12:19:06 +0000 |
commit | b13f964fd5403d15ece89f89f9823dd19a2bc459 (patch) | |
tree | 5424f9e6652861335a5b1b00e549fbcb9f7d09a8 /src/plugins/modeleditor | |
parent | a943717cebcd61108d16ac1490a9b2cd523a6bb5 (diff) | |
download | qt-creator-b13f964fd5403d15ece89f89f9823dd19a2bc459.tar.gz |
ModelEditor: Set global context for parent-diagram action
After selecting a new diagram from the pop-down menu the
open-parent-diagram action was not immediately available
because the model editor context is no longer the active one.
With this change the action is registered in global context.
Change-Id: Icf6fc0408916a3e22d2f19e7a09ab24fcf20a867
Reviewed-by: Tobias Hunger <tobias.hunger@theqtcompany.com>
Diffstat (limited to 'src/plugins/modeleditor')
-rw-r--r-- | src/plugins/modeleditor/actionhandler.cpp | 30 | ||||
-rw-r--r-- | src/plugins/modeleditor/actionhandler.h | 5 |
2 files changed, 18 insertions, 17 deletions
diff --git a/src/plugins/modeleditor/actionhandler.cpp b/src/plugins/modeleditor/actionhandler.cpp index 675c22a86a..284a1503ec 100644 --- a/src/plugins/modeleditor/actionhandler.cpp +++ b/src/plugins/modeleditor/actionhandler.cpp @@ -120,30 +120,30 @@ void ActionHandler::createActions() { Core::ActionContainer *medit = Core::ActionManager::actionContainer(Core::Constants::M_EDIT); - d->undoAction = registerCommand(Core::Constants::UNDO, [this]() { undo(); })->action(); - d->redoAction = registerCommand(Core::Constants::REDO, [this]() { redo(); })->action(); - d->cutAction = registerCommand(Core::Constants::CUT, [this]() { cut(); })->action(); - d->copyAction = registerCommand(Core::Constants::COPY, [this]() { copy(); })->action(); - d->pasteAction = registerCommand(Core::Constants::PASTE, [this]() { paste(); })->action(); + d->undoAction = registerCommand(Core::Constants::UNDO, [this]() { undo(); }, d->context)->action(); + d->redoAction = registerCommand(Core::Constants::REDO, [this]() { redo(); }, d->context)->action(); + d->cutAction = registerCommand(Core::Constants::CUT, [this]() { cut(); }, d->context)->action(); + d->copyAction = registerCommand(Core::Constants::COPY, [this]() { copy(); }, d->context)->action(); + d->pasteAction = registerCommand(Core::Constants::PASTE, [this]() { paste(); }, d->context)->action(); Core::Command *removeCommand = registerCommand( - Constants::REMOVE_SELECTED_ELEMENTS, [this]() { removeSelectedElements(); }, true, + Constants::REMOVE_SELECTED_ELEMENTS, [this]() { removeSelectedElements(); }, d->context, true, tr("&Remove"), QKeySequence::Delete); medit->addAction(removeCommand, Core::Constants::G_EDIT_COPYPASTE); d->removeAction = removeCommand->action(); Core::Command *deleteCommand = registerCommand( - Constants::DELETE_SELECTED_ELEMENTS, [this]() { deleteSelectedElements(); }, true, + Constants::DELETE_SELECTED_ELEMENTS, [this]() { deleteSelectedElements(); }, d->context, true, tr("&Delete"), QKeySequence(QStringLiteral("Ctrl+D"))); medit->addAction(deleteCommand, Core::Constants::G_EDIT_COPYPASTE); d->deleteAction = deleteCommand->action(); - d->selectAllAction = registerCommand(Core::Constants::SELECTALL, [this]() { selectAll(); })->action(); + d->selectAllAction = registerCommand(Core::Constants::SELECTALL, [this]() { selectAll(); }, d->context)->action(); d->openParentDiagramAction = registerCommand( - Constants::OPEN_PARENT_DIAGRAM, [this]() { openParentDiagram(); }, true, + Constants::OPEN_PARENT_DIAGRAM, [this]() { openParentDiagram(); }, Core::Context(), true, tr("Open Parent Diagram"), QKeySequence(QStringLiteral("Ctrl+Shift+P")))->action(); d->openParentDiagramAction->setIcon(QIcon(QStringLiteral(":/modeleditor/up.png"))); - registerCommand(Constants::ACTION_ADD_PACKAGE, nullptr); - registerCommand(Constants::ACTION_ADD_COMPONENT, nullptr); - registerCommand(Constants::ACTION_ADD_CLASS, nullptr); - registerCommand(Constants::ACTION_ADD_CANVAS_DIAGRAM, nullptr); + registerCommand(Constants::ACTION_ADD_PACKAGE, nullptr, Core::Context()); + 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) @@ -226,11 +226,11 @@ void ActionHandler::onEditProperties() } Core::Command *ActionHandler::registerCommand(const Core::Id &id, const std::function<void()> &slot, - bool scriptable, const QString &title, + const Core::Context &context, bool scriptable, const QString &title, const QKeySequence &keySequence) { auto action = new QAction(title, this); - Core::Command *command = Core::ActionManager::registerAction(action, id, d->context, scriptable); + Core::Command *command = Core::ActionManager::registerAction(action, id, context, scriptable); if (!keySequence.isEmpty()) command->setDefaultKeySequence(keySequence); if (slot) diff --git a/src/plugins/modeleditor/actionhandler.h b/src/plugins/modeleditor/actionhandler.h index 1654186f98..3f4f337c9e 100644 --- a/src/plugins/modeleditor/actionhandler.h +++ b/src/plugins/modeleditor/actionhandler.h @@ -87,8 +87,9 @@ private slots: private: Core::Command *registerCommand(const Core::Id &id, const std::function<void()> &slot, - bool scriptable = true, const QString &title = QString(), - const QKeySequence &keySequence = QKeySequence()); + const Core::Context &context, + bool scriptable = true, const QString &title = QString(), + const QKeySequence &keySequence = QKeySequence()); private: ActionHandlerPrivate *d; |