本文整理汇总了C++中ActionContainer::addSeparator方法的典型用法代码示例。如果您正苦于以下问题:C++ ActionContainer::addSeparator方法的具体用法?C++ ActionContainer::addSeparator怎么用?C++ ActionContainer::addSeparator使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ActionContainer
的用法示例。
在下文中一共展示了ActionContainer::addSeparator方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setId
CMakeEditorFactory::CMakeEditorFactory()
{
setId(Constants::CMAKE_EDITOR_ID);
setDisplayName(tr(Constants::CMAKE_EDITOR_DISPLAY_NAME));
addMimeType(Constants::CMAKEMIMETYPE);
addMimeType(Constants::CMAKEPROJECTMIMETYPE);
setEditorCreator([]() { return new CMakeEditor; });
setEditorWidgetCreator([]() { return new CMakeEditorWidget; });
setDocumentCreator([]() { return new CMakeDocument; });
setIndenterCreator([]() { return new CMakeIndenter; });
setUseGenericHighlighter(true);
setCommentStyle(Utils::CommentDefinition::HashStyle);
setCodeFoldingSupported(true);
setCompletionAssistProvider(new CMakeFileCompletionAssistProvider);
setAutoCompleterCreator([]() { return new CMakeAutoCompleter; });
setEditorActionHandlers(TextEditorActionHandler::UnCommentSelection
| TextEditorActionHandler::JumpToFileUnderCursor
| TextEditorActionHandler::Format);
ActionContainer *contextMenu = ActionManager::createMenu(Constants::M_CONTEXT);
contextMenu->addAction(ActionManager::command(TextEditor::Constants::JUMP_TO_FILE_UNDER_CURSOR));
contextMenu->addSeparator(Context(Constants::CMAKE_EDITOR_ID));
contextMenu->addAction(ActionManager::command(TextEditor::Constants::UN_COMMENT_SELECTION));
}
示例2: registerDefaultActions
void MainWindow::registerDefaultActions()
{
ActionContainer *mfile = ActionManager::actionContainer(Constants::M_FILE);
ActionContainer *medit = ActionManager::actionContainer(Constants::M_EDIT);
ActionContainer *mtools = ActionManager::actionContainer(Constants::M_TOOLS);
ActionContainer *mwindow = ActionManager::actionContainer(Constants::M_WINDOW);
ActionContainer *mhelp = ActionManager::actionContainer(Constants::M_HELP);
// File menu separators
mfile->addSeparator(Constants::G_FILE_SAVE);
mfile->addSeparator(Constants::G_FILE_PRINT);
mfile->addSeparator(Constants::G_FILE_CLOSE);
mfile->addSeparator(Constants::G_FILE_OTHER);
// Edit menu separators
medit->addSeparator(Constants::G_EDIT_COPYPASTE);
medit->addSeparator(Constants::G_EDIT_SELECTALL);
medit->addSeparator(Constants::G_EDIT_FIND);
medit->addSeparator(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 QAction(tr("Return to Editor"), this);
Command *cmd = ActionManager::registerAction(m_focusToEditor, Constants::S_RETURNTOEDITOR);
cmd->setDefaultKeySequence(QKeySequence(Qt::Key_Escape));
connect(m_focusToEditor, SIGNAL(triggered()), this, SLOT(setFocusToEditor()));
// New File Action
QIcon icon = QIcon::fromTheme(QLatin1String("document-new"), Icons::NEWFILE.icon());
m_newAction = new QAction(icon, tr("&New File or Project..."), this);
cmd = ActionManager::registerAction(m_newAction, Constants::NEW);
cmd->setDefaultKeySequence(QKeySequence::New);
mfile->addAction(cmd, Constants::G_FILE_NEW);
connect(m_newAction, &QAction::triggered, this, [this]() {
ICore::showNewItemDialog(tr("New File or Project", "Title of dialog"),
IWizardFactory::allWizardFactories(), QString());
});
connect(ICore::instance(), &ICore::newItemDialogRunningChanged, m_newAction, [this]() {
m_newAction->setEnabled(!ICore::isNewItemDialogRunning());
});
// Open Action
icon = QIcon::fromTheme(QLatin1String("document-open"), Icons::OPENFILE.icon());
m_openAction = new QAction(icon, tr("&Open File or Project..."), this);
cmd = ActionManager::registerAction(m_openAction, Constants::OPEN);
cmd->setDefaultKeySequence(QKeySequence::Open);
mfile->addAction(cmd, Constants::G_FILE_OPEN);
connect(m_openAction, SIGNAL(triggered()), this, SLOT(openFile()));
// Open With Action
m_openWithAction = new QAction(tr("Open File &With..."), this);
cmd = ActionManager::registerAction(m_openWithAction, Constants::OPEN_WITH);
mfile->addAction(cmd, Constants::G_FILE_OPEN);
connect(m_openWithAction, SIGNAL(triggered()), this, SLOT(openFileWith()));
// File->Recent Files Menu
ActionContainer *ac = ActionManager::createMenu(Constants::M_FILE_RECENTFILES);
mfile->addMenu(ac, Constants::G_FILE_OPEN);
ac->menu()->setTitle(tr("Recent &Files"));
ac->setOnAllDisabledBehavior(ActionContainer::Show);
// Save Action
icon = QIcon::fromTheme(QLatin1String("document-save"), Icons::SAVEFILE.icon());
QAction *tmpaction = new QAction(icon, tr("&Save"), this);
tmpaction->setEnabled(false);
cmd = ActionManager::registerAction(tmpaction, Constants::SAVE);
cmd->setDefaultKeySequence(QKeySequence::Save);
cmd->setAttribute(Command::CA_UpdateText);
cmd->setDescription(tr("Save"));
mfile->addAction(cmd, Constants::G_FILE_SAVE);
// Save As Action
icon = QIcon::fromTheme(QLatin1String("document-save-as"));
tmpaction = new QAction(icon, tr("Save &As..."), this);
tmpaction->setEnabled(false);
cmd = ActionManager::registerAction(tmpaction, Constants::SAVEAS);
cmd->setDefaultKeySequence(QKeySequence(UseMacShortcuts ? tr("Ctrl+Shift+S") : QString()));
cmd->setAttribute(Command::CA_UpdateText);
cmd->setDescription(tr("Save As..."));
mfile->addAction(cmd, Constants::G_FILE_SAVE);
// SaveAll Action
m_saveAllAction = new QAction(tr("Save A&ll"), this);
cmd = ActionManager::registerAction(m_saveAllAction, Constants::SAVEALL);
cmd->setDefaultKeySequence(QKeySequence(UseMacShortcuts ? QString() : tr("Ctrl+Shift+S")));
mfile->addAction(cmd, Constants::G_FILE_SAVE);
connect(m_saveAllAction, SIGNAL(triggered()), this, SLOT(saveAll()));
// Print Action
icon = QIcon::fromTheme(QLatin1String("document-print"));
tmpaction = new QAction(icon, tr("&Print..."), this);
tmpaction->setEnabled(false);
cmd = ActionManager::registerAction(tmpaction, Constants::PRINT);
cmd->setDefaultKeySequence(QKeySequence::Print);
mfile->addAction(cmd, Constants::G_FILE_PRINT);
// Exit Action
icon = QIcon::fromTheme(QLatin1String("application-exit"));
m_exitAction = new QAction(icon, tr("E&xit"), this);
m_exitAction->setMenuRole(QAction::QuitRole);
cmd = ActionManager::registerAction(m_exitAction, Constants::EXIT);
//.........这里部分代码省略.........
示例3: initialize
bool CppEditorPlugin::initialize(const QStringList & /*arguments*/, QString *errorMessage)
{
Q_UNUSED(errorMessage)
Utils::MimeDatabase::addMimeTypes(QLatin1String(":/cppeditor/CppEditor.mimetypes.xml"));
addAutoReleasedObject(new CppEditorFactory);
addAutoReleasedObject(new CppOutlineWidgetFactory);
addAutoReleasedObject(new CppTypeHierarchyFactory);
addAutoReleasedObject(new CppIncludeHierarchyFactory);
addAutoReleasedObject(new CppSnippetProvider);
m_quickFixProvider = new CppQuickFixAssistProvider;
addAutoReleasedObject(m_quickFixProvider);
registerQuickFixes(this);
Context context(Constants::CPPEDITOR_ID);
ActionContainer *contextMenu = ActionManager::createMenu(Constants::M_CONTEXT);
Command *cmd;
ActionContainer *cppToolsMenu = ActionManager::actionContainer(CppTools::Constants::M_TOOLS_CPP);
cmd = ActionManager::command(CppTools::Constants::SWITCH_HEADER_SOURCE);
contextMenu->addAction(cmd);
cmd = ActionManager::command(TextEditor::Constants::FOLLOW_SYMBOL_UNDER_CURSOR);
contextMenu->addAction(cmd);
cppToolsMenu->addAction(cmd);
QAction *openPreprocessorDialog = new QAction(tr("Additional Preprocessor Directives..."), this);
cmd = ActionManager::registerAction(openPreprocessorDialog,
Constants::OPEN_PREPROCESSOR_DIALOG, context);
cmd->setDefaultKeySequence(QKeySequence());
connect(openPreprocessorDialog, SIGNAL(triggered()), this, SLOT(showPreProcessorDialog()));
cppToolsMenu->addAction(cmd);
QAction *switchDeclarationDefinition = new QAction(tr("Switch Between Function Declaration/Definition"), this);
cmd = ActionManager::registerAction(switchDeclarationDefinition,
Constants::SWITCH_DECLARATION_DEFINITION, context, true);
cmd->setDefaultKeySequence(QKeySequence(tr("Shift+F2")));
connect(switchDeclarationDefinition, SIGNAL(triggered()),
this, SLOT(switchDeclarationDefinition()));
contextMenu->addAction(cmd);
cppToolsMenu->addAction(cmd);
cmd = ActionManager::command(TextEditor::Constants::FOLLOW_SYMBOL_UNDER_CURSOR_IN_NEXT_SPLIT);
cppToolsMenu->addAction(cmd);
QAction *openDeclarationDefinitionInNextSplit =
new QAction(tr("Open Function Declaration/Definition in Next Split"), this);
cmd = ActionManager::registerAction(openDeclarationDefinitionInNextSplit,
Constants::OPEN_DECLARATION_DEFINITION_IN_NEXT_SPLIT, context, true);
cmd->setDefaultKeySequence(QKeySequence(HostOsInfo::isMacHost()
? tr("Meta+E, Shift+F2")
: tr("Ctrl+E, Shift+F2")));
connect(openDeclarationDefinitionInNextSplit, SIGNAL(triggered()),
this, SLOT(openDeclarationDefinitionInNextSplit()));
cppToolsMenu->addAction(cmd);
m_findUsagesAction = new QAction(tr("Find Usages"), this);
cmd = ActionManager::registerAction(m_findUsagesAction, Constants::FIND_USAGES, context);
cmd->setDefaultKeySequence(QKeySequence(tr("Ctrl+Shift+U")));
connect(m_findUsagesAction, SIGNAL(triggered()), this, SLOT(findUsages()));
contextMenu->addAction(cmd);
cppToolsMenu->addAction(cmd);
m_openTypeHierarchyAction = new QAction(tr("Open Type Hierarchy"), this);
cmd = ActionManager::registerAction(m_openTypeHierarchyAction, Constants::OPEN_TYPE_HIERARCHY, context);
cmd->setDefaultKeySequence(QKeySequence(UseMacShortcuts ? tr("Meta+Shift+T") : tr("Ctrl+Shift+T")));
connect(m_openTypeHierarchyAction, SIGNAL(triggered()), this, SLOT(openTypeHierarchy()));
contextMenu->addAction(cmd);
cppToolsMenu->addAction(cmd);
m_openIncludeHierarchyAction = new QAction(tr("Open Include Hierarchy"), this);
cmd = ActionManager::registerAction(m_openIncludeHierarchyAction, Constants::OPEN_INCLUDE_HIERARCHY, context);
cmd->setDefaultKeySequence(QKeySequence(UseMacShortcuts ? tr("Meta+Shift+I") : tr("Ctrl+Shift+I")));
connect(m_openIncludeHierarchyAction, SIGNAL(triggered()), this, SLOT(openIncludeHierarchy()));
contextMenu->addAction(cmd);
cppToolsMenu->addAction(cmd);
// Refactoring sub-menu
Command *sep = contextMenu->addSeparator();
sep->action()->setObjectName(QLatin1String(Constants::M_REFACTORING_MENU_INSERTION_POINT));
contextMenu->addSeparator();
m_renameSymbolUnderCursorAction = new QAction(tr("Rename Symbol Under Cursor"),
this);
cmd = ActionManager::registerAction(m_renameSymbolUnderCursorAction,
Constants::RENAME_SYMBOL_UNDER_CURSOR,
context);
cmd->setDefaultKeySequence(QKeySequence(tr("CTRL+SHIFT+R")));
connect(m_renameSymbolUnderCursorAction, SIGNAL(triggered()),
this, SLOT(renameSymbolUnderCursor()));
cppToolsMenu->addAction(cmd);
// Update context in global context
cppToolsMenu->addSeparator();
m_reparseExternallyChangedFiles = new QAction(tr("Reparse Externally Changed Files"), this);
cmd = ActionManager::registerAction(m_reparseExternallyChangedFiles, Constants::UPDATE_CODEMODEL);
CppTools::CppModelManager *cppModelManager = CppTools::CppModelManager::instance();
//.........这里部分代码省略.........
示例4: initialize
//.........这里部分代码省略.........
Constants::OPEN_PREPROCESSOR_DIALOG, context);
cmd->setDefaultKeySequence(QKeySequence());
connect(openPreprocessorDialog, SIGNAL(triggered()), this, SLOT(showPreProcessorDialog()));
cppToolsMenu->addAction(cmd);
QAction *switchDeclarationDefinition = new QAction(tr("Switch Between Function Declaration/Definition"), this);
cmd = ActionManager::registerAction(switchDeclarationDefinition,
Constants::SWITCH_DECLARATION_DEFINITION, context, true);
cmd->setDefaultKeySequence(QKeySequence(tr("Shift+F2")));
connect(switchDeclarationDefinition, SIGNAL(triggered()),
this, SLOT(switchDeclarationDefinition()));
contextMenu->addAction(cmd);
cppToolsMenu->addAction(cmd);
cmd = ActionManager::command(TextEditor::Constants::FOLLOW_SYMBOL_UNDER_CURSOR_IN_NEXT_SPLIT);
cppToolsMenu->addAction(cmd);
QAction *openDeclarationDefinitionInNextSplit =
new QAction(tr("Open Function Declaration/Definition in Next Split"), this);
cmd = ActionManager::registerAction(openDeclarationDefinitionInNextSplit,
Constants::OPEN_DECLARATION_DEFINITION_IN_NEXT_SPLIT, context, true);
cmd->setDefaultKeySequence(QKeySequence(Utils::HostOsInfo::isMacHost()
? tr("Meta+E, Shift+F2")
: tr("Ctrl+E, Shift+F2")));
connect(openDeclarationDefinitionInNextSplit, SIGNAL(triggered()),
this, SLOT(openDeclarationDefinitionInNextSplit()));
cppToolsMenu->addAction(cmd);
m_findUsagesAction = new QAction(tr("Find Usages"), this);
cmd = ActionManager::registerAction(m_findUsagesAction, Constants::FIND_USAGES, context);
cmd->setDefaultKeySequence(QKeySequence(tr("Ctrl+Shift+U")));
connect(m_findUsagesAction, SIGNAL(triggered()), this, SLOT(findUsages()));
contextMenu->addAction(cmd);
cppToolsMenu->addAction(cmd);
m_openTypeHierarchyAction = new QAction(tr("Open Type Hierarchy"), this);
cmd = ActionManager::registerAction(m_openTypeHierarchyAction, Constants::OPEN_TYPE_HIERARCHY, context);
cmd->setDefaultKeySequence(QKeySequence(UseMacShortcuts ? tr("Meta+Shift+T") : tr("Ctrl+Shift+T")));
connect(m_openTypeHierarchyAction, SIGNAL(triggered()), this, SLOT(openTypeHierarchy()));
contextMenu->addAction(cmd);
cppToolsMenu->addAction(cmd);
m_openIncludeHierarchyAction = new QAction(tr("Open Include Hierarchy"), this);
cmd = Core::ActionManager::registerAction(m_openIncludeHierarchyAction, Constants::OPEN_INCLUDE_HIERARCHY, context);
cmd->setDefaultKeySequence(QKeySequence(Core::UseMacShortcuts ? tr("Meta+Shift+I") : tr("Ctrl+Shift+I")));
connect(m_openIncludeHierarchyAction, SIGNAL(triggered()), this, SLOT(openIncludeHierarchy()));
contextMenu->addAction(cmd);
cppToolsMenu->addAction(cmd);
// Refactoring sub-menu
Context globalContext(Core::Constants::C_GLOBAL);
Command *sep = contextMenu->addSeparator(globalContext);
sep->action()->setObjectName(QLatin1String(Constants::M_REFACTORING_MENU_INSERTION_POINT));
contextMenu->addSeparator(globalContext);
m_renameSymbolUnderCursorAction = new QAction(tr("Rename Symbol Under Cursor"),
this);
cmd = ActionManager::registerAction(m_renameSymbolUnderCursorAction,
Constants::RENAME_SYMBOL_UNDER_CURSOR,
context);
cmd->setDefaultKeySequence(QKeySequence(tr("CTRL+SHIFT+R")));
connect(m_renameSymbolUnderCursorAction, SIGNAL(triggered()),
this, SLOT(renameSymbolUnderCursor()));
cppToolsMenu->addAction(cmd);
// Update context in global context
cppToolsMenu->addSeparator(globalContext);
m_reparseExternallyChangedFiles = new QAction(tr("Reparse Externally Changed Files"), this);
cmd = ActionManager::registerAction(m_reparseExternallyChangedFiles, Constants::UPDATE_CODEMODEL, globalContext);
CppTools::CppModelManagerInterface *cppModelManager = CppTools::CppModelManagerInterface::instance();
connect(m_reparseExternallyChangedFiles, SIGNAL(triggered()), cppModelManager, SLOT(updateModifiedSourceFiles()));
cppToolsMenu->addAction(cmd);
m_actionHandler = new TextEditor::TextEditorActionHandler(CppEditor::Constants::C_CPPEDITOR,
TextEditor::TextEditorActionHandler::Format
| TextEditor::TextEditorActionHandler::UnCommentSelection
| TextEditor::TextEditorActionHandler::UnCollapseAll
| TextEditor::TextEditorActionHandler::FollowSymbolUnderCursor);
m_actionHandler->initializeActions();
contextMenu->addSeparator(context);
cmd = ActionManager::command(TextEditor::Constants::AUTO_INDENT_SELECTION);
contextMenu->addAction(cmd);
cmd = ActionManager::command(TextEditor::Constants::UN_COMMENT_SELECTION);
contextMenu->addAction(cmd);
connect(ProgressManager::instance(), SIGNAL(taskStarted(Core::Id)),
this, SLOT(onTaskStarted(Core::Id)));
connect(ProgressManager::instance(), SIGNAL(allTasksFinished(Core::Id)),
this, SLOT(onAllTasksFinished(Core::Id)));
connect(EditorManager::instance(), SIGNAL(currentEditorChanged(Core::IEditor*)),
SLOT(currentEditorChanged(Core::IEditor*)));
readSettings();
return true;
}
示例5: initialize
bool BookmarksPlugin::initialize(const QStringList & /*arguments*/, QString *)
{
Context textcontext(TextEditor::Constants::C_TEXTEDITOR);
Context globalcontext(Core::Constants::C_GLOBAL);
ActionContainer *mtools = ActionManager::actionContainer(Core::Constants::M_TOOLS);
ActionContainer *mbm = ActionManager::createMenu(Id(BOOKMARKS_MENU));
mbm->menu()->setTitle(tr("&Bookmarks"));
mtools->addMenu(mbm);
//Toggle
m_toggleAction = new QAction(tr("Toggle Bookmark"), this);
Command *cmd = ActionManager::registerAction(m_toggleAction, BOOKMARKS_TOGGLE_ACTION, textcontext);
cmd->setDefaultKeySequence(QKeySequence(UseMacShortcuts ? tr("Meta+M") : tr("Ctrl+M")));
mbm->addAction(cmd);
mbm->addSeparator(textcontext);
//Previous
m_prevAction = new QAction(tr("Previous Bookmark"), this);
cmd = ActionManager::registerAction(m_prevAction, BOOKMARKS_PREV_ACTION, globalcontext);
cmd->setDefaultKeySequence(QKeySequence(UseMacShortcuts ? tr("Meta+,") : tr("Ctrl+,")));
mbm->addAction(cmd);
//Next
m_nextAction = new QAction(tr("Next Bookmark"), this);
cmd = ActionManager::registerAction(m_nextAction, BOOKMARKS_NEXT_ACTION, globalcontext);
cmd->setDefaultKeySequence(QKeySequence(UseMacShortcuts ? tr("Meta+.") : tr("Ctrl+.")));
mbm->addAction(cmd);
mbm->addSeparator(globalcontext);
//Previous Doc
m_docPrevAction = new QAction(tr("Previous Bookmark in Document"), this);
cmd = ActionManager::registerAction(m_docPrevAction, BOOKMARKS_PREVDOC_ACTION, globalcontext);
mbm->addAction(cmd);
//Next Doc
m_docNextAction = new QAction(tr("Next Bookmark in Document"), this);
cmd = ActionManager::registerAction(m_docNextAction, BOOKMARKS_NEXTDOC_ACTION, globalcontext);
mbm->addAction(cmd);
m_editBookmarkAction = new QAction(tr("Edit Bookmark"), this);
m_bookmarkManager = new BookmarkManager;
connect(m_toggleAction, &QAction::triggered, [this]() {
if (BaseTextEditor *editor = BaseTextEditor::currentTextEditor())
m_bookmarkManager->toggleBookmark(editor->document()->filePath(), editor->currentLine());
});
connect(m_prevAction, &QAction::triggered, m_bookmarkManager, &BookmarkManager::prev);
connect(m_nextAction, &QAction::triggered, m_bookmarkManager, &BookmarkManager::next);
connect(m_docPrevAction, &QAction::triggered, m_bookmarkManager, &BookmarkManager::prevInDocument);
connect(m_docNextAction, &QAction::triggered, m_bookmarkManager, &BookmarkManager::nextInDocument);
connect(m_editBookmarkAction, &QAction::triggered, [this]() {
m_bookmarkManager->editByFileAndLine(m_bookmarkMarginActionFileName, m_bookmarkMarginActionLineNumber);
});
connect(m_bookmarkManager, &BookmarkManager::updateActions, this, &BookmarksPlugin::updateActions);
updateActions(m_bookmarkManager->state());
addAutoReleasedObject(new BookmarkViewFactory(m_bookmarkManager));
m_bookmarkMarginAction = new QAction(this);
m_bookmarkMarginAction->setText(tr("Toggle Bookmark"));
connect(m_bookmarkMarginAction, &QAction::triggered, [this]() {
m_bookmarkManager->toggleBookmark(m_bookmarkMarginActionFileName,
m_bookmarkMarginActionLineNumber);
});
// EditorManager
connect(EditorManager::instance(), &EditorManager::editorAboutToClose,
this, &BookmarksPlugin::editorAboutToClose);
connect(EditorManager::instance(), &EditorManager::editorOpened,
this, &BookmarksPlugin::editorOpened);
return true;
}
示例6: init
void OutputPaneManager::init()
{
ActionContainer *mwindow = ActionManager::actionContainer(Constants::M_WINDOW);
// Window->Output Panes
ActionContainer *mpanes = ActionManager::createMenu(Constants::M_WINDOW_PANES);
mwindow->addMenu(mpanes, Constants::G_WINDOW_PANES);
mpanes->menu()->setTitle(tr("Output &Panes"));
mpanes->appendGroup("Coreplugin.OutputPane.ActionsGroup");
mpanes->appendGroup("Coreplugin.OutputPane.PanesGroup");
Command *cmd;
cmd = ActionManager::registerAction(m_clearAction, "Coreplugin.OutputPane.clear");
m_clearButton->setDefaultAction(cmd->action());
m_clearButton->setIcon(Icons::CLEAN_TOOLBAR.icon());
mpanes->addAction(cmd, "Coreplugin.OutputPane.ActionsGroup");
cmd = ActionManager::registerAction(m_prevAction, "Coreplugin.OutputPane.previtem");
cmd->setDefaultKeySequence(QKeySequence(tr("Shift+F6")));
m_prevToolButton->setDefaultAction(
ProxyAction::proxyActionWithIcon(cmd->action(), Utils::Icons::PREV_TOOLBAR.icon()));
mpanes->addAction(cmd, "Coreplugin.OutputPane.ActionsGroup");
cmd = ActionManager::registerAction(m_nextAction, "Coreplugin.OutputPane.nextitem");
m_nextToolButton->setDefaultAction(
ProxyAction::proxyActionWithIcon(cmd->action(), Utils::Icons::NEXT_TOOLBAR.icon()));
cmd->setDefaultKeySequence(QKeySequence(tr("F6")));
mpanes->addAction(cmd, "Coreplugin.OutputPane.ActionsGroup");
cmd = ActionManager::registerAction(m_minMaxAction, "Coreplugin.OutputPane.minmax");
cmd->setDefaultKeySequence(QKeySequence(UseMacShortcuts ? tr("Ctrl+Shift+9") : tr("Alt+Shift+9")));
cmd->setAttribute(Command::CA_UpdateText);
cmd->setAttribute(Command::CA_UpdateIcon);
mpanes->addAction(cmd, "Coreplugin.OutputPane.ActionsGroup");
connect(m_minMaxAction, &QAction::triggered, this, &OutputPaneManager::toggleMaximized);
m_minMaxButton->setDefaultAction(cmd->action());
mpanes->addSeparator("Coreplugin.OutputPane.ActionsGroup");
QFontMetrics titleFm = m_titleLabel->fontMetrics();
int minTitleWidth = 0;
m_panes = ExtensionSystem::PluginManager::getObjects<IOutputPane>();
Utils::sort(m_panes, [](IOutputPane *p1, IOutputPane *p2) {
return p1->priorityInStatusBar() > p2->priorityInStatusBar();
});
const int n = m_panes.size();
int shortcutNumber = 1;
const Id baseId = "QtCreator.Pane.";
for (int i = 0; i != n; ++i) {
IOutputPane *outPane = m_panes.at(i);
const int idx = m_outputWidgetPane->addWidget(outPane->outputWidget(this));
QTC_CHECK(idx == i);
connect(outPane, &IOutputPane::showPage, this, [this, outPane](int flags) {
showPage(findIndexForPage(outPane), flags);
});
connect(outPane, &IOutputPane::hidePage, this, &OutputPaneManager::slotHide);
connect(outPane, &IOutputPane::togglePage, this, &OutputPaneManager::togglePage);
connect(outPane, &IOutputPane::navigateStateUpdate,
this, &OutputPaneManager::updateNavigateState);
connect(outPane, &IOutputPane::flashButton, this, &OutputPaneManager::flashButton);
connect(outPane, &IOutputPane::setBadgeNumber, this, &OutputPaneManager::setBadgeNumber);
QWidget *toolButtonsContainer = new QWidget(m_opToolBarWidgets);
QHBoxLayout *toolButtonsLayout = new QHBoxLayout;
toolButtonsLayout->setMargin(0);
toolButtonsLayout->setSpacing(0);
foreach (QWidget *toolButton, outPane->toolBarWidgets())
toolButtonsLayout->addWidget(toolButton);
toolButtonsLayout->addStretch(5);
toolButtonsContainer->setLayout(toolButtonsLayout);
m_opToolBarWidgets->addWidget(toolButtonsContainer);
minTitleWidth = qMax(minTitleWidth, titleFm.width(outPane->displayName()));
QString suffix = outPane->displayName().simplified();
suffix.remove(QLatin1Char(' '));
const Id id = baseId.withSuffix(suffix);
QAction *action = new QAction(outPane->displayName(), this);
Command *cmd = ActionManager::registerAction(action, id);
mpanes->addAction(cmd, "Coreplugin.OutputPane.PanesGroup");
m_actions.append(action);
m_ids.append(id);
cmd->setDefaultKeySequence(paneShortCut(shortcutNumber));
OutputPaneToggleButton *button = new OutputPaneToggleButton(shortcutNumber, outPane->displayName(),
cmd->action());
++shortcutNumber;
m_buttonsWidget->layout()->addWidget(button);
m_buttons.append(button);
connect(button, &QAbstractButton::clicked, this, [this, button]() {
buttonTriggered(m_buttons.indexOf(button));
});
bool visible = outPane->priorityInStatusBar() != -1;
//.........这里部分代码省略.........
示例7: init
void OutputPaneManager::init()
{
ActionContainer *mwindow = ActionManager::actionContainer(Constants::M_WINDOW);
const Context globalContext(Constants::C_GLOBAL);
// Window->Output Panes
ActionContainer *mpanes = ActionManager::createMenu(Constants::M_WINDOW_PANES);
mwindow->addMenu(mpanes, Constants::G_WINDOW_PANES);
mpanes->menu()->setTitle(tr("Output &Panes"));
mpanes->appendGroup("Coreplugin.OutputPane.ActionsGroup");
mpanes->appendGroup("Coreplugin.OutputPane.PanesGroup");
Command *cmd;
cmd = ActionManager::registerAction(m_clearAction, "Coreplugin.OutputPane.clear", globalContext);
m_clearButton->setDefaultAction(cmd->action());
mpanes->addAction(cmd, "Coreplugin.OutputPane.ActionsGroup");
cmd = ActionManager::registerAction(m_prevAction, "Coreplugin.OutputPane.previtem", globalContext);
cmd->setDefaultKeySequence(QKeySequence(tr("Shift+F6")));
m_prevToolButton->setDefaultAction(cmd->action());
mpanes->addAction(cmd, "Coreplugin.OutputPane.ActionsGroup");
cmd = ActionManager::registerAction(m_nextAction, "Coreplugin.OutputPane.nextitem", globalContext);
m_nextToolButton->setDefaultAction(cmd->action());
cmd->setDefaultKeySequence(QKeySequence(tr("F6")));
mpanes->addAction(cmd, "Coreplugin.OutputPane.ActionsGroup");
cmd = ActionManager::registerAction(m_minMaxAction, "Coreplugin.OutputPane.minmax", globalContext);
cmd->setDefaultKeySequence(QKeySequence(UseMacShortcuts ? tr("Ctrl+9") : tr("Alt+9")));
cmd->setAttribute(Command::CA_UpdateText);
cmd->setAttribute(Command::CA_UpdateIcon);
mpanes->addAction(cmd, "Coreplugin.OutputPane.ActionsGroup");
connect(m_minMaxAction, SIGNAL(triggered()), this, SLOT(slotMinMax()));
m_minMaxButton->setDefaultAction(cmd->action());
mpanes->addSeparator(globalContext, "Coreplugin.OutputPane.ActionsGroup");
QFontMetrics titleFm = m_titleLabel->fontMetrics();
int minTitleWidth = 0;
m_panes = ExtensionSystem::PluginManager::getObjects<IOutputPane>();
qSort(m_panes.begin(), m_panes.end(), &comparePanes);
const int n = m_panes.size();
int shortcutNumber = 1;
const Id baseId = "QtCreator.Pane.";
for (int i = 0; i != n; ++i) {
IOutputPane *outPane = m_panes.at(i);
const int idx = m_outputWidgetPane->addWidget(outPane->outputWidget(this));
QTC_CHECK(idx == i);
connect(outPane, SIGNAL(showPage(int)), this, SLOT(showPage(int)));
connect(outPane, SIGNAL(hidePage()), this, SLOT(slotHide()));
connect(outPane, SIGNAL(togglePage(int)), this, SLOT(togglePage(int)));
connect(outPane, SIGNAL(navigateStateUpdate()), this, SLOT(updateNavigateState()));
connect(outPane, SIGNAL(flashButton()), this, SLOT(flashButton()));
connect(outPane, SIGNAL(setBadgeNumber(int)), this, SLOT(setBadgeNumber(int)));
QWidget *toolButtonsContainer = new QWidget(m_opToolBarWidgets);
QHBoxLayout *toolButtonsLayout = new QHBoxLayout;
toolButtonsLayout->setMargin(0);
toolButtonsLayout->setSpacing(0);
foreach (QWidget *toolButton, outPane->toolBarWidgets())
toolButtonsLayout->addWidget(toolButton);
toolButtonsLayout->addStretch(5);
toolButtonsContainer->setLayout(toolButtonsLayout);
m_opToolBarWidgets->addWidget(toolButtonsContainer);
minTitleWidth = qMax(minTitleWidth, titleFm.width(outPane->displayName()));
QString suffix = outPane->displayName().simplified();
suffix.remove(QLatin1Char(' '));
const Id id = baseId.withSuffix(suffix);
QAction *action = new QAction(outPane->displayName(), this);
Command *cmd = ActionManager::registerAction(action, id, globalContext);
mpanes->addAction(cmd, "Coreplugin.OutputPane.PanesGroup");
m_actions.append(action);
m_ids.append(id);
cmd->setDefaultKeySequence(QKeySequence(paneShortCut(shortcutNumber)));
OutputPaneToggleButton *button = new OutputPaneToggleButton(shortcutNumber, outPane->displayName(),
cmd->action());
++shortcutNumber;
m_buttonsWidget->layout()->addWidget(button);
m_buttons.append(button);
connect(button, SIGNAL(clicked()), this, SLOT(buttonTriggered()));
bool visible = outPane->priorityInStatusBar() != -1;
button->setVisible(visible);
connect(action, SIGNAL(triggered()), this, SLOT(shortcutTriggered()));
}
m_titleLabel->setMinimumWidth(minTitleWidth + m_titleLabel->contentsMargins().left()
+ m_titleLabel->contentsMargins().right());
m_buttonsWidget->layout()->addWidget(m_manageButton);
connect(m_manageButton, SIGNAL(clicked()), this, SLOT(popupMenu()));
//.........这里部分代码省略.........
示例8: setupActions
void FormEditorW::setupActions()
{
//menus
ActionContainer *medit = ActionManager::actionContainer(Core::Constants::M_EDIT);
ActionContainer *mformtools = ActionManager::actionContainer(M_FORMEDITOR);
//overridden actions
bindShortcut(ActionManager::registerAction(m_fwm->actionUndo(), Core::Constants::UNDO, m_contexts), m_fwm->actionUndo());
bindShortcut(ActionManager::registerAction(m_fwm->actionRedo(), Core::Constants::REDO, m_contexts), m_fwm->actionRedo());
bindShortcut(ActionManager::registerAction(m_fwm->actionCut(), Core::Constants::CUT, m_contexts), m_fwm->actionCut());
bindShortcut(ActionManager::registerAction(m_fwm->actionCopy(), Core::Constants::COPY, m_contexts), m_fwm->actionCopy());
bindShortcut(ActionManager::registerAction(m_fwm->actionPaste(), Core::Constants::PASTE, m_contexts), m_fwm->actionPaste());
bindShortcut(ActionManager::registerAction(m_fwm->actionSelectAll(), Core::Constants::SELECTALL, m_contexts), m_fwm->actionSelectAll());
m_actionPrint = new QAction(this);
bindShortcut(ActionManager::registerAction(m_actionPrint, Core::Constants::PRINT, m_contexts), m_actionPrint);
connect(m_actionPrint, SIGNAL(triggered()), this, SLOT(print()));
//'delete' action. Do not set a shortcut as Designer handles
// the 'Delete' key by event filter. Setting a shortcut triggers
// buggy behaviour on Mac (Pressing Delete in QLineEdit removing the widget).
Command *command;
command = ActionManager::registerAction(m_fwm->actionDelete(), "FormEditor.Edit.Delete", m_contexts);
bindShortcut(command, m_fwm->actionDelete());
command->setAttribute(Command::CA_Hide);
medit->addAction(command, Core::Constants::G_EDIT_COPYPASTE);
m_actionGroupEditMode = new QActionGroup(this);
m_actionGroupEditMode->setExclusive(true);
connect(m_actionGroupEditMode, SIGNAL(triggered(QAction*)), this, SLOT(activateEditMode(QAction*)));
medit->addSeparator(m_contexts, Core::Constants::G_EDIT_OTHER);
m_toolActionIds.push_back("FormEditor.WidgetEditor");
createEditModeAction(m_actionGroupEditMode, m_contexts, medit,
tr("Edit Widgets"), m_toolActionIds.back(),
EditModeWidgetEditor, QLatin1String("widgettool.png"), tr("F3"));
m_toolActionIds.push_back("FormEditor.SignalsSlotsEditor");
createEditModeAction(m_actionGroupEditMode, m_contexts, medit,
tr("Edit Signals/Slots"), m_toolActionIds.back(),
EditModeSignalsSlotEditor, QLatin1String("signalslottool.png"), tr("F4"));
m_toolActionIds.push_back("FormEditor.BuddyEditor");
createEditModeAction(m_actionGroupEditMode, m_contexts, medit,
tr("Edit Buddies"), m_toolActionIds.back(),
EditModeBuddyEditor, QLatin1String("buddytool.png"));
m_toolActionIds.push_back("FormEditor.TabOrderEditor");
createEditModeAction(m_actionGroupEditMode, m_contexts, medit,
tr("Edit Tab Order"), m_toolActionIds.back(),
EditModeTabOrderEditor, QLatin1String("tabordertool.png"));
//tool actions
m_toolActionIds.push_back("FormEditor.LayoutHorizontally");
const QString horizLayoutShortcut = UseMacShortcuts ? tr("Meta+Shift+H") : tr("Ctrl+H");
addToolAction(m_fwm->actionHorizontalLayout(), m_contexts,
m_toolActionIds.back(), mformtools, horizLayoutShortcut);
m_toolActionIds.push_back("FormEditor.LayoutVertically");
const QString vertLayoutShortcut = UseMacShortcuts ? tr("Meta+L") : tr("Ctrl+L");
addToolAction(m_fwm->actionVerticalLayout(), m_contexts,
m_toolActionIds.back(), mformtools, vertLayoutShortcut);
m_toolActionIds.push_back("FormEditor.SplitHorizontal");
addToolAction(m_fwm->actionSplitHorizontal(), m_contexts,
m_toolActionIds.back(), mformtools);
m_toolActionIds.push_back("FormEditor.SplitVertical");
addToolAction(m_fwm->actionSplitVertical(), m_contexts,
m_toolActionIds.back(), mformtools);
m_toolActionIds.push_back("FormEditor.LayoutForm");
addToolAction(m_fwm->actionFormLayout(), m_contexts,
m_toolActionIds.back(), mformtools);
m_toolActionIds.push_back("FormEditor.LayoutGrid");
const QString gridShortcut = UseMacShortcuts ? tr("Meta+Shift+G") : tr("Ctrl+G");
addToolAction(m_fwm->actionGridLayout(), m_contexts,
m_toolActionIds.back(), mformtools, gridShortcut);
m_toolActionIds.push_back("FormEditor.LayoutBreak");
addToolAction(m_fwm->actionBreakLayout(), m_contexts,
m_toolActionIds.back(), mformtools);
m_toolActionIds.push_back("FormEditor.LayoutAdjustSize");
const QString adjustShortcut = UseMacShortcuts ? tr("Meta+J") : tr("Ctrl+J");
addToolAction(m_fwm->actionAdjustSize(), m_contexts,
m_toolActionIds.back(), mformtools, adjustShortcut);
m_toolActionIds.push_back("FormEditor.SimplifyLayout");
addToolAction(m_fwm->actionSimplifyLayout(), m_contexts,
m_toolActionIds.back(), mformtools);
mformtools->addSeparator(m_contexts);
addToolAction(m_fwm->actionLower(), m_contexts, "FormEditor.Lower", mformtools);
addToolAction(m_fwm->actionRaise(), m_contexts, "FormEditor.Raise", mformtools);
// Commands that do not go into the editor toolbar
//.........这里部分代码省略.........
示例9: initialize
bool GLSLEditorPlugin::initialize(const QStringList & /*arguments*/, QString *errorMessage)
{
if (!ICore::mimeDatabase()->addMimeTypes(QLatin1String(":/glsleditor/GLSLEditor.mimetypes.xml"), errorMessage))
return false;
// m_modelManager = new ModelManager(this);
// addAutoReleasedObject(m_modelManager);
addAutoReleasedObject(new GLSLHoverHandler(this));
m_editor = new GLSLEditorFactory(this);
addObject(m_editor);
addAutoReleasedObject(new GLSLCompletionAssistProvider);
m_actionHandler = new TextEditorActionHandler(Constants::C_GLSLEDITOR_ID,
TextEditorActionHandler::Format
| TextEditorActionHandler::UnCommentSelection
| TextEditorActionHandler::UnCollapseAll);
m_actionHandler->initializeActions();
ActionContainer *contextMenu = ActionManager::createMenu(GLSLEditor::Constants::M_CONTEXT);
ActionContainer *glslToolsMenu = ActionManager::createMenu(Id(Constants::M_TOOLS_GLSL));
glslToolsMenu->setOnAllDisabledBehavior(ActionContainer::Hide);
QMenu *menu = glslToolsMenu->menu();
//: GLSL sub-menu in the Tools menu
menu->setTitle(tr("GLSL"));
ActionManager::actionContainer(Core::Constants::M_TOOLS)->addMenu(glslToolsMenu);
Command *cmd = 0;
// Insert marker for "Refactoring" menu:
Context globalContext(Core::Constants::C_GLOBAL);
Command *sep = contextMenu->addSeparator(globalContext);
sep->action()->setObjectName(QLatin1String(Constants::M_REFACTORING_MENU_INSERTION_POINT));
contextMenu->addSeparator(globalContext);
cmd = ActionManager::command(TextEditor::Constants::UN_COMMENT_SELECTION);
contextMenu->addAction(cmd);
errorMessage->clear();
FileIconProvider *iconProvider = FileIconProvider::instance();
MimeDatabase *mimeDatabase = ICore::mimeDatabase();
iconProvider->registerIconOverlayForMimeType(QIcon(QLatin1String(":/glsleditor/images/glslfile.png")),
mimeDatabase->findByType(QLatin1String(GLSLEditor::Constants::GLSL_MIMETYPE)));
iconProvider->registerIconOverlayForMimeType(QIcon(QLatin1String(":/glsleditor/images/glslfile.png")),
mimeDatabase->findByType(QLatin1String(GLSLEditor::Constants::GLSL_MIMETYPE_VERT)));
iconProvider->registerIconOverlayForMimeType(QIcon(QLatin1String(":/glsleditor/images/glslfile.png")),
mimeDatabase->findByType(QLatin1String(GLSLEditor::Constants::GLSL_MIMETYPE_FRAG)));
iconProvider->registerIconOverlayForMimeType(QIcon(QLatin1String(":/glsleditor/images/glslfile.png")),
mimeDatabase->findByType(QLatin1String(GLSLEditor::Constants::GLSL_MIMETYPE_VERT_ES)));
iconProvider->registerIconOverlayForMimeType(QIcon(QLatin1String(":/glsleditor/images/glslfile.png")),
mimeDatabase->findByType(QLatin1String(GLSLEditor::Constants::GLSL_MIMETYPE_FRAG_ES)));
QObject *core = ICore::instance();
BaseFileWizardParameters fragWizardParameters(IWizard::FileWizard);
fragWizardParameters.setCategory(QLatin1String(Constants::WIZARD_CATEGORY_GLSL));
fragWizardParameters.setDisplayCategory(QCoreApplication::translate("GLSLEditor", Constants::WIZARD_TR_CATEGORY_GLSL));
fragWizardParameters.setDescription
(tr("Creates a fragment shader in the OpenGL/ES 2.0 Shading "
"Language (GLSL/ES). Fragment shaders generate the final "
"pixel colors for triangles, points and lines rendered "
"with OpenGL."));
fragWizardParameters.setDisplayName(tr("Fragment Shader (OpenGL/ES 2.0)"));
fragWizardParameters.setId(QLatin1String("F.GLSL"));
addAutoReleasedObject(new GLSLFileWizard(fragWizardParameters, GLSLFileWizard::FragmentShaderES, core));
BaseFileWizardParameters vertWizardParameters(IWizard::FileWizard);
vertWizardParameters.setCategory(QLatin1String(Constants::WIZARD_CATEGORY_GLSL));
vertWizardParameters.setDisplayCategory(QCoreApplication::translate("GLSLEditor", Constants::WIZARD_TR_CATEGORY_GLSL));
vertWizardParameters.setDescription
(tr("Creates a vertex shader in the OpenGL/ES 2.0 Shading "
"Language (GLSL/ES). Vertex shaders transform the "
"positions, normals and texture co-ordinates of "
"triangles, points and lines rendered with OpenGL."));
vertWizardParameters.setDisplayName(tr("Vertex Shader (OpenGL/ES 2.0)"));
vertWizardParameters.setId(QLatin1String("G.GLSL"));
addAutoReleasedObject(new GLSLFileWizard(vertWizardParameters, GLSLFileWizard::VertexShaderES, core));
fragWizardParameters.setDescription
(tr("Creates a fragment shader in the Desktop OpenGL Shading "
"Language (GLSL). Fragment shaders generate the final "
"pixel colors for triangles, points and lines rendered "
"with OpenGL."));
fragWizardParameters.setDisplayName(tr("Fragment Shader (Desktop OpenGL)"));
fragWizardParameters.setId(QLatin1String("J.GLSL"));
addAutoReleasedObject(new GLSLFileWizard(fragWizardParameters, GLSLFileWizard::FragmentShaderDesktop, core));
vertWizardParameters.setDescription
(tr("Creates a vertex shader in the Desktop OpenGL Shading "
"Language (GLSL). Vertex shaders transform the "
"positions, normals and texture co-ordinates of "
"triangles, points and lines rendered with OpenGL."));
vertWizardParameters.setDisplayName(tr("Vertex Shader (Desktop OpenGL)"));
vertWizardParameters.setId(QLatin1String("K.GLSL"));
addAutoReleasedObject(new GLSLFileWizard(vertWizardParameters, GLSLFileWizard::VertexShaderDesktop, core));
return true;
}
示例10: initialize
bool SubversionPlugin::initialize(const QStringList & /*arguments */, QString *errorMessage)
{
using namespace Constants;
using namespace Core::Constants;
Context context(SUBVERSION_CONTEXT);
initializeVcs(new SubversionControl(this), context);
m_subversionPluginInstance = this;
if (!MimeDatabase::addMimeTypes(QLatin1String(":/trolltech.subversion/Subversion.mimetypes.xml"), errorMessage))
return false;
m_settings.readSettings(ICore::settings());
m_client = new SubversionClient(&m_settings);
addAutoReleasedObject(new SettingsPage);
addAutoReleasedObject(new VcsSubmitEditorFactory(&submitParameters,
[]() { return new SubversionSubmitEditor(&submitParameters); }));
static const char *describeSlot = SLOT(describe(QString,QString));
const int editorCount = sizeof(editorParameters) / sizeof(editorParameters[0]);
const auto widgetCreator = []() { return new SubversionEditorWidget; };
for (int i = 0; i < editorCount; i++)
addAutoReleasedObject(new VcsEditorFactory(editorParameters + i, widgetCreator, this, describeSlot));
auto checkoutWizardFactory = new BaseCheckoutWizardFactory;
checkoutWizardFactory->setId(QLatin1String(VcsBase::Constants::VCS_ID_SUBVERSION));
checkoutWizardFactory->setIcon(QIcon(QLatin1String(":/subversion/images/subversion.png")));
checkoutWizardFactory->setDescription(tr("Checks out a Subversion repository and tries to load the contained project."));
checkoutWizardFactory->setDisplayName(tr("Subversion Checkout"));
checkoutWizardFactory->setWizardCreator([this] (const FileName &path, QWidget *parent) {
return new CheckoutWizard(path, parent);
});
addAutoReleasedObject(checkoutWizardFactory);
const QString prefix = QLatin1String("svn");
m_commandLocator = new CommandLocator("Subversion", prefix, prefix);
addAutoReleasedObject(m_commandLocator);
// Register actions
ActionContainer *toolsContainer = ActionManager::actionContainer(M_TOOLS);
ActionContainer *subversionMenu = ActionManager::createMenu(Id(CMD_ID_SUBVERSION_MENU));
subversionMenu->menu()->setTitle(tr("&Subversion"));
toolsContainer->addMenu(subversionMenu);
m_menuAction = subversionMenu->menu()->menuAction();
Command *command;
m_diffCurrentAction = new ParameterAction(tr("Diff Current File"), tr("Diff \"%1\""), ParameterAction::EnabledWithParameter, this);
command = ActionManager::registerAction(m_diffCurrentAction,
CMD_ID_DIFF_CURRENT, context);
command->setAttribute(Command::CA_UpdateText);
command->setDefaultKeySequence(QKeySequence(UseMacShortcuts ? tr("Meta+S,Meta+D") : tr("Alt+S,Alt+D")));
connect(m_diffCurrentAction, SIGNAL(triggered()), this, SLOT(diffCurrentFile()));
subversionMenu->addAction(command);
m_commandLocator->appendCommand(command);
m_filelogCurrentAction = new ParameterAction(tr("Filelog Current File"), tr("Filelog \"%1\""), ParameterAction::EnabledWithParameter, this);
command = ActionManager::registerAction(m_filelogCurrentAction,
CMD_ID_FILELOG_CURRENT, context);
command->setAttribute(Command::CA_UpdateText);
connect(m_filelogCurrentAction, SIGNAL(triggered()), this,
SLOT(filelogCurrentFile()));
subversionMenu->addAction(command);
m_commandLocator->appendCommand(command);
m_annotateCurrentAction = new ParameterAction(tr("Annotate Current File"), tr("Annotate \"%1\""), ParameterAction::EnabledWithParameter, this);
command = ActionManager::registerAction(m_annotateCurrentAction,
CMD_ID_ANNOTATE_CURRENT, context);
command->setAttribute(Command::CA_UpdateText);
connect(m_annotateCurrentAction, SIGNAL(triggered()), this,
SLOT(annotateCurrentFile()));
subversionMenu->addAction(command);
m_commandLocator->appendCommand(command);
subversionMenu->addSeparator(context);
m_addAction = new ParameterAction(tr("Add"), tr("Add \"%1\""), ParameterAction::EnabledWithParameter, this);
command = ActionManager::registerAction(m_addAction, CMD_ID_ADD,
context);
command->setAttribute(Command::CA_UpdateText);
command->setDefaultKeySequence(QKeySequence(UseMacShortcuts ? tr("Meta+S,Meta+A") : tr("Alt+S,Alt+A")));
connect(m_addAction, SIGNAL(triggered()), this, SLOT(addCurrentFile()));
subversionMenu->addAction(command);
m_commandLocator->appendCommand(command);
m_commitCurrentAction = new ParameterAction(tr("Commit Current File"), tr("Commit \"%1\""), ParameterAction::EnabledWithParameter, this);
command = ActionManager::registerAction(m_commitCurrentAction,
CMD_ID_COMMIT_CURRENT, context);
command->setAttribute(Command::CA_UpdateText);
command->setDefaultKeySequence(QKeySequence(UseMacShortcuts ? tr("Meta+S,Meta+C") : tr("Alt+S,Alt+C")));
connect(m_commitCurrentAction, SIGNAL(triggered()), this, SLOT(startCommitCurrentFile()));
subversionMenu->addAction(command);
m_commandLocator->appendCommand(command);
m_deleteAction = new ParameterAction(tr("Delete..."), tr("Delete \"%1\"..."), ParameterAction::EnabledWithParameter, this);
command = ActionManager::registerAction(m_deleteAction, CMD_ID_DELETE_FILE,
//.........这里部分代码省略.........
示例11: editorManagerContext
BookmarksPluginRunData::BookmarksPluginRunData()
: m_bookmarkFilter(&m_bookmarkManager)
, m_bookmarkViewFactory(&m_bookmarkManager)
{
ActionContainer *mtools = ActionManager::actionContainer(Core::Constants::M_TOOLS);
ActionContainer *touchBar = ActionManager::actionContainer(Core::Constants::TOUCH_BAR);
ActionContainer *mbm = ActionManager::createMenu(Id(BOOKMARKS_MENU));
mbm->menu()->setTitle(BookmarksPlugin::tr("&Bookmarks"));
mtools->addMenu(mbm);
const Context editorManagerContext(Core::Constants::C_EDITORMANAGER);
// Toggle
Command *cmd = ActionManager::registerAction(&m_toggleAction, BOOKMARKS_TOGGLE_ACTION,
editorManagerContext);
cmd->setDefaultKeySequence(QKeySequence(useMacShortcuts ? BookmarksPlugin::tr("Meta+M")
: BookmarksPlugin::tr("Ctrl+M")));
cmd->setTouchBarIcon(Utils::Icons::MACOS_TOUCHBAR_BOOKMARK.icon());
mbm->addAction(cmd);
touchBar->addAction(cmd, Core::Constants::G_TOUCHBAR_EDITOR);
mbm->addSeparator();
// Previous
m_prevAction.setIcon(Utils::Icons::PREV_TOOLBAR.icon());
m_prevAction.setIconVisibleInMenu(false);
cmd = ActionManager::registerAction(&m_prevAction, BOOKMARKS_PREV_ACTION, editorManagerContext);
cmd->setDefaultKeySequence(QKeySequence(useMacShortcuts ? BookmarksPlugin::tr("Meta+,")
: BookmarksPlugin::tr("Ctrl+,")));
mbm->addAction(cmd);
// Next
m_nextAction.setIcon(Utils::Icons::NEXT_TOOLBAR.icon());
m_nextAction.setIconVisibleInMenu(false);
cmd = ActionManager::registerAction(&m_nextAction, BOOKMARKS_NEXT_ACTION, editorManagerContext);
cmd->setDefaultKeySequence(QKeySequence(useMacShortcuts ? BookmarksPlugin::tr("Meta+.")
: BookmarksPlugin::tr("Ctrl+.")));
mbm->addAction(cmd);
mbm->addSeparator();
// Previous Doc
cmd = ActionManager::registerAction(&m_docPrevAction, BOOKMARKS_PREVDOC_ACTION,
editorManagerContext);
mbm->addAction(cmd);
// Next Doc
cmd = ActionManager::registerAction(&m_docNextAction, BOOKMARKS_NEXTDOC_ACTION,
editorManagerContext);
mbm->addAction(cmd);
connect(&m_toggleAction, &QAction::triggered, this, [this] {
BaseTextEditor *editor = BaseTextEditor::currentTextEditor();
if (editor && !editor->document()->isTemporary())
m_bookmarkManager.toggleBookmark(editor->document()->filePath(), editor->currentLine());
});
connect(&m_prevAction, &QAction::triggered, &m_bookmarkManager, &BookmarkManager::prev);
connect(&m_nextAction, &QAction::triggered, &m_bookmarkManager, &BookmarkManager::next);
connect(&m_docPrevAction, &QAction::triggered,
&m_bookmarkManager, &BookmarkManager::prevInDocument);
connect(&m_docNextAction, &QAction::triggered,
&m_bookmarkManager, &BookmarkManager::nextInDocument);
connect(&m_editBookmarkAction, &QAction::triggered, this, [this] {
m_bookmarkManager.editByFileAndLine(m_marginActionFileName, m_marginActionLineNumber);
});
connect(&m_bookmarkManager, &BookmarkManager::updateActions,
this, &BookmarksPluginRunData::updateActions);
updateActions(false, m_bookmarkManager.state());
connect(&m_bookmarkMarginAction, &QAction::triggered, this, [this] {
m_bookmarkManager.toggleBookmark(m_marginActionFileName, m_marginActionLineNumber);
});
// EditorManager
connect(EditorManager::instance(), &EditorManager::editorAboutToClose,
this, &BookmarksPluginRunData::editorAboutToClose);
connect(EditorManager::instance(), &EditorManager::editorOpened,
this, &BookmarksPluginRunData::editorOpened);
}
示例12: QWidget
//.........这里部分代码省略.........
ActionContainer *mpanes = ActionManager::createMenu(Constants::M_WINDOW_PANES);
mwindow->addMenu(mpanes, Constants::G_WINDOW_PANES);
mpanes->menu()->setTitle(tr("Output &Panes"));
mpanes->appendGroup("Coreplugin.OutputPane.ActionsGroup");
mpanes->appendGroup("Coreplugin.OutputPane.PanesGroup");
Command *cmd;
cmd = ActionManager::registerAction(m_clearAction, "Coreplugin.OutputPane.clear");
m_clearButton->setDefaultAction(cmd->action());
m_clearButton->setIcon(Utils::Icons::CLEAN_TOOLBAR.icon());
mpanes->addAction(cmd, "Coreplugin.OutputPane.ActionsGroup");
cmd = ActionManager::registerAction(m_prevAction, "Coreplugin.OutputPane.previtem");
cmd->setDefaultKeySequence(QKeySequence(tr("Shift+F6")));
m_prevToolButton->setDefaultAction(
ProxyAction::proxyActionWithIcon(cmd->action(), Utils::Icons::PREV_TOOLBAR.icon()));
mpanes->addAction(cmd, "Coreplugin.OutputPane.ActionsGroup");
cmd = ActionManager::registerAction(m_nextAction, "Coreplugin.OutputPane.nextitem");
m_nextToolButton->setDefaultAction(
ProxyAction::proxyActionWithIcon(cmd->action(), Utils::Icons::NEXT_TOOLBAR.icon()));
cmd->setDefaultKeySequence(QKeySequence(tr("F6")));
mpanes->addAction(cmd, "Coreplugin.OutputPane.ActionsGroup");
cmd = ActionManager::registerAction(m_minMaxAction, "Coreplugin.OutputPane.minmax");
cmd->setDefaultKeySequence(QKeySequence(useMacShortcuts ? tr("Ctrl+Shift+9") : tr("Alt+Shift+9")));
cmd->setAttribute(Command::CA_UpdateText);
cmd->setAttribute(Command::CA_UpdateIcon);
mpanes->addAction(cmd, "Coreplugin.OutputPane.ActionsGroup");
connect(m_minMaxAction, &QAction::triggered, this, &OutputPaneManager::toggleMaximized);
m_minMaxButton->setDefaultAction(cmd->action());
mpanes->addSeparator("Coreplugin.OutputPane.ActionsGroup");
QFontMetrics titleFm = m_titleLabel->fontMetrics();
int minTitleWidth = 0;
Utils::sort(g_outputPanes, [](const OutputPaneData &d1, const OutputPaneData &d2) {
return d1.pane->priorityInStatusBar() > d2.pane->priorityInStatusBar();
});
const int n = g_outputPanes.size();
int shortcutNumber = 1;
const Id baseId = "QtCreator.Pane.";
for (int i = 0; i != n; ++i) {
OutputPaneData &data = g_outputPanes[i];
IOutputPane *outPane = data.pane;
const int idx = m_outputWidgetPane->addWidget(outPane->outputWidget(this));
QTC_CHECK(idx == i);
connect(outPane, &IOutputPane::showPage, this, [this, idx](int flags) {
showPage(idx, flags);
});
connect(outPane, &IOutputPane::hidePage, this, &OutputPaneManager::slotHide);
connect(outPane, &IOutputPane::togglePage, this, [this, idx](int flags) {
if (OutputPanePlaceHolder::isCurrentVisible() && currentIndex() == idx)
slotHide();
else
showPage(idx, flags);
});
connect(outPane, &IOutputPane::navigateStateUpdate, this, [this, idx, outPane] {
if (currentIndex() == idx) {
m_prevAction->setEnabled(outPane->canNavigate() && outPane->canPrevious());