Added some structure to the advanced edit menu

It was getting a bit cluttered without any grouping of the different
actions. Also, the collapse and expand actions have been added, mainly
for discoverability.
This commit is contained in:
Thorbjørn Lindeijer
2009-01-20 09:48:50 +01:00
parent ac6419f0d7
commit e0a4789081
5 changed files with 52 additions and 22 deletions

View File

@@ -174,11 +174,18 @@ const char * const G_FILE_OTHER = "QtCreator.Group.File.Other";
const char * const G_EDIT_UNDOREDO = "QtCreator.Group.Edit.UndoRedo"; const char * const G_EDIT_UNDOREDO = "QtCreator.Group.Edit.UndoRedo";
const char * const G_EDIT_COPYPASTE = "QtCreator.Group.Edit.CopyPaste"; const char * const G_EDIT_COPYPASTE = "QtCreator.Group.Edit.CopyPaste";
const char * const G_EDIT_SELECTALL = "QtCreator.Group.Edit.SelectAll"; const char * const G_EDIT_SELECTALL = "QtCreator.Group.Edit.SelectAll";
const char * const G_EDIT_FORMAT = "QtCreator.Group.Edit.Format"; const char * const G_EDIT_ADVANCED = "QtCreator.Group.Edit.Advanced";
const char * const G_EDIT_FIND = "QtCreator.Group.Edit.Find"; const char * const G_EDIT_FIND = "QtCreator.Group.Edit.Find";
const char * const G_EDIT_OTHER = "QtCreator.Group.Edit.Other"; const char * const G_EDIT_OTHER = "QtCreator.Group.Edit.Other";
// advanced edit menu groups
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_FONT = "QtCreator.Group.Edit.Font";
const char * const G_EDIT_EDITOR = "QtCreator.Group.Edit.Editor";
// window menu groups // window menu groups
const char * const G_WINDOW_SIZE = "QtCreator.Group.Window.Size"; const char * const G_WINDOW_SIZE = "QtCreator.Group.Window.Size";
const char * const G_WINDOW_PANES = "QtCreator.Group.Window.Panes"; const char * const G_WINDOW_PANES = "QtCreator.Group.Window.Panes";

View File

@@ -196,6 +196,16 @@ EditorManagerPrivate::~EditorManagerPrivate()
EditorManager *EditorManager::m_instance = 0; EditorManager *EditorManager::m_instance = 0;
static Command *createSeparator(ActionManager *am, QObject *parent,
const QString &name,
const QList<int> &context)
{
QAction *tmpaction = new QAction(parent);
tmpaction->setSeparator(true);
Command *cmd = am->registerAction(tmpaction, name, context);
return cmd;
}
EditorManager::EditorManager(ICore *core, QWidget *parent) : EditorManager::EditorManager(ICore *core, QWidget *parent) :
QWidget(parent), QWidget(parent),
m_d(new EditorManagerPrivate(core, parent)) m_d(new EditorManagerPrivate(core, parent))
@@ -319,12 +329,24 @@ EditorManager::EditorManager(ICore *core, QWidget *parent) :
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_FORMAT); 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_COLLAPSING);
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.Font"), editManagerContext);
advancedMenu->addAction(cmd, Constants::G_EDIT_FONT);
cmd = createSeparator(am, this, QLatin1String("QtCreator.Edit.Sep.Editor"), editManagerContext);
advancedMenu->addAction(cmd, Constants::G_EDIT_EDITOR);
cmd = am->registerAction(m_d->m_openInExternalEditorAction, Constants::OPEN_IN_EXTERNAL_EDITOR, editManagerContext); cmd = am->registerAction(m_d->m_openInExternalEditorAction, Constants::OPEN_IN_EXTERNAL_EDITOR, editManagerContext);
cmd->setDefaultKeySequence(QKeySequence(tr("Alt+V,Alt+I"))); cmd->setDefaultKeySequence(QKeySequence(tr("Alt+V,Alt+I")));
advancedMenu->addAction(cmd); advancedMenu->addAction(cmd, Constants::G_EDIT_EDITOR);
connect(m_d->m_openInExternalEditorAction, SIGNAL(triggered()), this, SLOT(openInExternalEditor())); connect(m_d->m_openInExternalEditorAction, SIGNAL(triggered()), this, SLOT(openInExternalEditor()));

View File

