本文整理汇总了C++中core::ActionManager::command方法的典型用法代码示例。如果您正苦于以下问题:C++ ActionManager::command方法的具体用法?C++ ActionManager::command怎么用?C++ ActionManager::command使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类core::ActionManager
的用法示例。
在下文中一共展示了ActionManager::command方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: createMenuItems
void DoNothingPlugin::createMenuItems()
{
// Fetch the action manager
Core::ActionManager* am = Core::ICore::instance()->actionManager();
// Create a command for "About DoNothing"
Core::Command* cmd = am->registerAction(new QAction(this), "DoNothingPlugin.AboutDoNothingItem", QList<int>() << Core::Constants::C_GLOBAL_ID);
cmd->action()->setText("About DoNothing");
// Add the command "Do Nothing" in the beginning of Help menu
am->actionContainer(Core::Constants::M_HELP)->addAction(cmd);
// Since menu-items are QActions, we can connect to their triggered(bool) or
// toggled(bool) signal and respond to trigger/toggled events
connect(cmd->action(), SIGNAL(triggered(bool)), this, SLOT(about()));
// Create a command for "About DoNothing 2"
Core::Command* cmd2 = am->registerAction(new QAction(this), "DoNothingPlugin.AboutDoNothing2Item", QList<int>() << Core::Constants::C_GLOBAL_ID);
cmd2->action()->setText("About DoNothing 2");
// Insert the "DoNothing 2" item before "About Plugins..."
QMenu* helpMenu = am->actionContainer(Core::Constants::M_HELP)->menu();
QAction* aboutPluginsAction = am->command(Core::Constants::ABOUT_PLUGINS)->action();
helpMenu->insertAction(aboutPluginsAction, cmd2->action());
// Connect the action
connect(cmd2->action(), SIGNAL(triggered(bool)), this, SLOT(about()));
}
示例2: endRecordingMacro
void TextEditorMacroHandler::endRecordingMacro(Macros::Macro *macro)
{
if (m_currentEditor && m_currentEditor->widget())
m_currentEditor->widget()->removeEventFilter(this);
IMacroHandler::endRecordingMacro(macro);
// Unblock completion
Core::ActionManager *am = Core::ICore::instance()->actionManager();
am->command(TextEditor::Constants::COMPLETE_THIS)->shortcut()->blockSignals(false);
}
示例3: startRecording
void TextEditorMacroHandler::startRecording(Macros::Macro *macro)
{
IMacroHandler::startRecording(macro);
if (isRecording() && m_currentEditor && m_currentEditor->widget())
m_currentEditor->widget()->installEventFilter(this);
// Block completion
Core::ActionManager *am = Core::ICore::instance()->actionManager();
am->command(TextEditor::Constants::COMPLETE_THIS)->shortcut()->blockSignals(true);
}
示例4:
QToolBar *FormEditorW::createEditorToolBar() const
{
QToolBar *editorToolBar = new QToolBar;
Core::ActionManager *am = Core::ICore::actionManager();
const QList<Core::Id>::const_iterator cend = m_toolActionIds.constEnd();
for (QList<Core::Id>::const_iterator it = m_toolActionIds.constBegin(); it != cend; ++it) {
Core::Command *cmd = am->command(*it);
QTC_ASSERT(cmd, continue);
QAction *action = cmd->action();
if (!action->icon().isNull()) // Simplify grid has no action yet
editorToolBar->addAction(action);
}
const int size = editorToolBar->style()->pixelMetric(QStyle::PM_SmallIconSize);
editorToolBar->setIconSize(QSize(size, size));
editorToolBar->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);
return editorToolBar;
}
示例5: showMarker
void FunctionDeclDefLink::showMarker(CPPEditorWidget *editor)
{
if (hasMarker)
return;
QList<TextEditor::RefactorMarker> markers = removeMarkersOfType<Marker>(editor->refactorMarkers());
TextEditor::RefactorMarker marker;
// show the marker at the end of the linked area, with a special case
// to avoid it overlapping with a trailing semicolon
marker.cursor = editor->textCursor();
marker.cursor.setPosition(linkSelection.selectionEnd());
const int endBlockNr = marker.cursor.blockNumber();
marker.cursor.setPosition(linkSelection.selectionEnd() + 1, QTextCursor::KeepAnchor);
if (marker.cursor.blockNumber() != endBlockNr
|| marker.cursor.selectedText() != QLatin1String(";")) {
marker.cursor.setPosition(linkSelection.selectionEnd());
}
QString message;
if (targetDeclaration->asFunctionDefinition())
message = tr("Apply changes to definition");
else
message = tr("Apply changes to declaration");
Core::ActionManager *actionManager = Core::ICore::actionManager();
Core::Command *quickfixCommand = actionManager->command(TextEditor::Constants::QUICKFIX_THIS);
if (quickfixCommand)
message = Utils::ProxyAction::stringWithAppendedShortcut(message, quickfixCommand->keySequence());
marker.tooltip = message;
marker.data = QVariant::fromValue(Marker());
markers += marker;
editor->setRefactorMarkers(markers);
hasMarker = true;
}
示例6: initialize
bool GLSLEditorPlugin::initialize(const QStringList & /*arguments*/, QString *error_message)
{
Core::ICore *core = Core::ICore::instance();
if (!core->mimeDatabase()->addMimeTypes(QLatin1String(":/glsleditor/GLSLEditor.mimetypes.xml"), error_message))
return false;
parseGlslFile(QLatin1String("glsl_120.frag"), &m_glsl_120_frag);
parseGlslFile(QLatin1String("glsl_120.vert"), &m_glsl_120_vert);
parseGlslFile(QLatin1String("glsl_120_common.glsl"), &m_glsl_120_common);
parseGlslFile(QLatin1String("glsl_es_100.frag"), &m_glsl_es_100_frag);
parseGlslFile(QLatin1String("glsl_es_100.vert"), &m_glsl_es_100_vert);
parseGlslFile(QLatin1String("glsl_es_100_common.glsl"), &m_glsl_es_100_common);
// m_modelManager = new ModelManager(this);
// addAutoReleasedObject(m_modelManager);
addAutoReleasedObject(new GLSLHoverHandler(this));
Core::Context context(GLSLEditor::Constants::C_GLSLEDITOR_ID);
m_editor = new GLSLEditorFactory(this);
addObject(m_editor);
addAutoReleasedObject(new GLSLCompletionAssistProvider);
m_actionHandler = new TextEditor::TextEditorActionHandler(GLSLEditor::Constants::C_GLSLEDITOR_ID,
TextEditor::TextEditorActionHandler::Format
| TextEditor::TextEditorActionHandler::UnCommentSelection
| TextEditor::TextEditorActionHandler::UnCollapseAll);
m_actionHandler->initializeActions();
Core::ActionManager *am = core->actionManager();
Core::ActionContainer *contextMenu = am->createMenu(GLSLEditor::Constants::M_CONTEXT);
Core::ActionContainer *glslToolsMenu = am->createMenu(Core::Id(Constants::M_TOOLS_GLSL));
glslToolsMenu->setOnAllDisabledBehavior(Core::ActionContainer::Hide);
QMenu *menu = glslToolsMenu->menu();
//: GLSL sub-menu in the Tools menu
menu->setTitle(tr("GLSL"));
am->actionContainer(Core::Constants::M_TOOLS)->addMenu(glslToolsMenu);
Core::Command *cmd = 0;
// Insert marker for "Refactoring" menu:
Core::Context globalContext(Core::Constants::C_GLOBAL);
Core::Command *sep = createSeparator(am, this, globalContext,
Constants::SEPARATOR1);
sep->action()->setObjectName(Constants::M_REFACTORING_MENU_INSERTION_POINT);
contextMenu->addAction(sep);
contextMenu->addAction(createSeparator(am, this, globalContext,
Constants::SEPARATOR2));
cmd = am->command(TextEditor::Constants::UN_COMMENT_SELECTION);
contextMenu->addAction(cmd);
error_message->clear();
Core::FileIconProvider *iconProvider = Core::FileIconProvider::instance();
Core::MimeDatabase *mimeDatabase = Core::ICore::instance()->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)));
Core::BaseFileWizardParameters fragWizardParameters(Core::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));
Core::BaseFileWizardParameters vertWizardParameters(Core::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)"));
//.........这里部分代码省略.........
示例7: initialize
bool QmlJSEditorPlugin::initialize(const QStringList & /*arguments*/, QString *error_message)
{
Core::ICore *core = Core::ICore::instance();
if (!core->mimeDatabase()->addMimeTypes(QLatin1String(":/qmljseditor/QmlJSEditor.mimetypes.xml"), error_message))
return false;
m_modelManager = QmlJS::ModelManagerInterface::instance();
addAutoReleasedObject(new QmlJSSnippetProvider);
Core::Context context(QmlJSEditor::Constants::C_QMLJSEDITOR_ID);
m_editor = new QmlJSEditorFactory(this);
addObject(m_editor);
Core::BaseFileWizardParameters qmlWizardParameters(Core::IWizard::FileWizard);
qmlWizardParameters.setCategory(QLatin1String(Constants::WIZARD_CATEGORY_QML));
qmlWizardParameters.setDisplayCategory(QCoreApplication::translate("QmlJsEditor", Constants::WIZARD_TR_CATEGORY_QML));
qmlWizardParameters.setDescription(tr("Creates a QML file."));
qmlWizardParameters.setDisplayName(tr("QML File"));
qmlWizardParameters.setId(QLatin1String("Q.Qml"));
addAutoReleasedObject(new QmlFileWizard(qmlWizardParameters, core));
Core::BaseFileWizardParameters jsWizardParameters(Core::IWizard::FileWizard);
jsWizardParameters.setCategory(QLatin1String(Constants::WIZARD_CATEGORY_QML));
jsWizardParameters.setDisplayCategory(QCoreApplication::translate("QmlJsEditor", Constants::WIZARD_TR_CATEGORY_QML));
jsWizardParameters.setDescription(tr("Creates a JavaScript file."));
jsWizardParameters.setDisplayName(tr("JS File"));
jsWizardParameters.setId(QLatin1String("Z.Js"));
addAutoReleasedObject(new JsFileWizard(jsWizardParameters, core));
m_actionHandler = new TextEditor::TextEditorActionHandler(QmlJSEditor::Constants::C_QMLJSEDITOR_ID,
TextEditor::TextEditorActionHandler::Format
| TextEditor::TextEditorActionHandler::UnCommentSelection
| TextEditor::TextEditorActionHandler::UnCollapseAll);
m_actionHandler->initializeActions();
Core::ActionManager *am = core->actionManager();
Core::ActionContainer *contextMenu = am->createMenu(QmlJSEditor::Constants::M_CONTEXT);
Core::ActionContainer *qmlToolsMenu = am->createMenu(Core::Id(Constants::M_TOOLS_QML));
qmlToolsMenu->setOnAllDisabledBehavior(Core::ActionContainer::Hide);
QMenu *menu = qmlToolsMenu->menu();
//: QML sub-menu in the Tools menu
menu->setTitle(tr("QML"));
am->actionContainer(Core::Constants::M_TOOLS)->addMenu(qmlToolsMenu);
Core::Command *cmd;
QAction *followSymbolUnderCursorAction = new QAction(tr("Follow Symbol Under Cursor"), this);
cmd = am->registerAction(followSymbolUnderCursorAction, Constants::FOLLOW_SYMBOL_UNDER_CURSOR, context);
cmd->setDefaultKeySequence(QKeySequence(Qt::Key_F2));
connect(followSymbolUnderCursorAction, SIGNAL(triggered()), this, SLOT(followSymbolUnderCursor()));
contextMenu->addAction(cmd);
qmlToolsMenu->addAction(cmd);
QAction *findUsagesAction = new QAction(tr("Find Usages"), this);
cmd = am->registerAction(findUsagesAction, Constants::FIND_USAGES, context);
cmd->setDefaultKeySequence(QKeySequence(tr("Ctrl+Shift+U")));
connect(findUsagesAction, SIGNAL(triggered()), this, SLOT(findUsages()));
contextMenu->addAction(cmd);
qmlToolsMenu->addAction(cmd);
QAction *showQuickToolbar = new QAction(tr("Show Qt Quick Toolbar"), this);
cmd = am->registerAction(showQuickToolbar, Constants::SHOW_QT_QUICK_HELPER, context);
#ifdef Q_WS_MACX
cmd->setDefaultKeySequence(QKeySequence(Qt::META + Qt::ALT + Qt::Key_Space));
#else
cmd->setDefaultKeySequence(QKeySequence(Qt::CTRL + Qt::ALT + Qt::Key_Space));
#endif
connect(showQuickToolbar, SIGNAL(triggered()), this, SLOT(showContextPane()));
contextMenu->addAction(cmd);
qmlToolsMenu->addAction(cmd);
// Insert marker for "Refactoring" menu:
Core::Context globalContext(Core::Constants::C_GLOBAL);
Core::Command *sep = createSeparator(am, this, globalContext,
Constants::SEPARATOR1);
sep->action()->setObjectName(Constants::M_REFACTORING_MENU_INSERTION_POINT);
contextMenu->addAction(sep);
contextMenu->addAction(createSeparator(am, this, globalContext,
Constants::SEPARATOR2));
cmd = am->command(TextEditor::Constants::AUTO_INDENT_SELECTION);
contextMenu->addAction(cmd);
cmd = am->command(TextEditor::Constants::UN_COMMENT_SELECTION);
contextMenu->addAction(cmd);
CodeCompletion *completion = new CodeCompletion(m_modelManager);
addAutoReleasedObject(completion);
addAutoReleasedObject(new HoverHandler);
// Set completion settings and keep them up to date
TextEditor::TextEditorSettings *textEditorSettings = TextEditor::TextEditorSettings::instance();
completion->setCompletionSettings(textEditorSettings->completionSettings());
connect(textEditorSettings, SIGNAL(completionSettingsChanged(TextEditor::CompletionSettings)),
completion, SLOT(setCompletionSettings(TextEditor::CompletionSettings)));
error_message->clear();
Core::FileIconProvider *iconProvider = Core::FileIconProvider::instance();
//.........这里部分代码省略.........
示例8: globalcontext
FindToolBar::FindToolBar(FindPlugin *plugin, CurrentDocumentFind *currentDocumentFind)
: m_plugin(plugin),
m_currentDocumentFind(currentDocumentFind),
m_findCompleter(new QCompleter(this)),
m_replaceCompleter(new QCompleter(this)),
m_enterFindStringAction(0),
m_findNextAction(0),
m_findPreviousAction(0),
m_replaceAction(0),
m_replaceNextAction(0),
m_replacePreviousAction(0),
m_findIncrementalTimer(this), m_findStepTimer(this),
m_useFakeVim(false),
m_eventFiltersInstalled(false)
{
//setup ui
m_ui.setupUi(this);
// compensate for a vertically expanding spacer below the label
m_ui.replaceLabel->setMinimumHeight(m_ui.replaceEdit->sizeHint().height());
delete m_ui.replaceButtonsWidget->layout();
Utils::FlowLayout *flowlayout = new Utils::FlowLayout(m_ui.replaceButtonsWidget, 0, 3, 3);
flowlayout->addWidget(m_ui.replaceButton);
flowlayout->addWidget(m_ui.replaceNextButton);
flowlayout->addWidget(m_ui.replaceAllButton);
m_ui.replaceButtonsWidget->setLayout(flowlayout);
setFocusProxy(m_ui.findEdit);
setProperty("topBorder", true);
setSingleRow(false);
m_ui.findEdit->setAttribute(Qt::WA_MacShowFocusRect, false);
m_ui.replaceEdit->setAttribute(Qt::WA_MacShowFocusRect, false);
connect(m_ui.findEdit, SIGNAL(editingFinished()), this, SLOT(invokeResetIncrementalSearch()));
m_ui.close->setIcon(QIcon(QLatin1String(Core::Constants::ICON_CLOSE_DOCUMENT)));
connect(m_ui.close, SIGNAL(clicked()), this, SLOT(hideAndResetFocus()));
m_findCompleter->setModel(m_plugin->findCompletionModel());
m_replaceCompleter->setModel(m_plugin->replaceCompletionModel());
m_ui.findEdit->setCompleter(m_findCompleter);
m_ui.replaceEdit->setCompleter(m_replaceCompleter);
QMenu *lineEditMenu = new QMenu(m_ui.findEdit);
m_ui.findEdit->setButtonMenu(Utils::FancyLineEdit::Left, lineEditMenu);
m_ui.findEdit->setButtonVisible(Utils::FancyLineEdit::Left, true);
m_ui.findEdit->setPlaceholderText(QString());
m_ui.replaceEdit->setPlaceholderText(QString());
connect(m_ui.findEdit, SIGNAL(textChanged(QString)), this, SLOT(invokeFindIncremental()));
connect(m_ui.findEdit, SIGNAL(returnPressed()), this, SLOT(invokeFindEnter()));
connect(m_ui.replaceEdit, SIGNAL(returnPressed()), this, SLOT(invokeReplaceEnter()));
QAction *shiftEnterAction = new QAction(m_ui.findEdit);
shiftEnterAction->setShortcut(QKeySequence(tr("Shift+Enter")));
shiftEnterAction->setShortcutContext(Qt::WidgetShortcut);
connect(shiftEnterAction, SIGNAL(triggered()), this, SLOT(invokeFindPrevious()));
m_ui.findEdit->addAction(shiftEnterAction);
QAction *shiftReturnAction = new QAction(m_ui.findEdit);
shiftReturnAction->setShortcut(QKeySequence(tr("Shift+Return")));
shiftReturnAction->setShortcutContext(Qt::WidgetShortcut);
connect(shiftReturnAction, SIGNAL(triggered()), this, SLOT(invokeFindPrevious()));
m_ui.findEdit->addAction(shiftReturnAction);
QAction *shiftEnterReplaceAction = new QAction(m_ui.replaceEdit);
shiftEnterReplaceAction->setShortcut(QKeySequence(tr("Shift+Enter")));
shiftEnterReplaceAction->setShortcutContext(Qt::WidgetShortcut);
connect(shiftEnterReplaceAction, SIGNAL(triggered()), this, SLOT(invokeReplacePrevious()));
m_ui.replaceEdit->addAction(shiftEnterReplaceAction);
QAction *shiftReturnReplaceAction = new QAction(m_ui.replaceEdit);
shiftReturnReplaceAction->setShortcut(QKeySequence(tr("Shift+Return")));
shiftReturnReplaceAction->setShortcutContext(Qt::WidgetShortcut);
connect(shiftReturnReplaceAction, SIGNAL(triggered()), this, SLOT(invokeReplacePrevious()));
m_ui.replaceEdit->addAction(shiftReturnReplaceAction);
// need to make sure QStringList is registered as metatype
QMetaTypeId<QStringList>::qt_metatype_id();
// register actions
Core::Context globalcontext(Core::Constants::C_GLOBAL);
Core::ActionManager *am = Core::ICore::actionManager();
Core::ActionContainer *mfind = am->actionContainer(Constants::M_FIND);
Core::Command *cmd;
m_ui.advancedButton->setDefaultAction(am->command(Constants::ADVANCED_FIND)->action());
QIcon icon = QIcon::fromTheme(QLatin1String("edit-find-replace"));
m_findInDocumentAction = new QAction(icon, tr("Find/Replace"), this);
cmd = am->registerAction(m_findInDocumentAction, Constants::FIND_IN_DOCUMENT, globalcontext);
cmd->setDefaultKeySequence(QKeySequence::Find);
mfind->addAction(cmd, Constants::G_FIND_CURRENTDOCUMENT);
connect(m_findInDocumentAction, SIGNAL(triggered()), this, SLOT(openFind()));
if (QApplication::clipboard()->supportsFindBuffer()) {
m_enterFindStringAction = new QAction(tr("Enter Find String"), this);
cmd = am->registerAction(m_enterFindStringAction, "Find.EnterFindString", globalcontext);
cmd->setDefaultKeySequence(QKeySequence(tr("Ctrl+E")));
mfind->addAction(cmd, Constants::G_FIND_ACTIONS);
connect(m_enterFindStringAction, SIGNAL(triggered()), this, SLOT(putSelectionToFindClipboard()));
connect(QApplication::clipboard(), SIGNAL(findBufferChanged()), this, SLOT(updateFromFindClipboard()));
}
//.........这里部分代码省略.........
示例9: initialize
bool QmlJSEditorPlugin::initialize(const QStringList & /*arguments*/, QString *error_message)
{
Core::ICore *core = Core::ICore::instance();
if (!core->mimeDatabase()->addMimeTypes(QLatin1String(":/qmljseditor/QmlJSEditor.mimetypes.xml"), error_message))
return false;
m_modelManager = new ModelManager(this);
addAutoReleasedObject(m_modelManager);
QList<int> context;
context << core->uniqueIDManager()->uniqueIdentifier(QmlJSEditor::Constants::C_QMLJSEDITOR_ID);
m_editor = new QmlJSEditorFactory(this);
addObject(m_editor);
Core::BaseFileWizardParameters wizardParameters(Core::IWizard::FileWizard);
wizardParameters.setCategory(QLatin1String(Core::Constants::WIZARD_CATEGORY_QT));
wizardParameters.setDisplayCategory(QCoreApplication::translate("Core", Core::Constants::WIZARD_TR_CATEGORY_QT));
wizardParameters.setDescription(tr("Creates a Qt QML file."));
wizardParameters.setDisplayName(tr("Qt QML File"));
wizardParameters.setId(QLatin1String("Q.Qml"));
addAutoReleasedObject(new QmlFileWizard(wizardParameters, core));
m_actionHandler = new TextEditor::TextEditorActionHandler(QmlJSEditor::Constants::C_QMLJSEDITOR_ID,
TextEditor::TextEditorActionHandler::Format
| TextEditor::TextEditorActionHandler::UnCommentSelection
| TextEditor::TextEditorActionHandler::UnCollapseAll);
m_actionHandler->initializeActions();
Core::ActionManager *am = core->actionManager();
Core::ActionContainer *contextMenu = am->createMenu(QmlJSEditor::Constants::M_CONTEXT);
Core::Command *cmd;
QAction *followSymbolUnderCursorAction = new QAction(tr("Follow Symbol Under Cursor"), this);
cmd = am->registerAction(followSymbolUnderCursorAction, Constants::FOLLOW_SYMBOL_UNDER_CURSOR, context);
cmd->setDefaultKeySequence(QKeySequence(Qt::Key_F2));
connect(followSymbolUnderCursorAction, SIGNAL(triggered()), this, SLOT(followSymbolUnderCursor()));
contextMenu->addAction(cmd);
cmd = am->command(TextEditor::Constants::AUTO_INDENT_SELECTION);
contextMenu->addAction(cmd);
cmd = am->command(TextEditor::Constants::UN_COMMENT_SELECTION);
contextMenu->addAction(cmd);
CodeCompletion *completion = new CodeCompletion(m_modelManager);
addAutoReleasedObject(completion);
addAutoReleasedObject(new HoverHandler);
// Set completion settings and keep them up to date
TextEditor::TextEditorSettings *textEditorSettings = TextEditor::TextEditorSettings::instance();
completion->setCompletionSettings(textEditorSettings->completionSettings());
connect(textEditorSettings, SIGNAL(completionSettingsChanged(TextEditor::CompletionSettings)),
completion, SLOT(setCompletionSettings(TextEditor::CompletionSettings)));
error_message->clear();
Core::FileIconProvider *iconProvider = Core::FileIconProvider::instance();
iconProvider->registerIconOverlayForSuffix(QIcon(":/qmljseditor/images/qmlfile.png"), "qml");
return true;
}
示例10: initialize
//.........这里部分代码省略.........
wizardParameters.setId(QLatin1String("B.Source"));
addAutoReleasedObject(new CppFileWizard(wizardParameters, Source, core));
wizardParameters.setDescription(tr("Creates a C++ header file that you can add to a C++ project."));
wizardParameters.setDisplayName(tr("C++ Header File"));
wizardParameters.setId(QLatin1String("C.Header"));
addAutoReleasedObject(new CppFileWizard(wizardParameters, Header, core));
Core::Context context(CppEditor::Constants::C_CPPEDITOR);
Core::ActionManager *am = core->actionManager();
Core::ActionContainer *contextMenu= am->createMenu(CppEditor::Constants::M_CONTEXT);
Core::Command *cmd;
Core::ActionContainer *cppToolsMenu = am->actionContainer(Core::Id(CppTools::Constants::M_TOOLS_CPP));
QAction *jumpToDefinition = new QAction(tr("Follow Symbol Under Cursor"), this);
cmd = am->registerAction(jumpToDefinition,
Constants::JUMP_TO_DEFINITION, context, true);
cmd->setDefaultKeySequence(QKeySequence(Qt::Key_F2));
connect(jumpToDefinition, SIGNAL(triggered()),
this, SLOT(jumpToDefinition()));
contextMenu->addAction(cmd);
cppToolsMenu->addAction(cmd);
QAction *switchDeclarationDefinition = new QAction(tr("Switch Between Method Declaration/Definition"), this);
cmd = am->registerAction(switchDeclarationDefinition,
Constants::SWITCH_DECLARATION_DEFINITION, context, true);
cmd->setDefaultKeySequence(QKeySequence("Shift+F2"));
connect(switchDeclarationDefinition, SIGNAL(triggered()),
this, SLOT(switchDeclarationDefinition()));
contextMenu->addAction(cmd);
cppToolsMenu->addAction(cmd);
m_findUsagesAction = new QAction(tr("Find Usages"), this);
cmd = am->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 = am->registerAction(m_openTypeHierarchyAction, Constants::OPEN_TYPE_HIERARCHY, context);
cmd->setDefaultKeySequence(QKeySequence(tr("Ctrl+Shift+T")));
connect(m_openTypeHierarchyAction, SIGNAL(triggered()), this, SLOT(openTypeHierarchy()));
contextMenu->addAction(cmd);
cppToolsMenu->addAction(cmd);
// Refactoring sub-menu
Core::Context globalContext(Core::Constants::C_GLOBAL);
Core::Command *sep = createSeparator(am, this, globalContext,
Constants::SEPARATOR2);
sep->action()->setObjectName(Constants::M_REFACTORING_MENU_INSERTION_POINT);
contextMenu->addAction(sep);
contextMenu->addAction(createSeparator(am, this, globalContext,
Constants::SEPARATOR3));
m_renameSymbolUnderCursorAction = new QAction(tr("Rename Symbol Under Cursor"),
this);
cmd = am->registerAction(m_renameSymbolUnderCursorAction,
Constants::RENAME_SYMBOL_UNDER_CURSOR,
context);
cmd->setDefaultKeySequence(QKeySequence("CTRL+SHIFT+R"));
connect(m_renameSymbolUnderCursorAction, SIGNAL(triggered()),
this, SLOT(renameSymbolUnderCursor()));
cppToolsMenu->addAction(cmd);
// Update context in global context
cppToolsMenu->addAction(createSeparator(am, this, globalContext, CppEditor::Constants::SEPARATOR4));
m_updateCodeModelAction = new QAction(tr("Update Code Model"), this);
cmd = am->registerAction(m_updateCodeModelAction, Core::Id(Constants::UPDATE_CODEMODEL), globalContext);
CPlusPlus::CppModelManagerInterface *cppModelManager = CPlusPlus::CppModelManagerInterface::instance();
connect(m_updateCodeModelAction, 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);
m_actionHandler->initializeActions();
contextMenu->addAction(createSeparator(am, this, context, CppEditor::Constants::SEPARATOR));
cmd = am->command(TextEditor::Constants::AUTO_INDENT_SELECTION);
contextMenu->addAction(cmd);
cmd = am->command(TextEditor::Constants::UN_COMMENT_SELECTION);
contextMenu->addAction(cmd);
connect(core->progressManager(), SIGNAL(taskStarted(QString)),
this, SLOT(onTaskStarted(QString)));
connect(core->progressManager(), SIGNAL(allTasksFinished(QString)),
this, SLOT(onAllTasksFinished(QString)));
connect(core->editorManager(), SIGNAL(currentEditorChanged(Core::IEditor*)), SLOT(currentEditorChanged(Core::IEditor*)));
readSettings();
return true;
}