add standard cut/copy/paste actions (if available) to the cpp editor's context menu

at a later stage we will look into harmonizing context menu among different editors.
The cpp editor had the biggest need, because its context menu features all sorts of
extra refactoring operations, thus the standard Qt context menu became too large.
This commit is contained in:
mae
2009-11-02 14:02:18 +01:00
parent b8bd20dd42
commit c035290602
3 changed files with 23 additions and 8 deletions

View File

@@ -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;