diff --git a/src/plugins/cppeditor/cppeditor.cpp b/src/plugins/cppeditor/cppeditor.cpp index e323ff0651a61eaf7f4aa937860c26b5100fb68c..7260569dbb7bef336e0fc8c48df2cabfea4b03e6 100644 --- a/src/plugins/cppeditor/cppeditor.cpp +++ b/src/plugins/cppeditor/cppeditor.cpp @@ -1643,14 +1643,6 @@ void CPPEditor::contextMenuEvent(QContextMenuEvent *e) QMenu *menu = new QMenu(); - -// QMenu *menu = createStandardContextMenu(); -// -// // Remove insert unicode control character -// QAction *lastAction = menu->actions().last(); -// if (lastAction->menu() && QLatin1String(lastAction->menu()->metaObject()->className()) == QLatin1String("QUnicodeControlCharacterMenu")) -// menu->removeAction(lastAction); - Core::ActionManager *am = Core::ICore::instance()->actionManager(); Core::ActionContainer *mcontext = am->actionContainer(CppEditor::Constants::M_CONTEXT); QMenu *contextMenu = mcontext->menu(); @@ -1661,6 +1653,8 @@ void CPPEditor::contextMenuEvent(QContextMenuEvent *e) const QList<QTextEdit::ExtraSelection> selections = extraSelections(BaseTextEditor::CodeSemanticsSelection); + appendStandardContextMenuActions(menu); + menu->exec(e->globalPos()); delete menu; } diff --git a/src/plugins/texteditor/basetexteditor.cpp b/src/plugins/texteditor/basetexteditor.cpp index e9beb84e1568d44b0083282e48c3e1dc30c910dc..ffa8862aab455f3de5a0a6003aefce944989a6c9 100644 --- a/src/plugins/texteditor/basetexteditor.cpp +++ b/src/plugins/texteditor/basetexteditor.cpp @@ -43,6 +43,8 @@ #include <coreplugin/coreconstants.h> #include <coreplugin/editormanager/editormanager.h> #include <coreplugin/manhattanstyle.h> +#include <coreplugin/icore.h> +#include <coreplugin/actionmanager/actionmanager.h> #include <extensionsystem/pluginmanager.h> #include <find/basetextfind.h> #include <utils/stylehelper.h> @@ -4711,6 +4713,23 @@ BaseTextEditorEditable::BaseTextEditorEditable(BaseTextEditor *editor) connect(editor, SIGNAL(cursorPositionChanged()), this, SLOT(updateCursorPosition())); } +void BaseTextEditor::appendStandardContextMenuActions(QMenu *menu) +{ + menu->addSeparator(); + Core::ActionManager *am = Core::ICore::instance()->actionManager(); + + QAction *a = am->command(Core::Constants::CUT)->action(); + if (a && a->isEnabled()) + menu->addAction(a); + a = am->command(Core::Constants::COPY)->action(); + if (a && a->isEnabled()) + menu->addAction(a); + a = am->command(Core::Constants::PASTE)->action(); + if (a && a->isEnabled()) + menu->addAction(a); +} + + BaseTextEditorEditable::~BaseTextEditorEditable() { delete m_toolBar; diff --git a/src/plugins/texteditor/basetexteditor.h b/src/plugins/texteditor/basetexteditor.h index 0bfa24bfa23e471fbd4bf0a3f8fdbc287fb7471f..69b74fad1e0214c7add6c19cb1775cb590af1023 100644 --- a/src/plugins/texteditor/basetexteditor.h +++ b/src/plugins/texteditor/basetexteditor.h @@ -321,6 +321,8 @@ public: void setMimeType(const QString &mt); + void appendStandardContextMenuActions(QMenu *menu); + // Works only in conjunction with a syntax highlighter that puts // parentheses into text block user data void setParenthesesMatchingEnabled(bool b);