summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/plugins/help/help_dependencies.pri2
-rw-r--r--src/plugins/help/helpplugin.cpp8
-rw-r--r--src/plugins/texteditor/texteditor.cpp31
-rw-r--r--src/plugins/texteditor/texteditorconstants.h5
-rw-r--r--src/plugins/texteditor/texteditorplugin.cpp31
5 files changed, 55 insertions, 22 deletions
diff --git a/src/plugins/help/help_dependencies.pri b/src/plugins/help/help_dependencies.pri
index 2094a72dd3..cf2e37d3c3 100644
--- a/src/plugins/help/help_dependencies.pri
+++ b/src/plugins/help/help_dependencies.pri
@@ -6,3 +6,5 @@ QTC_LIB_DEPENDS += \
QTC_PLUGIN_DEPENDS += \
coreplugin \
projectexplorer
+QTC_PLUGIN_RECOMMENDS += \
+ texteditor
diff --git a/src/plugins/help/helpplugin.cpp b/src/plugins/help/helpplugin.cpp
index 263f0aac15..091a845686 100644
--- a/src/plugins/help/helpplugin.cpp
+++ b/src/plugins/help/helpplugin.cpp
@@ -254,6 +254,14 @@ HelpPluginPrivate::HelpPluginPrivate()
ActionManager::actionContainer(Core::Constants::M_HELP)->addAction(cmd, Core::Constants::G_HELP_HELP);
cmd->setDefaultKeySequence(QKeySequence(Qt::Key_F1));
connect(action, &QAction::triggered, this, &HelpPluginPrivate::requestContextHelp);
+ ActionContainer *textEditorContextMenu = ActionManager::actionContainer(
+ TextEditor::Constants::M_STANDARDCONTEXTMENU);
+ if (textEditorContextMenu) {
+ textEditorContextMenu->insertGroup(TextEditor::Constants::G_BOM,
+ Core::Constants::G_HELP);
+ textEditorContextMenu->addSeparator(Core::Constants::G_HELP);
+ textEditorContextMenu->addAction(cmd, Core::Constants::G_HELP);
+ }
action = new QAction(HelpPlugin::tr("Technical Support"), this);
cmd = ActionManager::registerAction(action, "Help.TechSupport");
diff --git a/src/plugins/texteditor/texteditor.cpp b/src/plugins/texteditor/texteditor.cpp
index f93d8109e6..a01d8a6e6b 100644
--- a/src/plugins/texteditor/texteditor.cpp
+++ b/src/plugins/texteditor/texteditor.cpp
@@ -7762,30 +7762,17 @@ void TextEditorWidget::setupFallBackEditor(Id id)
void TextEditorWidget::appendStandardContextMenuActions(QMenu *menu)
{
menu->addSeparator();
- const auto add = [menu](const Id &id) {
- QAction *a = ActionManager::command(id)->action();
- if (a)
- menu->addAction(a);
- };
-
- add(Core::Constants::UNDO);
- add(Core::Constants::REDO);
- menu->addSeparator();
- add(Core::Constants::CUT);
- add(Core::Constants::COPY);
- add(Core::Constants::PASTE);
- add(Constants::CIRCULAR_PASTE);
- menu->addSeparator();
- add(Core::Constants::SELECTALL);
-
- TextDocument *doc = textDocument();
- if (doc->codec()->name() == QByteArray("UTF-8") && doc->supportsUtf8Bom()) {
- QAction *a = ActionManager::command(Constants::SWITCH_UTF8BOM)->action();
- if (a) {
+ appendMenuActionsFromContext(menu, Constants::M_STANDARDCONTEXTMENU);
+ Command *bomCmd = ActionManager::command(Constants::SWITCH_UTF8BOM);
+ if (bomCmd) {
+ QAction *a = bomCmd->action();
+ TextDocument *doc = textDocument();
+ if (doc->codec()->name() == QByteArray("UTF-8") && doc->supportsUtf8Bom()) {
+ a->setVisible(true);
a->setText(doc->format().hasUtf8Bom ? tr("Delete UTF-8 BOM on Save")
: tr("Add UTF-8 BOM on Save"));
- menu->addSeparator();
- menu->addAction(a);
+ } else {
+ a->setVisible(false);
}
}
}
diff --git a/src/plugins/texteditor/texteditorconstants.h b/src/plugins/texteditor/texteditorconstants.h
index e7024614e5..8007c76617 100644
--- a/src/plugins/texteditor/texteditorconstants.h
+++ b/src/plugins/texteditor/texteditorconstants.h
@@ -109,6 +109,11 @@ enum TextStyle : quint8 {
namespace Constants {
const char C_TEXTEDITOR[] = "Text Editor";
+const char M_STANDARDCONTEXTMENU[] = "TextEditor.StandardContextMenu";
+const char G_UNDOREDO[] = "TextEditor.UndoRedoGroup";
+const char G_COPYPASTE[] = "TextEditor.CopyPasteGroup";
+const char G_SELECT[] = "TextEditor.SelectGroup";
+const char G_BOM[] = "TextEditor.BomGroup";
const char COMPLETE_THIS[] = "TextEditor.CompleteThis";
const char QUICKFIX_THIS[] = "TextEditor.QuickFix";
const char SHOWCONTEXTMENU[] = "TextEditor.ShowContextMenu";
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