@@ -402,7 +402,7 @@ void MainWindow::registerDefaultContainers()
medit->appendGroup(Constants::G_EDIT_UNDOREDO); medit->appendGroup(Constants::G_EDIT_UNDOREDO);
medit->appendGroup(Constants::G_EDIT_COPYPASTE); medit->appendGroup(Constants::G_EDIT_COPYPASTE);
medit->appendGroup(Constants::G_EDIT_SELECTALL); medit->appendGroup(Constants::G_EDIT_SELECTALL);
medit->appendGroup(Constants::G_EDIT_FORMAT); medit->appendGroup(Constants::G_EDIT_ADVANCED);
medit->appendGroup(Constants::G_EDIT_FIND); medit->appendGroup(Constants::G_EDIT_FIND);
medit->appendGroup(Constants::G_EDIT_OTHER); medit->appendGroup(Constants::G_EDIT_OTHER);
@@ -432,9 +432,9 @@ void MainWindow::registerDefaultContainers()
ac->appendGroup(Constants::G_HELP_ABOUT); ac->appendGroup(Constants::G_HELP_ABOUT);
} }
static Command *createSeparator(ActionManagerPrivate *am, QObject *parent, static Command *createSeparator(ActionManager *am, QObject *parent,
const QString &name, const QString &name,
const QList<int> &context) const QList<int> &context)
{ {
QAction *tmpaction = new QAction(parent); QAction *tmpaction = new QAction(parent);
tmpaction->setSeparator(true); tmpaction->setSeparator(true);
@@ -465,7 +465,7 @@ void MainWindow::registerDefaultActions()
mfile->addAction(cmd, Constants::G_FILE_OTHER); mfile->addAction(cmd, Constants::G_FILE_OTHER);
// Edit menu separators // Edit menu separators
cmd = createSeparator(am, this, QLatin1String("QtCreator.Edit.Sep.CopyPaste"), m_globalContext); cmd = createSeparator(am, this, QLatin1String("QtCreator.Edit.Sep.CopyPaste"), m_globalContext);
medit->addAction(cmd, Constants::G_EDIT_COPYPASTE); medit->addAction(cmd, Constants::G_EDIT_COPYPASTE);
cmd = createSeparator(am, this, QLatin1String("QtCreator.Edit.Sep.SelectAll"), m_globalContext); cmd = createSeparator(am, this, QLatin1String("QtCreator.Edit.Sep.SelectAll"), m_globalContext);
@@ -474,8 +474,8 @@ void MainWindow::registerDefaultActions()
cmd = createSeparator(am, this, QLatin1String("QtCreator.Edit.Sep.Find"), m_globalContext); cmd = createSeparator(am, this, QLatin1String("QtCreator.Edit.Sep.Find"), m_globalContext);
medit->addAction(cmd, Constants::G_EDIT_FIND); medit->addAction(cmd, Constants::G_EDIT_FIND);
cmd = createSeparator(am, this, QLatin1String("QtCreator.Edit.Sep.Format"), m_globalContext); cmd = createSeparator(am, this, QLatin1String("QtCreator.Edit.Sep.Advanced"), m_globalContext);
medit->addAction(cmd, Constants::G_EDIT_FORMAT); medit->addAction(cmd, Constants::G_EDIT_ADVANCED);
//Tools menu separators //Tools menu separators
cmd = createSeparator(am, this, QLatin1String("QtCreator.Tools.Sep.Options"), m_globalContext); cmd = createSeparator(am, this, QLatin1String("QtCreator.Tools.Sep.Options"), m_globalContext);

View File

@@ -178,7 +178,7 @@ bool FakeVimPluginPrivate::initialize(const QStringList &arguments, QString *err
ActionContainer *advancedMenu = ActionContainer *advancedMenu =
actionManager->actionContainer(Core::Constants::M_EDIT_ADVANCED); actionManager->actionContainer(Core::Constants::M_EDIT_ADVANCED);
advancedMenu->addAction(cmd); advancedMenu->addAction(cmd, Core::Constants::G_EDIT_EDITOR);
connect(m_installHandlerAction, SIGNAL(triggered()), connect(m_installHandlerAction, SIGNAL(triggered()),
this, SLOT(installHandler())); this, SLOT(installHandler()));

View File

@@ -125,35 +125,34 @@ void TextEditorActionHandler::createActions()
m_formatAction = new QAction(tr("Auto-&indent Selection"), this); m_formatAction = new QAction(tr("Auto-&indent Selection"), this);
command = am->registerAction(m_formatAction, TextEditor::Constants::AUTO_INDENT_SELECTION, m_contextId); command = am->registerAction(m_formatAction, TextEditor::Constants::AUTO_INDENT_SELECTION, m_contextId);
command->setDefaultKeySequence(QKeySequence(tr("Ctrl+I"))); command->setDefaultKeySequence(QKeySequence(tr("Ctrl+I")));
advancedMenu->addAction(command); advancedMenu->addAction(command, Core::Constants::G_EDIT_FORMAT);
connect(m_formatAction, SIGNAL(triggered(bool)), this, SLOT(formatAction())); connect(m_formatAction, SIGNAL(triggered(bool)), this, SLOT(formatAction()));
m_visualizeWhitespaceAction = new QAction(tr("&Visualize Whitespace"), this); m_visualizeWhitespaceAction = new QAction(tr("&Visualize Whitespace"), this);
m_visualizeWhitespaceAction->setCheckable(true); m_visualizeWhitespaceAction->setCheckable(true);
command = am->registerAction(m_visualizeWhitespaceAction, command = am->registerAction(m_visualizeWhitespaceAction,
TextEditor::Constants::VISUALIZE_WHITESPACE, m_contextId); TextEditor::Constants::VISUALIZE_WHITESPACE, m_contextId);
#ifndef Q_OS_MAC #ifndef Q_OS_MAC
command->setDefaultKeySequence(QKeySequence(tr("Ctrl+E, Ctrl+V"))); command->setDefaultKeySequence(QKeySequence(tr("Ctrl+E, Ctrl+V")));
#endif #endif
advancedMenu->addAction(command); advancedMenu->addAction(command, Core::Constants::G_EDIT_FORMAT);
connect(m_visualizeWhitespaceAction, SIGNAL(triggered(bool)), this, SLOT(setVisualizeWhitespace(bool))); connect(m_visualizeWhitespaceAction, SIGNAL(triggered(bool)), this, SLOT(setVisualizeWhitespace(bool)));
m_cleanWhitespaceAction = new QAction(tr("Clean Whitespace"), this); m_cleanWhitespaceAction = new QAction(tr("Clean Whitespace"), this);
command = am->registerAction(m_cleanWhitespaceAction, command = am->registerAction(m_cleanWhitespaceAction,
TextEditor::Constants::CLEAN_WHITESPACE, m_contextId); TextEditor::Constants::CLEAN_WHITESPACE, m_contextId);
advancedMenu->addAction(command); advancedMenu->addAction(command, Core::Constants::G_EDIT_FORMAT);
connect(m_cleanWhitespaceAction, SIGNAL(triggered()), this, SLOT(cleanWhitespace())); connect(m_cleanWhitespaceAction, SIGNAL(triggered()), this, SLOT(cleanWhitespace()));
m_textWrappingAction = new QAction(tr("Enable Text &Wrapping"), this); m_textWrappingAction = new QAction(tr("Enable Text &Wrapping"), this);
m_textWrappingAction->setCheckable(true); m_textWrappingAction->setCheckable(true);
command = am->registerAction(m_textWrappingAction, command = am->registerAction(m_textWrappingAction, TextEditor::Constants::TEXT_WRAPPING, m_contextId);
TextEditor::Constants::TEXT_WRAPPING, m_contextId);
#ifndef Q_OS_MAC #ifndef Q_OS_MAC
command->setDefaultKeySequence(QKeySequence(tr("Ctrl+E, Ctrl+W"))); command->setDefaultKeySequence(QKeySequence(tr("Ctrl+E, Ctrl+W")));
#endif #endif
advancedMenu->addAction(command); advancedMenu->addAction(command, Core::Constants::G_EDIT_FORMAT);
connect(m_textWrappingAction, SIGNAL(triggered(bool)), this, SLOT(setTextWrapping(bool))); connect(m_textWrappingAction, SIGNAL(triggered(bool)), this, SLOT(setTextWrapping(bool)));
@@ -161,7 +160,7 @@ void TextEditorActionHandler::createActions()
command = am->registerAction(m_unCommentSelectionAction, Constants::UN_COMMENT_SELECTION, m_contextId); command = am->registerAction(m_unCommentSelectionAction, Constants::UN_COMMENT_SELECTION, m_contextId);
command->setDefaultKeySequence(QKeySequence(tr("Ctrl+/"))); command->setDefaultKeySequence(QKeySequence(tr("Ctrl+/")));
connect(m_unCommentSelectionAction, SIGNAL(triggered()), this, SLOT(unCommentSelection())); connect(m_unCommentSelectionAction, SIGNAL(triggered()), this, SLOT(unCommentSelection()));
advancedMenu->addAction(command); advancedMenu->addAction(command, Core::Constants::G_EDIT_FORMAT);
m_deleteLineAction = new QAction(tr("Delete &Line"), this); m_deleteLineAction = new QAction(tr("Delete &Line"), this);
command = am->registerAction(m_deleteLineAction, Constants::DELETE_LINE, m_contextId); command = am->registerAction(m_deleteLineAction, Constants::DELETE_LINE, m_contextId);
@@ -172,28 +171,30 @@ void TextEditorActionHandler::createActions()
command = am->registerAction(m_collapseAction, Constants::COLLAPSE, m_contextId); command = am->registerAction(m_collapseAction, Constants::COLLAPSE, m_contextId);
command->setDefaultKeySequence(QKeySequence(tr("Ctrl+<"))); command->setDefaultKeySequence(QKeySequence(tr("Ctrl+<")));
connect(m_collapseAction, SIGNAL(triggered()), this, SLOT(collapse())); connect(m_collapseAction, SIGNAL(triggered()), this, SLOT(collapse()));
advancedMenu->addAction(command, Core::Constants::G_EDIT_COLLAPSING);
m_expandAction = new QAction(tr("Expand"), this); m_expandAction = new QAction(tr("Expand"), this);
command = am->registerAction(m_expandAction, Constants::EXPAND, m_contextId); command = am->registerAction(m_expandAction, Constants::EXPAND, m_contextId);
command->setDefaultKeySequence(QKeySequence(tr("Ctrl+>"))); command->setDefaultKeySequence(QKeySequence(tr("Ctrl+>")));
connect(m_expandAction, SIGNAL(triggered()), this, SLOT(expand())); connect(m_expandAction, SIGNAL(triggered()), this, SLOT(expand()));
advancedMenu->addAction(command, Core::Constants::G_EDIT_COLLAPSING);
m_unCollapseAllAction = new QAction(tr("(Un)&Collapse All"), this); m_unCollapseAllAction = new QAction(tr("(Un)&Collapse All"), this);
command = am->registerAction(m_unCollapseAllAction, Constants::UN_COLLAPSE_ALL, m_contextId); command = am->registerAction(m_unCollapseAllAction, Constants::UN_COLLAPSE_ALL, m_contextId);
connect(m_unCollapseAllAction, SIGNAL(triggered()), this, SLOT(unCollapseAll())); connect(m_unCollapseAllAction, SIGNAL(triggered()), this, SLOT(unCollapseAll()));
advancedMenu->addAction(command); advancedMenu->addAction(command, Core::Constants::G_EDIT_COLLAPSING);
m_increaseFontSizeAction = new QAction(tr("Increase Font Size"), this); m_increaseFontSizeAction = new QAction(tr("Increase Font Size"), this);
command = am->registerAction(m_increaseFontSizeAction, Constants::INCREASE_FONT_SIZE, m_contextId); command = am->registerAction(m_increaseFontSizeAction, Constants::INCREASE_FONT_SIZE, m_contextId);
command->setDefaultKeySequence(QKeySequence(tr("Ctrl++"))); command->setDefaultKeySequence(QKeySequence(tr("Ctrl++")));
connect(m_increaseFontSizeAction, SIGNAL(triggered()), this, SLOT(increaseFontSize())); connect(m_increaseFontSizeAction, SIGNAL(triggered()), this, SLOT(increaseFontSize()));
advancedMenu->addAction(command); advancedMenu->addAction(command, Core::Constants::G_EDIT_FONT);
m_decreaseFontSizeAction = new QAction(tr("Decrease Font Size"), this); m_decreaseFontSizeAction = new QAction(tr("Decrease Font Size"), this);
command = am->registerAction(m_decreaseFontSizeAction, Constants::DECREASE_FONT_SIZE, m_contextId); command = am->registerAction(m_decreaseFontSizeAction, Constants::DECREASE_FONT_SIZE, m_contextId);
command->setDefaultKeySequence(QKeySequence(tr("Ctrl+-"))); command->setDefaultKeySequence(QKeySequence(tr("Ctrl+-")));
connect(m_decreaseFontSizeAction, SIGNAL(triggered()), this, SLOT(decreaseFontSize())); connect(m_decreaseFontSizeAction, SIGNAL(triggered()), this, SLOT(decreaseFontSize()));
advancedMenu->addAction(command); advancedMenu->addAction(command, Core::Constants::G_EDIT_FONT);
m_gotoBlockStartAction = new QAction(tr("Goto Block Start"), this); m_gotoBlockStartAction = new QAction(tr("Goto Block Start"), this);
command = am->registerAction(m_gotoBlockStartAction, Constants::GOTO_BLOCK_START, m_contextId); command = am->registerAction(m_gotoBlockStartAction, Constants::GOTO_BLOCK_START, m_contextId);