Commit 600fc9b2 authored by mae's avatar mae
Browse files

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