Add ActionContainer::addSeparator(...)

Gets rid of a lot of code duplication.

Change-Id: I2ce38fb38a0b61cb821e0bdc7bcc9a7ccdf9da72
Reviewed-by: hjk <qthjk@ovi.com>
This commit is contained in:
Eike Ziller
2012-06-05 14:22:20 +02:00
committed by hjk
parent d90264d6c2
commit cdd44befff
34 changed files with 132 additions and 394 deletions

View File

@@ -548,15 +548,6 @@ void MainWindow::registerDefaultContainers()
ac->appendGroup(Constants::G_HELP_ABOUT);
}
static Command *createSeparator(QObject *parent,
const Id &id, const Context &context)
{
QAction *tmpaction = new QAction(parent);
tmpaction->setSeparator(true);
Command *cmd = ActionManager::registerAction(tmpaction, id, context);
return cmd;
}
void MainWindow::registerDefaultActions()
{
ActionContainer *mfile = ActionManager::actionContainer(Constants::M_FILE);
@@ -568,41 +559,25 @@ void MainWindow::registerDefaultActions()
Context globalContext(Constants::C_GLOBAL);
// File menu separators
Command *cmd = createSeparator(this, Id("QtCreator.File.Sep.Save"), globalContext);
mfile->addAction(cmd, Constants::G_FILE_SAVE);
cmd = createSeparator(this, Id("QtCreator.File.Sep.Print"), globalContext);
QIcon icon = QIcon::fromTheme(QLatin1String("edit-cut"), QIcon(QLatin1String(Constants::ICON_CUT)));
mfile->addAction(cmd, Constants::G_FILE_PRINT);
cmd = createSeparator(this, Id("QtCreator.File.Sep.Close"), globalContext);
mfile->addAction(cmd, Constants::G_FILE_CLOSE);
cmd = createSeparator(this, Id("QtCreator.File.Sep.Other"), globalContext);
mfile->addAction(cmd, Constants::G_FILE_OTHER);
mfile->addSeparator(globalContext, Constants::G_FILE_SAVE);
mfile->addSeparator(globalContext, Constants::G_FILE_PRINT);
mfile->addSeparator(globalContext, Constants::G_FILE_CLOSE);
mfile->addSeparator(globalContext, Constants::G_FILE_OTHER);
// Edit menu separators
cmd = createSeparator(this, Id("QtCreator.Edit.Sep.CopyPaste"), globalContext);
medit->addAction(cmd, Constants::G_EDIT_COPYPASTE);
cmd = createSeparator(this, Id("QtCreator.Edit.Sep.SelectAll"), globalContext);
medit->addAction(cmd, Constants::G_EDIT_SELECTALL);
cmd = createSeparator(this, Id("QtCreator.Edit.Sep.Find"), globalContext);
medit->addAction(cmd, Constants::G_EDIT_FIND);
cmd = createSeparator(this, Id("QtCreator.Edit.Sep.Advanced"), globalContext);
medit->addAction(cmd, Constants::G_EDIT_ADVANCED);
medit->addSeparator(globalContext, Constants::G_EDIT_COPYPASTE);
medit->addSeparator(globalContext, Constants::G_EDIT_SELECTALL);
medit->addSeparator(globalContext, Constants::G_EDIT_FIND);
medit->addSeparator(globalContext, Constants::G_EDIT_ADVANCED);
// Return to editor shortcut: Note this requires Qt to fix up
// handling of shortcut overrides in menus, item views, combos....
m_focusToEditor = new QShortcut(this);
cmd = ActionManager::registerShortcut(m_focusToEditor, Constants::S_RETURNTOEDITOR, globalContext);
Command *cmd = ActionManager::registerShortcut(m_focusToEditor, Constants::S_RETURNTOEDITOR, globalContext);
cmd->setDefaultKeySequence(QKeySequence(Qt::Key_Escape));
connect(m_focusToEditor, SIGNAL(activated()), this, SLOT(setFocusToEditor()));
// New File Action
icon = QIcon::fromTheme(QLatin1String("document-new"), QIcon(QLatin1String(Constants::ICON_NEWFILE)));
QIcon icon = QIcon::fromTheme(QLatin1String("document-new"), QIcon(QLatin1String(Constants::ICON_NEWFILE)));
m_newAction = new QAction(icon, tr("&New File or Project..."), this);
cmd = ActionManager::registerAction(m_newAction, Constants::NEW, globalContext);
cmd->setDefaultKeySequence(QKeySequence::New);
@@ -734,8 +709,7 @@ void MainWindow::registerDefaultActions()
// Options Action
mtools->appendGroup(Constants::G_TOOLS_OPTIONS);
cmd = createSeparator(this, Id("QtCreator.Tools.Sep.Options"), globalContext);
mtools->addAction(cmd, Constants::G_TOOLS_OPTIONS);
mtools->addSeparator(globalContext, Constants::G_TOOLS_OPTIONS);
m_optionsAction = new QAction(tr("&Options..."), this);
cmd = ActionManager::registerAction(m_optionsAction, Constants::OPTIONS, globalContext);
if (UseMacShortcuts) {
@@ -760,8 +734,7 @@ void MainWindow::registerDefaultActions()
connect(m_zoomAction, SIGNAL(triggered()), this, SLOT(showMaximized()));
// Window separator
cmd = createSeparator(this, Id("QtCreator.Window.Sep.Size"), globalContext);
mwindow->addAction(cmd, Constants::G_WINDOW_SIZE);
mwindow->addSeparator(globalContext, Constants::G_WINDOW_SIZE);
}
// Show Sidebar Action