Commit 600fc9b2 authored by mae's avatar mae

cpp editor actions

remove some standard actions from the cpp editor context menu,
and enhance the advanced menu instead.
parent a86ea970
......@@ -181,6 +181,7 @@ const char * const G_EDIT_OTHER = "QtCreator.Group.Edit.Other";
const char * const G_EDIT_FORMAT = "QtCreator.Group.Edit.Format";
const char * const G_EDIT_COLLAPSING = "QtCreator.Group.Edit.Collapsing";
const char * const G_EDIT_BLOCKS = "QtCreator.Group.Edit.Blocks";
const char * const G_EDIT_FONT = "QtCreator.Group.Edit.Font";
const char * const G_EDIT_EDITOR = "QtCreator.Group.Edit.Editor";
......
......@@ -365,19 +365,21 @@ EditorManager::EditorManager(ICore *core, QWidget *parent) :
mwindow->addAction(cmd, Constants::G_WINDOW_SPLIT);
connect(m_d->m_gotoOtherSplitAction, SIGNAL(triggered()), this, SLOT(gotoOtherSplit()));
ActionContainer *medit = am->actionContainer(Constants::M_EDIT);
ActionContainer *advancedMenu = am->createMenu(Constants::M_EDIT_ADVANCED);
medit->addMenu(advancedMenu, Constants::G_EDIT_ADVANCED);
advancedMenu->menu()->setTitle(tr("&Advanced"));
advancedMenu->appendGroup(Constants::G_EDIT_FORMAT);
advancedMenu->appendGroup(Constants::G_EDIT_COLLAPSING);
advancedMenu->appendGroup(Constants::G_EDIT_BLOCKS);
advancedMenu->appendGroup(Constants::G_EDIT_FONT);
advancedMenu->appendGroup(Constants::G_EDIT_EDITOR);
// Advanced menu separators
cmd = createSeparator(am, this, QLatin1String("QtCreator.Edit.Sep.Collapsing"), editManagerContext);
advancedMenu->addAction(cmd, Constants::G_EDIT_COLLAPSING);
cmd = createSeparator(am, this, QLatin1String("QtCreator.Edit.Sep.Blocks"), editManagerContext);
advancedMenu->addAction(cmd, Constants::G_EDIT_BLOCKS);
cmd = createSeparator(am, this, QLatin1String("QtCreator.Edit.Sep.Font"), editManagerContext);
advancedMenu->addAction(cmd, Constants::G_EDIT_FONT);
cmd = createSeparator(am, this, QLatin1String("QtCreator.Edit.Sep.Editor"), editManagerContext);
......
......@@ -1569,12 +1569,15 @@ void CPPEditor::contextMenuEvent(QContextMenuEvent *e)
// ### enable
// updateSemanticInfo(m_semanticHighlighter->semanticInfo(currentSource()));
QMenu *menu = createStandardContextMenu();
QMenu *menu = new QMenu();
// Remove insert unicode control character
QAction *lastAction = menu->actions().last();
if (lastAction->menu() && QLatin1String(lastAction->menu()->metaObject()->className()) == QLatin1String("QUnicodeControlCharacterMenu"))
menu->removeAction(lastAction);
// 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);
......
......@@ -39,6 +39,7 @@ const char * const C_CPPEDITOR = "C++ Editor";
const char * const CPPEDITOR_KIND = QT_TRANSLATE_NOOP("OpenWith::Editors", "C++ Editor");
const char * const SWITCH_DECLARATION_DEFINITION = "CppEditor.SwitchDeclarationDefinition";
const char * const RENAME_SYMBOL_UNDER_CURSOR = "CppEditor.RenameSymbolUnderCursor";
const char * const SEPARATOR = "CppEditor.Separator";
const char * const FIND_REFERENCES = "CppEditor.FindReferences";
const char * const JUMP_TO_DEFINITION = "CppEditor.JumpToDefinition";
......
......@@ -190,7 +190,7 @@ bool CppPlugin::initialize(const QStringList & /*arguments*/, QString *errorMess
context << core->uniqueIDManager()->uniqueIdentifier(CppEditor::Constants::C_CPPEDITOR);
Core::ActionManager *am = core->actionManager();
am->createMenu(CppEditor::Constants::M_CONTEXT);
Core::ActionContainer *contextMenu= am->createMenu(CppEditor::Constants::M_CONTEXT);
Core::Command *cmd;
......@@ -200,7 +200,7 @@ bool CppPlugin::initialize(const QStringList & /*arguments*/, QString *errorMess
cmd->setDefaultKeySequence(QKeySequence(Qt::Key_F2));
connect(jumpToDefinition, SIGNAL(triggered()),
this, SLOT(jumpToDefinition()));
am->actionContainer(CppEditor::Constants::M_CONTEXT)->addAction(cmd);
contextMenu->addAction(cmd);
am->actionContainer(CppTools::Constants::M_TOOLS_CPP)->addAction(cmd);
QAction *switchDeclarationDefinition = new QAction(tr("Switch between Method Declaration/Definition"), this);
......@@ -209,7 +209,7 @@ bool CppPlugin::initialize(const QStringList & /*arguments*/, QString *errorMess
cmd->setDefaultKeySequence(QKeySequence("Shift+F2"));
connect(switchDeclarationDefinition, SIGNAL(triggered()),
this, SLOT(switchDeclarationDefinition()));
am->actionContainer(CppEditor::Constants::M_CONTEXT)->addAction(cmd);
contextMenu->addAction(cmd);
am->actionContainer(CppTools::Constants::M_TOOLS_CPP)->addAction(cmd);
QAction *renameSymbolUnderCursorAction = new QAction(tr("Rename Symbol under Cursor"), this);
......@@ -217,7 +217,7 @@ bool CppPlugin::initialize(const QStringList & /*arguments*/, QString *errorMess
Constants::RENAME_SYMBOL_UNDER_CURSOR, context);
cmd->setDefaultKeySequence(QKeySequence("CTRL+SHIFT+R"));
connect(renameSymbolUnderCursorAction, SIGNAL(triggered()), this, SLOT(renameSymbolUnderCursor()));
am->actionContainer(CppEditor::Constants::M_CONTEXT)->addAction(cmd);
contextMenu->addAction(cmd);
am->actionContainer(CppTools::Constants::M_TOOLS_CPP)->addAction(cmd);
if (! qgetenv("QTCREATOR_REFERENCES").isEmpty()) {
......@@ -225,7 +225,7 @@ bool CppPlugin::initialize(const QStringList & /*arguments*/, QString *errorMess
cmd = am->registerAction(findReferencesAction,
Constants::FIND_REFERENCES, context);
connect(findReferencesAction, SIGNAL(triggered()), this, SLOT(findReferences()));
am->actionContainer(CppEditor::Constants::M_CONTEXT)->addAction(cmd);
contextMenu->addAction(cmd);
am->actionContainer(CppTools::Constants::M_TOOLS_CPP)->addAction(cmd);
}
......@@ -235,12 +235,17 @@ bool CppPlugin::initialize(const QStringList & /*arguments*/, QString *errorMess
| TextEditor::TextEditorActionHandler::UnCollapseAll);
m_actionHandler->initializeActions();
QAction *separator = new QAction(this);
separator->setSeparator(true);
cmd = am->registerAction(separator, CppEditor::Constants::SEPARATOR, context);
contextMenu->addAction(cmd);
cmd = am->command(TextEditor::Constants::AUTO_INDENT_SELECTION);
am->actionContainer(CppEditor::Constants::M_CONTEXT)->addAction(cmd);
contextMenu->addAction(cmd);
cmd = am->command(TextEditor::Constants::UN_COMMENT_SELECTION);
am->actionContainer(CppEditor::Constants::M_CONTEXT)->addAction(cmd);
contextMenu->addAction(cmd);
readSettings();
......
......@@ -232,11 +232,13 @@ void TextEditorActionHandler::createActions()
command = am->registerAction(m_gotoBlockStartAction, Constants::GOTO_BLOCK_START, m_contextId);
command->setDefaultKeySequence(QKeySequence(tr("Ctrl+[")));
connect(m_gotoBlockStartAction, SIGNAL(triggered()), this, SLOT(gotoBlockStart()));
advancedMenu->addAction(command, Core::Constants::G_EDIT_BLOCKS);
m_gotoBlockEndAction = new QAction(tr("Goto Block End"), this);
command = am->registerAction(m_gotoBlockEndAction, Constants::GOTO_BLOCK_END, m_contextId);
command->setDefaultKeySequence(QKeySequence(tr("Ctrl+]")));
connect(m_gotoBlockEndAction, SIGNAL(triggered()), this, SLOT(gotoBlockEnd()));
advancedMenu->addAction(command, Core::Constants::G_EDIT_BLOCKS);
m_gotoBlockStartWithSelectionAction = new QAction(tr("Goto Block Start With Selection"), this);
command = am->registerAction(m_gotoBlockStartWithSelectionAction, Constants::GOTO_BLOCK_START_WITH_SELECTION, m_contextId);
......@@ -252,11 +254,13 @@ void TextEditorActionHandler::createActions()
command = am->registerAction(m_selectBlockUpAction, Constants::SELECT_BLOCK_UP, m_contextId);
command->setDefaultKeySequence(QKeySequence(tr("Ctrl+U")));
connect(m_selectBlockUpAction, SIGNAL(triggered()), this, SLOT(selectBlockUp()));
advancedMenu->addAction(command, Core::Constants::G_EDIT_BLOCKS);
m_selectBlockDownAction= new QAction(tr("Select Block Down"), this);
command = am->registerAction(m_selectBlockDownAction, Constants::SELECT_BLOCK_DOWN, m_contextId);
command->setDefaultKeySequence(QKeySequence(tr("Ctrl+Shift+U")));
connect(m_selectBlockDownAction, SIGNAL(triggered()), this, SLOT(selectBlockDown()));
advancedMenu->addAction(command, Core::Constants::G_EDIT_BLOCKS);
m_moveLineUpAction= new QAction(tr("Move Line Up"), this);
command = am->registerAction(m_moveLineUpAction, Constants::MOVE_LINE_UP, m_contextId);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment