summaryrefslogtreecommitdiff
path: root/src/plugins/texteditor/texteditorplugin.cpp
diff options
context:
space:
mode:
authorEike Ziller <eike.ziller@qt.io>2018-03-22 09:52:49 +0100
committerEike Ziller <eike.ziller@qt.io>2018-03-29 08:26:24 +0000
commit454e9ee5ca9d8266ab8e5a654a1d4e7a04b40833 (patch)
treeac89a641f5969cfa47f2d403d99cdda0a8bf70f0 /src/plugins/texteditor/texteditorplugin.cpp
parent26bfa469db1fbfb0f5f231c0ac9c780926e5d522 (diff)
downloadqt-creator-454e9ee5ca9d8266ab8e5a654a1d4e7a04b40833.tar.gz
Add Context Help to text editor context menu
For this make the default context menu for the text editor extensible and add the context help item from the help plugin, which now has an optional dependency on the text editor to ensure correct loading order if both are present. Task-number: QTCREATORBUG-55 Change-Id: I378a491ba3700e65fc262bdb10c8ead5ad62cb33 Reviewed-by: David Schulz <david.schulz@qt.io>
Diffstat (limited to 'src/plugins/texteditor/texteditorplugin.cpp')
-rw-r--r--src/plugins/texteditor/texteditorplugin.cpp31
1 files changed, 31 insertions, 0 deletions
diff --git a/src/plugins/texteditor/texteditorplugin.cpp b/src/plugins/texteditor/texteditorplugin.cpp
index b0809ad094..5cacd941c4 100644
--- a/src/plugins/texteditor/texteditorplugin.cpp
+++ b/src/plugins/texteditor/texteditorplugin.cpp
@@ -40,6 +40,7 @@
#include <coreplugin/icore.h>
#include <coreplugin/actionmanager/actionmanager.h>
+#include <coreplugin/actionmanager/actioncontainer.h>
#include <coreplugin/actionmanager/command.h>
#include <coreplugin/externaltoolmanager.h>
#include <extensionsystem/pluginmanager.h>
@@ -74,6 +75,8 @@ public:
void updateSearchResultsTabWidth(const TextEditor::TabSettings &tabSettings);
void updateCurrentSelection(const QString &text);
+ void createStandardContextMenu();
+
TextEditorSettings settings;
LineNumberFilter lineNumberFilter; // Goto line functionality for quick open
OutlineFactory outlineFactory;
@@ -148,6 +151,7 @@ bool TextEditorPlugin::initialize(const QStringList &arguments, QString *errorMe
SnippetProvider::registerGroup(Constants::TEXT_SNIPPET_GROUP_ID,
tr("Text", "SnippetProvider"));
+ d->createStandardContextMenu();
return true;
}
@@ -262,5 +266,32 @@ void TextEditorPluginPrivate::updateCurrentSelection(const QString &text)
}
}
+void TextEditorPluginPrivate::createStandardContextMenu()
+{
+ ActionContainer *contextMenu = ActionManager::createMenu(Constants::M_STANDARDCONTEXTMENU);
+ contextMenu->appendGroup(Constants::G_UNDOREDO);
+ contextMenu->appendGroup(Constants::G_COPYPASTE);
+ contextMenu->appendGroup(Constants::G_SELECT);
+ contextMenu->appendGroup(Constants::G_BOM);
+
+ const auto add = [contextMenu](const Id &id, const Id &group) {
+ Command *cmd = ActionManager::command(id);
+ if (cmd)
+ contextMenu->addAction(cmd, group);
+ };
+
+ add(Core::Constants::UNDO, Constants::G_UNDOREDO);
+ add(Core::Constants::REDO, Constants::G_UNDOREDO);
+ contextMenu->addSeparator(Constants::G_COPYPASTE);
+ add(Core::Constants::CUT, Constants::G_COPYPASTE);
+ add(Core::Constants::COPY, Constants::G_COPYPASTE);
+ add(Core::Constants::PASTE, Constants::G_COPYPASTE);
+ add(Constants::CIRCULAR_PASTE, Constants::G_COPYPASTE);
+ contextMenu->addSeparator(Constants::G_SELECT);
+ add(Core::Constants::SELECTALL, Constants::G_SELECT);
+ contextMenu->addSeparator(Constants::G_BOM);
+ add(Constants::SWITCH_UTF8BOM, Constants::G_BOM);
+}
+
} // namespace Internal
} // namespace TextEditor