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)); }
CMakeEditorFactory::CMakeEditorFactory(CMakeManager *manager) : m_mimeTypes(QStringList() << QLatin1String(CMakeProjectManager::Constants::CMAKEMIMETYPE)), m_manager(manager) { using namespace Core; using namespace TextEditor; m_actionHandler = new TextEditorActionHandler(Constants::C_CMAKEEDITOR, TextEditorActionHandler::UnCommentSelection | TextEditorActionHandler::JumpToFileUnderCursor); ActionManager *am = ICore::actionManager(); ActionContainer *contextMenu = am->createMenu(Constants::M_CONTEXT); Command *cmd; Context cmakeEditorContext = Context(Constants::C_CMAKEEDITOR); cmd = am->command(TextEditor::Constants::JUMP_TO_FILE_UNDER_CURSOR); contextMenu->addAction(cmd); QAction *separator = new QAction(this); separator->setSeparator(true); contextMenu->addAction(am->registerAction(separator, Id(Constants::SEPARATOR), cmakeEditorContext)); cmd = am->command(TextEditor::Constants::UN_COMMENT_SELECTION); contextMenu->addAction(cmd); }
void AutotestPlugin::initializeMenuEntries() { ActionContainer *menu = ActionManager::createMenu(Constants::MENU_ID); menu->menu()->setTitle(tr("&Tests")); QAction *action = new QAction(tr("Run &All Tests"), this); Command *command = ActionManager::registerAction(action, Constants::ACTION_RUN_ALL_ID); command->setDefaultKeySequence(QKeySequence(tr("Alt+Shift+T,Alt+A"))); connect(action, &QAction::triggered, this, &AutotestPlugin::onRunAllTriggered); menu->addAction(command); action = new QAction(tr("&Run Selected Tests"), this); command = ActionManager::registerAction(action, Constants::ACTION_RUN_SELECTED_ID); command->setDefaultKeySequence(QKeySequence(tr("Alt+Shift+T,Alt+R"))); connect(action, &QAction::triggered, this, &AutotestPlugin::onRunSelectedTriggered); menu->addAction(command); action = new QAction(tr("Re&scan Tests"), this); command = ActionManager::registerAction(action, Constants::ACTION_SCAN_ID); command->setDefaultKeySequence(QKeySequence(tr("Alt+Shift+T,Alt+S"))); connect(action, &QAction::triggered, TestTreeModel::instance()->parser(), &TestCodeParser::updateTestTree); menu->addAction(command); ActionContainer *toolsMenu = ActionManager::actionContainer(Core::Constants::M_TOOLS); toolsMenu->addMenu(menu); connect(toolsMenu->menu(), &QMenu::aboutToShow, this, &AutotestPlugin::updateMenuItemsEnabledState); }
void DebuggerMainWindow::finalizeSetup() { auto viewButton = new QToolButton; viewButton->setText(tr("Views")); auto toolbar = new Utils::StyledBar; toolbar->setProperty("topBorder", true); auto hbox = new QHBoxLayout(toolbar); hbox->setMargin(0); hbox->setSpacing(0); hbox->addWidget(m_perspectiveChooser); hbox->addWidget(m_controlsStackWidget); hbox->addWidget(m_statusLabel); hbox->addStretch(); hbox->addWidget(new Utils::StyledSeparator); hbox->addWidget(viewButton); connect(viewButton, &QAbstractButton::clicked, [this, viewButton] { QMenu menu; addDockActionsToMenu(&menu); menu.exec(viewButton->mapToGlobal(QPoint())); }); Context debugcontext(Debugger::Constants::C_DEBUGMODE); ActionContainer *viewsMenu = ActionManager::actionContainer(Core::Constants::M_WINDOW_VIEWS); Command *cmd = ActionManager::registerAction(menuSeparator1(), "Debugger.Views.Separator1", debugcontext); cmd->setAttribute(Command::CA_Hide); viewsMenu->addAction(cmd, Core::Constants::G_DEFAULT_THREE); cmd = ActionManager::registerAction(autoHideTitleBarsAction(), "Debugger.Views.AutoHideTitleBars", debugcontext); cmd->setAttribute(Command::CA_Hide); viewsMenu->addAction(cmd, Core::Constants::G_DEFAULT_THREE); cmd = ActionManager::registerAction(menuSeparator2(), "Debugger.Views.Separator2", debugcontext); cmd->setAttribute(Command::CA_Hide); viewsMenu->addAction(cmd, Core::Constants::G_DEFAULT_THREE); cmd = ActionManager::registerAction(resetLayoutAction(), "Debugger.Views.ResetSimple", debugcontext); cmd->setAttribute(Command::CA_Hide); viewsMenu->addAction(cmd, Core::Constants::G_DEFAULT_THREE); addDockActionsToMenu(viewsMenu->menu()); auto dock = new QDockWidget(tr("Toolbar")); dock->setObjectName(QLatin1String("Toolbar")); dock->setFeatures(QDockWidget::NoDockWidgetFeatures); dock->setAllowedAreas(Qt::BottomDockWidgetArea); dock->setTitleBarWidget(new QWidget(dock)); // hide title bar dock->setProperty("managed_dockwidget", QLatin1String("true")); dock->setWidget(toolbar); m_toolbarDock = dock; addDockWidget(Qt::BottomDockWidgetArea, dock); }
ActionContainer *FormEditorW::createPreviewStyleMenu(QActionGroup *actionGroup) { const QString menuId = QLatin1String(M_FORMEDITOR_PREVIEW); ActionContainer *menuPreviewStyle = ActionManager::createMenu(M_FORMEDITOR_PREVIEW); menuPreviewStyle->menu()->setTitle(tr("Preview in")); // The preview menu is a list of invisible actions for the embedded design // device profiles (integer data) followed by a separator and the styles // (string data). Make device profiles update their text and hide them // in the configuration dialog. const QList<QAction*> actions = actionGroup->actions(); const QString deviceProfilePrefix = QLatin1String("DeviceProfile"); const QChar dot = QLatin1Char('.'); foreach (QAction* a, actions) { QString name = menuId; name += dot; const QVariant data = a->data(); const bool isDeviceProfile = data.type() == QVariant::Int; if (isDeviceProfile) { name += deviceProfilePrefix; name += dot; } name += data.toString(); Command *command = ActionManager::registerAction(a, Id::fromString(name), m_contexts); bindShortcut(command, a); if (isDeviceProfile) { command->setAttribute(Command::CA_UpdateText); command->setAttribute(Command::CA_NonConfigurable); } menuPreviewStyle->addAction(command); }
bool GenericProjectPlugin::initialize(const QStringList &, QString *errorMessage) { Q_UNUSED(errorMessage) Utils::MimeDatabase::addMimeTypes(QLatin1String(":genericproject/GenericProjectManager.mimetypes.xml")); addAutoReleasedObject(new Manager); addAutoReleasedObject(new ProjectFilesFactory); addAutoReleasedObject(new GenericMakeStepFactory); addAutoReleasedObject(new GenericBuildConfigurationFactory); IWizardFactory::registerFactoryCreator([]() { return QList<IWizardFactory *>() << new GenericProjectWizard; }); ActionContainer *mproject = ActionManager::actionContainer(ProjectExplorer::Constants::M_PROJECTCONTEXT); auto editFilesAction = new QAction(tr("Edit Files..."), this); Command *command = ActionManager::registerAction(editFilesAction, "GenericProjectManager.EditFiles", Context(Constants::PROJECTCONTEXT)); command->setAttribute(Command::CA_Hide); mproject->addAction(command, ProjectExplorer::Constants::G_PROJECT_FILES); connect(editFilesAction, &QAction::triggered, this, &GenericProjectPlugin::editFiles); return true; }
QmlProfilerTool::QmlProfilerTool(QObject *parent) : IAnalyzerTool(parent), d(new QmlProfilerToolPrivate) { setObjectName(QLatin1String("QmlProfilerTool")); d->m_profilerState = 0; d->m_viewContainer = 0; qmlRegisterType<TimelineRenderer>("Monitor", 1, 0,"TimelineRenderer"); d->m_profilerState = new QmlProfilerStateManager(this); connect(d->m_profilerState, SIGNAL(stateChanged()), this, SLOT(profilerStateChanged())); connect(d->m_profilerState, SIGNAL(clientRecordingChanged()), this, SLOT(clientRecordingChanged())); connect(d->m_profilerState, SIGNAL(serverRecordingChanged()), this, SLOT(serverRecordingChanged())); d->m_profilerConnections = new QmlProfilerClientManager(this); d->m_profilerConnections->registerProfilerStateManager(d->m_profilerState); connect(d->m_profilerConnections, SIGNAL(connectionClosed()), this, SLOT(clientsDisconnected())); d->m_profilerModelManager = new QmlProfilerModelManager(&d->m_projectFinder, this); connect(d->m_profilerModelManager, SIGNAL(stateChanged()), this, SLOT(profilerDataModelStateChanged())); connect(d->m_profilerModelManager, SIGNAL(error(QString)), this, SLOT(showErrorDialog(QString))); d->m_profilerConnections->setModelManager(d->m_profilerModelManager); Command *command = 0; const Context globalContext(C_GLOBAL); ActionContainer *menu = Core::ActionManager::actionContainer(M_DEBUG_ANALYZER); ActionContainer *options = Core::ActionManager::createMenu(M_DEBUG_ANALYZER_QML_OPTIONS); options->menu()->setTitle(tr("QML Profiler Options")); menu->addMenu(options, G_ANALYZER_OPTIONS); options->menu()->setEnabled(true); QAction *act = d->m_loadQmlTrace = new QAction(tr("Load QML Trace"), options); command = Core::ActionManager::registerAction(act, "Analyzer.Menu.StartAnalyzer.QMLProfilerOptions.LoadQMLTrace", globalContext); connect(act, SIGNAL(triggered()), this, SLOT(showLoadDialog())); options->addAction(command); act = d->m_saveQmlTrace = new QAction(tr("Save QML Trace"), options); d->m_saveQmlTrace->setEnabled(false); command = Core::ActionManager::registerAction(act, "Analyzer.Menu.StartAnalyzer.QMLProfilerOptions.SaveQMLTrace", globalContext); connect(act, SIGNAL(triggered()), this, SLOT(showSaveDialog())); options->addAction(command); d->m_recordingTimer.setInterval(100); connect(&d->m_recordingTimer, SIGNAL(timeout()), this, SLOT(updateTimeDisplay())); }
void QtcCppcheckPlugin::initMenus() { QAction *checkNodeAction = new QAction(tr("Scan with cppcheck"), this); Command *checkNodeCmd = ActionManager::registerAction( checkNodeAction, Constants::ACTION_CHECK_NODE_ID, Context(Core::Constants::C_EDIT_MODE)); connect(checkNodeAction, SIGNAL(triggered()), this, SLOT(checkCurrentNode())); #define ADD_TO_MENU(COMMAND, CONTAINER_ID) {ActionContainer *menu = ActionManager::actionContainer(CONTAINER_ID); if (menu != NULL) {menu->addAction (COMMAND);} } ADD_TO_MENU (checkNodeCmd, ProjectExplorer::Constants::M_FILECONTEXT); ADD_TO_MENU (checkNodeCmd, ProjectExplorer::Constants::M_FOLDERCONTEXT); ADD_TO_MENU (checkNodeCmd, ProjectExplorer::Constants::M_PROJECTCONTEXT); ADD_TO_MENU (checkNodeCmd, ProjectExplorer::Constants::M_SUBPROJECTCONTEXT); #undef ADD_TO_MENU QAction *checkProjectAction = new QAction(tr("Check current project"), this); Core::Command *checkProjectCmd = ActionManager::registerAction( checkProjectAction, Constants::ACTION_CHECK_PROJECT_ID, Context(Core::Constants::C_GLOBAL)); checkProjectCmd->setDefaultKeySequence (QKeySequence (tr ("Alt+C,Ctrl+A"))); connect(checkProjectAction, SIGNAL(triggered()), this, SLOT(checkActiveProject())); QAction *checkDocumentAction = new QAction(tr("Check current document"), this); Command *checkDocumentCmd = ActionManager::registerAction( checkDocumentAction, Constants::ACTION_CHECK_DOCUMENT_ID, Context(Core::Constants::C_GLOBAL)); checkDocumentCmd->setDefaultKeySequence (QKeySequence (tr ("Alt+C,Ctrl+D"))); connect(checkDocumentAction, SIGNAL(triggered()), this, SLOT(checkCurrentDocument())); ActionContainer *menu = ActionManager::createMenu(Constants::MENU_ID); menu->menu()->setTitle(tr("Cppcheck")); menu->addAction(checkProjectCmd); menu->addAction(checkDocumentCmd); ActionManager::actionContainer(Core::Constants::M_TOOLS)->addMenu(menu); }
bool QmlJSToolsPlugin::initialize(const QStringList &arguments, QString *error) { Q_UNUSED(arguments) Q_UNUSED(error) Utils::MimeDatabase::addMimeTypes(QLatin1String(":/qmljstools/QmlJSTools.mimetypes.xml")); m_settings = new QmlJSToolsSettings(this); // force registration of qmljstools settings // Objects m_modelManager = new ModelManager(this); // VCSManager *vcsManager = core->vcsManager(); // DocumentManager *fileManager = core->fileManager(); // connect(vcsManager, SIGNAL(repositoryChanged(QString)), // m_modelManager, SLOT(updateModifiedSourceFiles())); // connect(fileManager, SIGNAL(filesChangedInternally(QStringList)), // m_modelManager, SLOT(updateSourceFiles(QStringList))); LocatorData *locatorData = new LocatorData; addAutoReleasedObject(locatorData); addAutoReleasedObject(new FunctionFilter(locatorData)); addAutoReleasedObject(new QmlJSCodeStyleSettingsPage); addAutoReleasedObject(new BasicBundleProvider); // Menus ActionContainer *mtools = ActionManager::actionContainer(Core::Constants::M_TOOLS); ActionContainer *mqmljstools = ActionManager::createMenu(Constants::M_TOOLS_QMLJS); QMenu *menu = mqmljstools->menu(); menu->setTitle(tr("&QML/JS")); menu->setEnabled(true); mtools->addMenu(mqmljstools); // Update context in global context m_resetCodeModelAction = new QAction(tr("Reset Code Model"), this); Command *cmd = ActionManager::registerAction( m_resetCodeModelAction, Constants::RESET_CODEMODEL); connect(m_resetCodeModelAction, &QAction::triggered, m_modelManager, &ModelManager::resetCodeModel); mqmljstools->addAction(cmd); // watch task progress connect(ProgressManager::instance(), SIGNAL(taskStarted(Core::Id)), this, SLOT(onTaskStarted(Core::Id))); connect(ProgressManager::instance(), SIGNAL(allTasksFinished(Core::Id)), this, SLOT(onAllTasksFinished(Core::Id))); return true; }
bool CMakeProjectPlugin::initialize(const QStringList & /*arguments*/, QString *errorMessage) { Q_UNUSED(errorMessage) const Context projectContext(Constants::PROJECTCONTEXT); Utils::MimeDatabase::addMimeTypes(QLatin1String(":cmakeproject/CMakeProjectManager.mimetypes.xml")); Core::FileIconProvider::registerIconOverlayForSuffix(Constants::FILEOVERLAY_CMAKE, "cmake"); Core::FileIconProvider::registerIconOverlayForFilename(Constants::FILEOVERLAY_CMAKE, "CMakeLists.txt"); addAutoReleasedObject(new Internal::CMakeSnippetProvider); addAutoReleasedObject(new CMakeSettingsPage); addAutoReleasedObject(new CMakeManager); addAutoReleasedObject(new CMakeBuildStepFactory); addAutoReleasedObject(new CMakeRunConfigurationFactory); addAutoReleasedObject(new CMakeBuildConfigurationFactory); addAutoReleasedObject(new CMakeEditorFactory); addAutoReleasedObject(new CMakeLocatorFilter); new CMakeToolManager(this); KitManager::registerKitInformation(new CMakeKitInformation); KitManager::registerKitInformation(new CMakeGeneratorKitInformation); KitManager::registerKitInformation(new CMakeConfigurationKitInformation); //menus ActionContainer *msubproject = ActionManager::actionContainer(ProjectExplorer::Constants::M_SUBPROJECTCONTEXT); //register actions Command *command = nullptr; m_buildTargetContextAction = new Utils::ParameterAction(tr("Build"), tr("Build \"%1\""), Utils::ParameterAction::AlwaysEnabled/*handled manually*/, this); command = ActionManager::registerAction(m_buildTargetContextAction, Constants::BUILD_TARGET_CONTEXTMENU, projectContext); command->setAttribute(Command::CA_Hide); command->setAttribute(Command::CA_UpdateText); command->setDescription(m_buildTargetContextAction->text()); msubproject->addAction(command, ProjectExplorer::Constants::G_PROJECT_BUILD); // Wire up context menu updates: connect(ProjectTree::instance(), &ProjectTree::currentNodeChanged, this, &CMakeProjectPlugin::updateContextActions); return true; }
void FormEditorPlugin::extensionsInitialized() { DesignMode::instance()->setDesignModeIsRequired(); // 4) test and make sure everything works (undo, saving, editors, opening/closing multiple files, dirtiness etc) ActionContainer *mtools = ActionManager::actionContainer(Core::Constants::M_TOOLS); ActionContainer *mformtools = ActionManager::createMenu(M_FORMEDITOR); mformtools->menu()->setTitle(tr("For&m Editor")); mtools->addMenu(mformtools); connect(m_actionSwitchSource, &QAction::triggered, this, &FormEditorPlugin::switchSourceForm); Context context(C_FORMEDITOR, Core::Constants::C_EDITORMANAGER); Command *cmd = ActionManager::registerAction(m_actionSwitchSource, "FormEditor.FormSwitchSource", context); cmd->setDefaultKeySequence(tr("Shift+F4")); mformtools->addAction(cmd, Core::Constants::G_DEFAULT_THREE); }
bool ColorPickerPlugin::initialize(const QStringList &arguments, QString *errorMessage) { Q_UNUSED(arguments); Q_UNUSED(errorMessage); auto optionsPage = new ColorPickerOptionsPage; d->generalSettings = optionsPage->generalSettings(); connect(optionsPage, &ColorPickerOptionsPage::generalSettingsChanged, this, &ColorPickerPlugin::onGeneralSettingsChanged); // Register the plugin actions ActionContainer *toolsContainer = ActionManager::actionContainer(Core::Constants::M_TOOLS); ActionContainer *myContainer = ActionManager::createMenu("ColorPicker"); QMenu *myMenu = myContainer->menu(); myMenu->setTitle(tr("&ColorPicker")); myMenu->setEnabled(true); auto triggerColorEditAction = new QAction(tr(Constants::ACTION_NAME_TRIGGER_COLOR_EDIT), this); Command *command = ActionManager::registerAction(triggerColorEditAction, Constants::TRIGGER_COLOR_EDIT); command->setDefaultKeySequence(QKeySequence(tr("Ctrl+Alt+C"))); myContainer->addAction(command); connect(triggerColorEditAction, &QAction::triggered, this, &ColorPickerPlugin::onColorEditTriggered); toolsContainer->addMenu(myContainer); // Register objects addAutoReleasedObject(optionsPage); return true; }
bool LuaEditorPlugin::initialize(const QStringList & /*arguments*/, QString *errorMessage) { if (!Core::MimeDatabase::addMimeTypes(QLatin1String(":/cppeditor/CppEditor.mimetypes.xml"), errorMessage)) return false; addAutoReleasedObject(new LuaEditorFactory(this)); addAutoReleasedObject(new LuaHoverHandler); addAutoReleasedObject(new LuaOutlineWidgetFactory); addAutoReleasedObject(new CppTypeHierarchyFactory); addAutoReleasedObject(new CppIncludeHierarchyFactory); addAutoReleasedObject(new LuaSnippetProvider); addAutoReleasedObject(new LuaHighlighterFactory); m_quickFixProvider = new LuaQuickFixAssistProvider; addAutoReleasedObject(m_quickFixProvider); CppEditor::Internal::registerQuickFixes(this); QString trCat = QCoreApplication::translate(Constants::WIZARD_CATEGORY, Constants::WIZARD_TR_CATEGORY); IWizard *wizard = new LuaClassWizard; wizard->setWizardKind(IWizard::ClassWizard); wizard->setCategory(QLatin1String(Constants::WIZARD_CATEGORY)); wizard->setDisplayCategory(trCat); wizard->setDisplayName(tr("C++ Class")); wizard->setId(QLatin1String("A.Class")); wizard->setDescription(tr("Creates a C++ header and a source file for a new class that you can add to a C++ project.")); addAutoReleasedObject(wizard); wizard = new LuaFileWizard(Source); wizard->setWizardKind(IWizard::FileWizard); wizard->setCategory(QLatin1String(Constants::WIZARD_CATEGORY)); wizard->setDisplayCategory(trCat); wizard->setDisplayName(tr("C++ Class")); wizard->setDescription(tr("Creates a C++ source file that you can add to a C++ project.")); wizard->setDisplayName(tr("C++ Source File")); wizard->setId(QLatin1String("B.Source")); addAutoReleasedObject(wizard); wizard = new LuaFileWizard(Header); wizard->setWizardKind(IWizard::FileWizard); wizard->setCategory(QLatin1String(Constants::WIZARD_CATEGORY)); wizard->setDisplayCategory(trCat); wizard->setDescription(tr("Creates a C++ header file that you can add to a C++ project.")); wizard->setDisplayName(tr("C++ Header File")); wizard->setId(QLatin1String("C.Header")); addAutoReleasedObject(wizard); Context context(CppEditor::Constants::C_CPPEDITOR); ActionContainer *contextMenu = ActionManager::createMenu(CppEditor::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(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; }
QmlProfilerTool::QmlProfilerTool(QObject *parent) : IAnalyzerTool(parent), d(new QmlProfilerToolPrivate(this)) { setObjectName("QmlProfilerTool"); d->m_profilerState = 0; d->m_viewContainer = 0; d->m_runConfiguration = 0; qmlRegisterType<QmlProfilerCanvas>("Monitor", 1, 0, "Canvas2D"); qmlRegisterType<Context2D>(); qmlRegisterType<CanvasGradient>(); qmlRegisterType<TimelineRenderer>("Monitor", 1, 0,"TimelineRenderer"); d->m_profilerState = new QmlProfilerStateManager(this); connect(d->m_profilerState, SIGNAL(stateChanged()), this, SLOT(profilerStateChanged())); connect(d->m_profilerState, SIGNAL(clientRecordingChanged()), this, SLOT(clientRecordingChanged())); connect(d->m_profilerState, SIGNAL(serverRecordingChanged()), this, SLOT(serverRecordingChanged())); d->m_profilerConnections = new QmlProfilerClientManager(this); d->m_profilerConnections->registerProfilerStateManager(d->m_profilerState); d->m_profilerDataModel = new QmlProfilerDataModel(this); connect(d->m_profilerDataModel, SIGNAL(stateChanged()), this, SLOT(profilerDataModelStateChanged())); connect(d->m_profilerDataModel, SIGNAL(error(QString)), this, SLOT(showErrorDialog(QString))); connect(d->m_profilerConnections, SIGNAL(addRangedEvent(int,qint64,qint64,QStringList,QmlJsDebugClient::QmlEventLocation)), d->m_profilerDataModel, SLOT(addRangedEvent(int,qint64,qint64,QStringList,QmlJsDebugClient::QmlEventLocation))); connect(d->m_profilerConnections, SIGNAL(addV8Event(int,QString,QString,int,double,double)), d->m_profilerDataModel, SLOT(addV8Event(int,QString,QString,int,double,double))); connect(d->m_profilerConnections, SIGNAL(addFrameEvent(qint64,int,int)), d->m_profilerDataModel, SLOT(addFrameEvent(qint64,int,int))); connect(d->m_profilerConnections, SIGNAL(traceStarted(qint64)), d->m_profilerDataModel, SLOT(setTraceStartTime(qint64))); connect(d->m_profilerConnections, SIGNAL(traceFinished(qint64)), d->m_profilerDataModel, SLOT(setTraceEndTime(qint64))); connect(d->m_profilerConnections, SIGNAL(dataReadyForProcessing()), d->m_profilerDataModel, SLOT(complete())); d->m_detailsRewriter = new QmlProfilerDetailsRewriter(this); connect(d->m_profilerDataModel, SIGNAL(requestDetailsForLocation(int,QmlJsDebugClient::QmlEventLocation)), d->m_detailsRewriter, SLOT(requestDetailsForLocation(int,QmlJsDebugClient::QmlEventLocation))); connect(d->m_detailsRewriter, SIGNAL(rewriteDetailsString(int,QmlJsDebugClient::QmlEventLocation,QString)), d->m_profilerDataModel, SLOT(rewriteDetailsString(int,QmlJsDebugClient::QmlEventLocation,QString))); connect(d->m_detailsRewriter, SIGNAL(eventDetailsChanged()), d->m_profilerDataModel, SLOT(finishedRewritingDetails())); connect(d->m_profilerDataModel, SIGNAL(reloadDocumentsForDetails()), d->m_detailsRewriter, SLOT(reloadDocuments())); Command *command = 0; const Context globalContext(C_GLOBAL); ActionManager *am = ICore::actionManager(); ActionContainer *menu = am->actionContainer(M_DEBUG_ANALYZER); ActionContainer *options = am->createMenu(M_DEBUG_ANALYZER_QML_OPTIONS); options->menu()->setTitle(tr("QML Profiler Options")); menu->addMenu(options, G_ANALYZER_OPTIONS); options->menu()->setEnabled(true); QAction *act = d->m_loadQmlTrace = new QAction(tr("Load QML Trace"), options); command = am->registerAction(act, "Analyzer.Menu.StartAnalyzer.QMLProfilerOptions.LoadQMLTrace", globalContext); connect(act, SIGNAL(triggered()), this, SLOT(showLoadDialog())); options->addAction(command); act = d->m_saveQmlTrace = new QAction(tr("Save QML Trace"), options); d->m_saveQmlTrace->setEnabled(false); command = am->registerAction(act, "Analyzer.Menu.StartAnalyzer.QMLProfilerOptions.SaveQMLTrace", globalContext); connect(act, SIGNAL(triggered()), this, SLOT(showSaveDialog())); options->addAction(command); d->m_recordingTimer.setInterval(100); connect(&d->m_recordingTimer, SIGNAL(timeout()), this, SLOT(updateTimeDisplay())); }
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; }
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; button->setVisible(visible); m_buttonVisibility.insert(id, visible); connect(action, &QAction::triggered, this, &OutputPaneManager::shortcutTriggered); } m_titleLabel->setMinimumWidth(minTitleWidth + m_titleLabel->contentsMargins().left() + m_titleLabel->contentsMargins().right()); m_buttonsWidget->layout()->addWidget(m_manageButton); connect(m_manageButton, &QAbstractButton::clicked, this, &OutputPaneManager::popupMenu); readSettings(); }
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())); readSettings(); }
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); }
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 mformtools->addSeparator(m_contexts); #if QT_VERSION >= 0x050000 m_actionPreview = m_fwm->action(QDesignerFormWindowManagerInterface::DefaultPreviewAction); #else m_actionPreview = m_fwm->actionDefaultPreview(); #endif QTC_ASSERT(m_actionPreview, return); addToolAction(m_actionPreview, m_contexts, "FormEditor.Preview", mformtools, tr("Alt+Shift+R")); // Preview in style... #if QT_VERSION >= 0x050000 m_actionGroupPreviewInStyle = m_fwm->actionGroup(QDesignerFormWindowManagerInterface::StyledPreviewActionGroup); #else m_actionGroupPreviewInStyle = m_fwm->actionGroupPreviewInStyle(); #endif ActionContainer *previewAC = createPreviewStyleMenu(m_actionGroupPreviewInStyle); m_previewInStyleMenu = previewAC->menu(); mformtools->addMenu(previewAC); setPreviewMenuEnabled(false); // Form settings medit->addSeparator(m_contexts, Core::Constants::G_EDIT_OTHER); mformtools->addSeparator(m_contexts); mformtools->addSeparator(m_contexts, Core::Constants::G_DEFAULT_THREE); #if QT_VERSION >= 0x050000 QAction *actionFormSettings = m_fwm->action(QDesignerFormWindowManagerInterface::FormWindowSettingsDialogAction); #else QAction *actionFormSettings = m_fwm->actionShowFormWindowSettingsDialog(); #endif addToolAction(actionFormSettings, m_contexts, "FormEditor.FormSettings", mformtools, QString(), Core::Constants::G_DEFAULT_THREE); mformtools->addSeparator(m_contexts, Core::Constants::G_DEFAULT_THREE); m_actionAboutPlugins = new QAction(tr("About Qt Designer Plugins..."), this); m_actionAboutPlugins->setMenuRole(QAction::NoRole); addToolAction(m_actionAboutPlugins, m_contexts, "FormEditor.AboutPlugins", mformtools, QString(), Core::Constants::G_DEFAULT_THREE); connect(m_actionAboutPlugins, SIGNAL(triggered()), m_fwm, #if QT_VERSION >= 0x050000 SLOT(showPluginDialog()) #else SLOT(aboutPlugins()) #endif ); m_actionAboutPlugins->setEnabled(false); // FWM connect(m_fwm, SIGNAL(activeFormWindowChanged(QDesignerFormWindowInterface*)), this, SLOT(activeFormWindowChanged(QDesignerFormWindowInterface*))); }
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, context); command->setAttribute(Command::CA_UpdateText); connect(m_deleteAction, SIGNAL(triggered()), this, SLOT(promptToDeleteCurrentFile())); subversionMenu->addAction(command); m_commandLocator->appendCommand(command); m_revertAction = new ParameterAction(tr("Revert..."), tr("Revert \"%1\"..."), ParameterAction::EnabledWithParameter, this); command = ActionManager::registerAction(m_revertAction, CMD_ID_REVERT, context); command->setAttribute(Command::CA_UpdateText); connect(m_revertAction, SIGNAL(triggered()), this, SLOT(revertCurrentFile())); subversionMenu->addAction(command); m_commandLocator->appendCommand(command); subversionMenu->addSeparator(context); m_diffProjectAction = new ParameterAction(tr("Diff Project"), tr("Diff Project \"%1\""), ParameterAction::EnabledWithParameter, this); command = ActionManager::registerAction(m_diffProjectAction, CMD_ID_DIFF_PROJECT, context); command->setAttribute(Command::CA_UpdateText); connect(m_diffProjectAction, SIGNAL(triggered()), this, SLOT(diffProject())); subversionMenu->addAction(command); m_commandLocator->appendCommand(command); m_statusProjectAction = new ParameterAction(tr("Project Status"), tr("Status of Project \"%1\""), ParameterAction::EnabledWithParameter, this); command = ActionManager::registerAction(m_statusProjectAction, CMD_ID_STATUS, context); command->setAttribute(Command::CA_UpdateText); connect(m_statusProjectAction, SIGNAL(triggered()), this, SLOT(projectStatus())); subversionMenu->addAction(command); m_commandLocator->appendCommand(command); m_logProjectAction = new ParameterAction(tr("Log Project"), tr("Log Project \"%1\""), ParameterAction::EnabledWithParameter, this); command = ActionManager::registerAction(m_logProjectAction, CMD_ID_PROJECTLOG, context); command->setAttribute(Command::CA_UpdateText); connect(m_logProjectAction, SIGNAL(triggered()), this, SLOT(logProject())); subversionMenu->addAction(command); m_commandLocator->appendCommand(command); m_updateProjectAction = new ParameterAction(tr("Update Project"), tr("Update Project \"%1\""), ParameterAction::EnabledWithParameter, this); command = ActionManager::registerAction(m_updateProjectAction, CMD_ID_UPDATE, context); connect(m_updateProjectAction, SIGNAL(triggered()), this, SLOT(updateProject())); command->setAttribute(Command::CA_UpdateText); subversionMenu->addAction(command); m_commandLocator->appendCommand(command); m_commitProjectAction = new ParameterAction(tr("Commit Project"), tr("Commit Project \"%1\""), ParameterAction::EnabledWithParameter, this); command = ActionManager::registerAction(m_commitProjectAction, CMD_ID_COMMIT_PROJECT, context); connect(m_commitProjectAction, SIGNAL(triggered()), this, SLOT(startCommitProject())); command->setAttribute(Command::CA_UpdateText); subversionMenu->addAction(command); m_commandLocator->appendCommand(command); subversionMenu->addSeparator(context); m_diffRepositoryAction = new QAction(tr("Diff Repository"), this); command = ActionManager::registerAction(m_diffRepositoryAction, CMD_ID_REPOSITORYDIFF, context); connect(m_diffRepositoryAction, SIGNAL(triggered()), this, SLOT(diffRepository())); subversionMenu->addAction(command); m_commandLocator->appendCommand(command); m_statusRepositoryAction = new QAction(tr("Repository Status"), this); command = ActionManager::registerAction(m_statusRepositoryAction, CMD_ID_REPOSITORYSTATUS, context); connect(m_statusRepositoryAction, SIGNAL(triggered()), this, SLOT(statusRepository())); subversionMenu->addAction(command); m_commandLocator->appendCommand(command); m_logRepositoryAction = new QAction(tr("Log Repository"), this); command = ActionManager::registerAction(m_logRepositoryAction, CMD_ID_REPOSITORYLOG, context); connect(m_logRepositoryAction, SIGNAL(triggered()), this, SLOT(logRepository())); subversionMenu->addAction(command); m_commandLocator->appendCommand(command); m_updateRepositoryAction = new QAction(tr("Update Repository"), this); command = ActionManager::registerAction(m_updateRepositoryAction, CMD_ID_REPOSITORYUPDATE, context); connect(m_updateRepositoryAction, SIGNAL(triggered()), this, SLOT(updateRepository())); subversionMenu->addAction(command); m_commandLocator->appendCommand(command); m_commitAllAction = new QAction(tr("Commit All Files"), this); command = ActionManager::registerAction(m_commitAllAction, CMD_ID_COMMIT_ALL, context); connect(m_commitAllAction, SIGNAL(triggered()), this, SLOT(startCommitAll())); subversionMenu->addAction(command); m_commandLocator->appendCommand(command); m_describeAction = new QAction(tr("Describe..."), this); command = ActionManager::registerAction(m_describeAction, CMD_ID_DESCRIBE, context); connect(m_describeAction, SIGNAL(triggered()), this, SLOT(slotDescribe())); subversionMenu->addAction(command); m_revertRepositoryAction = new QAction(tr("Revert Repository..."), this); command = ActionManager::registerAction(m_revertRepositoryAction, CMD_ID_REVERT_ALL, context); connect(m_revertRepositoryAction, SIGNAL(triggered()), this, SLOT(revertAll())); subversionMenu->addAction(command); m_commandLocator->appendCommand(command); // Actions of the submit editor Context svncommitcontext(Constants::SUBVERSION_COMMIT_EDITOR_ID); m_submitCurrentLogAction = new QAction(VcsBaseSubmitEditor::submitIcon(), tr("Commit"), this); command = ActionManager::registerAction(m_submitCurrentLogAction, SUBMIT_CURRENT, svncommitcontext); command->setAttribute(Command::CA_UpdateText); connect(m_submitCurrentLogAction, SIGNAL(triggered()), this, SLOT(submitCurrentLog())); m_submitDiffAction = new QAction(VcsBaseSubmitEditor::diffIcon(), tr("Diff &Selected Files"), this); command = ActionManager::registerAction(m_submitDiffAction , DIFF_SELECTED, svncommitcontext); m_submitUndoAction = new QAction(tr("&Undo"), this); command = ActionManager::registerAction(m_submitUndoAction, Core::Constants::UNDO, svncommitcontext); m_submitRedoAction = new QAction(tr("&Redo"), this); command = ActionManager::registerAction(m_submitRedoAction, Core::Constants::REDO, svncommitcontext); return true; }
void OutputPaneManager::init() { ActionManager *am = Core::ICore::instance()->actionManager(); ActionContainer *mwindow = am->actionContainer(Constants::M_WINDOW); const Context globalcontext(Core::Constants::C_GLOBAL); // Window->Output Panes ActionContainer *mpanes = am->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"); Core::Command *cmd; cmd = am->registerAction(m_clearAction, "Coreplugin.OutputPane.clear", globalcontext); m_clearButton->setDefaultAction(cmd->action()); mpanes->addAction(cmd, "Coreplugin.OutputPane.ActionsGroup"); cmd = am->registerAction(m_prevAction, "Coreplugin.OutputPane.previtem", globalcontext); cmd->setDefaultKeySequence(QKeySequence("Shift+F6")); m_prevToolButton->setDefaultAction(cmd->action()); mpanes->addAction(cmd, "Coreplugin.OutputPane.ActionsGroup"); cmd = am->registerAction(m_nextAction, "Coreplugin.OutputPane.nextitem", globalcontext); m_nextToolButton->setDefaultAction(cmd->action()); cmd->setDefaultKeySequence(QKeySequence("F6")); mpanes->addAction(cmd, "Coreplugin.OutputPane.ActionsGroup"); cmd = am->registerAction(m_minMaxAction, "Coreplugin.OutputPane.minmax", globalcontext); #ifdef Q_WS_MAC cmd->setDefaultKeySequence(QKeySequence("Ctrl+9")); #else cmd->setDefaultKeySequence(QKeySequence("Alt+9")); #endif 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()); QAction *sep = new QAction(this); sep->setSeparator(true); cmd = am->registerAction(sep, "Coreplugin.OutputPane.Sep", globalcontext); mpanes->addAction(cmd, "Coreplugin.OutputPane.ActionsGroup"); QList<IOutputPane*> panes = ExtensionSystem::PluginManager::instance() ->getObjects<IOutputPane>(); QMultiMap<int, IOutputPane*> sorted; foreach (IOutputPane* outPane, panes) sorted.insertMulti(outPane->priorityInStatusBar(), outPane); QMultiMap<int, IOutputPane*>::const_iterator it, begin; begin = sorted.constBegin(); it = sorted.constEnd(); int shortcutNumber = 1; while (it != begin) { --it; IOutputPane* outPane = it.value(); const int idx = m_outputWidgetPane->addWidget(outPane->outputWidget(this)); m_pageMap.insert(idx, outPane); connect(outPane, SIGNAL(showPage(bool,bool)), this, SLOT(showPage(bool,bool))); connect(outPane, SIGNAL(hidePage()), this, SLOT(slotHide())); connect(outPane, SIGNAL(togglePage(bool)), this, SLOT(togglePage(bool))); connect(outPane, SIGNAL(navigateStateUpdate()), this, SLOT(updateNavigateState())); 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); QString actionId = QString("QtCreator.Pane.%1").arg(outPane->displayName().simplified()); actionId.remove(QLatin1Char(' ')); QAction *action = new QAction(outPane->displayName(), this); Command *cmd = am->registerAction(action, Id(actionId), Context(Constants::C_GLOBAL)); mpanes->addAction(cmd, "Coreplugin.OutputPane.PanesGroup"); m_actions.insert(cmd->action(), idx); if (outPane->priorityInStatusBar() != -1) { cmd->setDefaultKeySequence(QKeySequence(paneShortCut(shortcutNumber))); QToolButton *button = new OutputPaneToggleButton(shortcutNumber, outPane->displayName(), cmd->action()); ++shortcutNumber; m_buttonsWidget->layout()->addWidget(button); connect(button, SIGNAL(clicked()), this, SLOT(buttonTriggered())); m_buttons.insert(idx, button); } // Now add the entry to the combobox, since the first item we add sets the currentIndex, thus we need to be set up for that m_widgetComboBox->addItem(outPane->displayName(), idx); connect(cmd->action(), SIGNAL(triggered()), this, SLOT(shortcutTriggered())); } changePage(); }
OutputPaneManager::OutputPaneManager(QWidget *parent) : QWidget(parent), m_titleLabel(new QLabel), m_manageButton(new OutputPaneManageButton), m_closeButton(new QToolButton), m_minMaxAction(0), m_minMaxButton(new QToolButton), m_nextAction(0), m_prevAction(0), m_outputWidgetPane(new QStackedWidget), m_opToolBarWidgets(new QStackedWidget), m_minimizeIcon(Utils::Icons::ARROW_DOWN.icon()), m_maximizeIcon(Utils::Icons::ARROW_UP.icon()), m_outputPaneHeightSetting(0) { setWindowTitle(tr("Output")); m_titleLabel->setContentsMargins(5, 0, 5, 0); m_clearAction = new QAction(this); m_clearAction->setIcon(Utils::Icons::CLEAN.icon()); m_clearAction->setText(tr("Clear")); connect(m_clearAction, &QAction::triggered, this, &OutputPaneManager::clearPage); m_nextAction = new QAction(this); m_nextAction->setIcon(Utils::Icons::NEXT.icon()); m_nextAction->setText(tr("Next Item")); connect(m_nextAction, &QAction::triggered, this, &OutputPaneManager::slotNext); m_prevAction = new QAction(this); m_prevAction->setIcon(Utils::Icons::PREV.icon()); m_prevAction->setText(tr("Previous Item")); connect(m_prevAction, &QAction::triggered, this, &OutputPaneManager::slotPrev); m_minMaxAction = new QAction(this); m_minMaxAction->setIcon(m_maximizeIcon); m_minMaxAction->setText(tr("Maximize Output Pane")); m_closeButton->setIcon(Icons::CLOSE_SPLIT_BOTTOM.icon()); connect(m_closeButton, &QAbstractButton::clicked, this, &OutputPaneManager::slotHide); connect(ICore::instance(), &ICore::saveSettingsRequested, this, &OutputPaneManager::saveSettings); QVBoxLayout *mainlayout = new QVBoxLayout; mainlayout->setSpacing(0); mainlayout->setMargin(0); m_toolBar = new StyledBar; QHBoxLayout *toolLayout = new QHBoxLayout(m_toolBar); toolLayout->setMargin(0); toolLayout->setSpacing(0); toolLayout->addWidget(m_titleLabel); toolLayout->addWidget(new StyledSeparator); m_clearButton = new QToolButton; toolLayout->addWidget(m_clearButton); m_prevToolButton = new QToolButton; toolLayout->addWidget(m_prevToolButton); m_nextToolButton = new QToolButton; toolLayout->addWidget(m_nextToolButton); toolLayout->addWidget(m_opToolBarWidgets); toolLayout->addWidget(m_minMaxButton); toolLayout->addWidget(m_closeButton); mainlayout->addWidget(m_toolBar); mainlayout->addWidget(m_outputWidgetPane, 10); mainlayout->addWidget(new FindToolBarPlaceHolder(this)); setLayout(mainlayout); m_buttonsWidget = new QWidget; m_buttonsWidget->setLayout(new QHBoxLayout); m_buttonsWidget->layout()->setContentsMargins(5,0,0,0); m_buttonsWidget->layout()->setSpacing( creatorTheme()->flag(Theme::FlatToolBars) ? 9 : 4); StatusBarManager::addStatusBarWidget(m_buttonsWidget, StatusBarManager::Second); 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(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()); m_nextAction->setEnabled(outPane->canNavigate() && outPane->canNext()); } }); 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(' ')); data.id = baseId.withSuffix(suffix); data.action = new QAction(outPane->displayName(), this); Command *cmd = ActionManager::registerAction(data.action, data.id); mpanes->addAction(cmd, "Coreplugin.OutputPane.PanesGroup"); cmd->setDefaultKeySequence(paneShortCut(shortcutNumber)); auto button = new OutputPaneToggleButton(shortcutNumber, outPane->displayName(), cmd->action()); data.button = button; connect(outPane, &IOutputPane::flashButton, button, [button] { button->flash(); }); connect(outPane, &IOutputPane::setBadgeNumber, button, &OutputPaneToggleButton::setIconBadgeNumber); ++shortcutNumber; m_buttonsWidget->layout()->addWidget(data.button); connect(data.button, &QAbstractButton::clicked, this, [this, i] { buttonTriggered(i); }); bool visible = outPane->priorityInStatusBar() != -1; data.button->setVisible(visible); data.buttonVisible = visible; connect(data.action, &QAction::triggered, this, [this, i] { shortcutTriggered(i); }); } m_titleLabel->setMinimumWidth(minTitleWidth + m_titleLabel->contentsMargins().left() + m_titleLabel->contentsMargins().right()); m_buttonsWidget->layout()->addWidget(m_manageButton); connect(m_manageButton, &QAbstractButton::clicked, this, &OutputPaneManager::popupMenu); readSettings(); }
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(); connect(m_reparseExternallyChangedFiles, SIGNAL(triggered()), cppModelManager, SLOT(updateModifiedSourceFiles())); cppToolsMenu->addAction(cmd); cppToolsMenu->addSeparator(); QAction *inspectCppCodeModel = new QAction(tr("Inspect C++ Code Model..."), this); cmd = ActionManager::registerAction(inspectCppCodeModel, Constants::INSPECT_CPP_CODEMODEL); cmd->setDefaultKeySequence(QKeySequence(UseMacShortcuts ? tr("Meta+Shift+F12") : tr("Ctrl+Shift+F12"))); connect(inspectCppCodeModel, SIGNAL(triggered()), this, SLOT(inspectCppCodeModel())); cppToolsMenu->addAction(cmd); 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))); return true; }
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); cmd->setDefaultKeySequence(QKeySequence(tr("Ctrl+Q"))); mfile->addAction(cmd, Constants::G_FILE_OTHER); connect(m_exitAction, SIGNAL(triggered()), this, SLOT(exit())); // Undo Action icon = QIcon::fromTheme(QLatin1String("edit-undo"), Icons::UNDO.icon()); tmpaction = new QAction(icon, tr("&Undo"), this); cmd = ActionManager::registerAction(tmpaction, Constants::UNDO); cmd->setDefaultKeySequence(QKeySequence::Undo); cmd->setAttribute(Command::CA_UpdateText); cmd->setDescription(tr("Undo")); medit->addAction(cmd, Constants::G_EDIT_UNDOREDO); tmpaction->setEnabled(false); // Redo Action icon = QIcon::fromTheme(QLatin1String("edit-redo"), Icons::REDO.icon()); tmpaction = new QAction(icon, tr("&Redo"), this); cmd = ActionManager::registerAction(tmpaction, Constants::REDO); cmd->setDefaultKeySequence(QKeySequence::Redo); cmd->setAttribute(Command::CA_UpdateText); cmd->setDescription(tr("Redo")); medit->addAction(cmd, Constants::G_EDIT_UNDOREDO); tmpaction->setEnabled(false); // Cut Action icon = QIcon::fromTheme(QLatin1String("edit-cut"), Icons::CUT.icon()); tmpaction = new QAction(icon, tr("Cu&t"), this); cmd = ActionManager::registerAction(tmpaction, Constants::CUT); cmd->setDefaultKeySequence(QKeySequence::Cut); medit->addAction(cmd, Constants::G_EDIT_COPYPASTE); tmpaction->setEnabled(false); // Copy Action icon = QIcon::fromTheme(QLatin1String("edit-copy"), Icons::COPY.icon()); tmpaction = new QAction(icon, tr("&Copy"), this); cmd = ActionManager::registerAction(tmpaction, Constants::COPY); cmd->setDefaultKeySequence(QKeySequence::Copy); medit->addAction(cmd, Constants::G_EDIT_COPYPASTE); tmpaction->setEnabled(false); // Paste Action icon = QIcon::fromTheme(QLatin1String("edit-paste"), Icons::PASTE.icon()); tmpaction = new QAction(icon, tr("&Paste"), this); cmd = ActionManager::registerAction(tmpaction, Constants::PASTE); cmd->setDefaultKeySequence(QKeySequence::Paste); medit->addAction(cmd, Constants::G_EDIT_COPYPASTE); tmpaction->setEnabled(false); // Select All icon = QIcon::fromTheme(QLatin1String("edit-select-all")); tmpaction = new QAction(icon, tr("Select &All"), this); cmd = ActionManager::registerAction(tmpaction, Constants::SELECTALL); cmd->setDefaultKeySequence(QKeySequence::SelectAll); medit->addAction(cmd, Constants::G_EDIT_SELECTALL); tmpaction->setEnabled(false); // Goto Action icon = QIcon::fromTheme(QLatin1String("go-jump")); tmpaction = new QAction(icon, tr("&Go to Line..."), this); cmd = ActionManager::registerAction(tmpaction, Constants::GOTO); cmd->setDefaultKeySequence(QKeySequence(tr("Ctrl+L"))); medit->addAction(cmd, Constants::G_EDIT_OTHER); tmpaction->setEnabled(false); // Options Action mtools->appendGroup(Constants::G_TOOLS_OPTIONS); mtools->addSeparator(Constants::G_TOOLS_OPTIONS); m_optionsAction = new QAction(tr("&Options..."), this); m_optionsAction->setMenuRole(QAction::PreferencesRole); cmd = ActionManager::registerAction(m_optionsAction, Constants::OPTIONS); cmd->setDefaultKeySequence(QKeySequence::Preferences); mtools->addAction(cmd, Constants::G_TOOLS_OPTIONS); connect(m_optionsAction, SIGNAL(triggered()), this, SLOT(showOptionsDialog())); mwindow->addSeparator(Constants::G_WINDOW_LIST); if (UseMacShortcuts) { // Minimize Action QAction *minimizeAction = new QAction(tr("Minimize"), this); minimizeAction->setEnabled(false); // actual implementation in WindowSupport cmd = ActionManager::registerAction(minimizeAction, Constants::MINIMIZE_WINDOW); cmd->setDefaultKeySequence(QKeySequence(tr("Ctrl+M"))); mwindow->addAction(cmd, Constants::G_WINDOW_SIZE); // Zoom Action QAction *zoomAction = new QAction(tr("Zoom"), this); zoomAction->setEnabled(false); // actual implementation in WindowSupport cmd = ActionManager::registerAction(zoomAction, Constants::ZOOM_WINDOW); mwindow->addAction(cmd, Constants::G_WINDOW_SIZE); } // Full Screen Action QAction *toggleFullScreenAction = new QAction(tr("Full Screen"), this); toggleFullScreenAction->setCheckable(!HostOsInfo::isMacHost()); toggleFullScreenAction->setEnabled(false); // actual implementation in WindowSupport cmd = ActionManager::registerAction(toggleFullScreenAction, Constants::TOGGLE_FULLSCREEN); cmd->setDefaultKeySequence(QKeySequence(UseMacShortcuts ? tr("Ctrl+Meta+F") : tr("Ctrl+Shift+F11"))); if (HostOsInfo::isMacHost()) cmd->setAttribute(Command::CA_UpdateText); mwindow->addAction(cmd, Constants::G_WINDOW_SIZE); if (UseMacShortcuts) { mwindow->addSeparator(Constants::G_WINDOW_SIZE); QAction *closeAction = new QAction(tr("Close Window"), this); closeAction->setEnabled(false); cmd = ActionManager::registerAction(closeAction, Constants::CLOSE_WINDOW); cmd->setDefaultKeySequence(QKeySequence(tr("Ctrl+Meta+W"))); mwindow->addAction(cmd, Constants::G_WINDOW_SIZE); mwindow->addSeparator(Constants::G_WINDOW_SIZE); } // Show Sidebar Action m_toggleSideBarAction = new QAction(Icons::TOGGLE_SIDEBAR.icon(), QCoreApplication::translate("Core", Constants::TR_SHOW_SIDEBAR), this); m_toggleSideBarAction->setCheckable(true); cmd = ActionManager::registerAction(m_toggleSideBarAction, Constants::TOGGLE_SIDEBAR); cmd->setAttribute(Command::CA_UpdateText); cmd->setDefaultKeySequence(QKeySequence(UseMacShortcuts ? tr("Ctrl+0") : tr("Alt+0"))); connect(m_toggleSideBarAction, &QAction::triggered, this, &MainWindow::setSidebarVisible); m_toggleSideBarButton->setDefaultAction(cmd->action()); mwindow->addAction(cmd, Constants::G_WINDOW_VIEWS); m_toggleSideBarAction->setEnabled(false); // Show Mode Selector Action m_toggleModeSelectorAction = new QAction(tr("Show Mode Selector"), this); m_toggleModeSelectorAction->setCheckable(true); cmd = ActionManager::registerAction(m_toggleModeSelectorAction, Constants::TOGGLE_MODE_SELECTOR); connect(m_toggleModeSelectorAction, &QAction::triggered, ModeManager::instance(), &ModeManager::setModeSelectorVisible); mwindow->addAction(cmd, Constants::G_WINDOW_VIEWS); // Window->Views ActionContainer *mviews = ActionManager::createMenu(Constants::M_WINDOW_VIEWS); mwindow->addMenu(mviews, Constants::G_WINDOW_VIEWS); mviews->menu()->setTitle(tr("&Views")); // "Help" separators mhelp->addSeparator(Constants::G_HELP_SUPPORT); if (!HostOsInfo::isMacHost()) mhelp->addSeparator(Constants::G_HELP_ABOUT); // About IDE Action icon = QIcon::fromTheme(QLatin1String("help-about")); if (HostOsInfo::isMacHost()) tmpaction = new QAction(icon, tr("About &Qt Creator"), this); // it's convention not to add dots to the about menu else tmpaction = new QAction(icon, tr("About &Qt Creator..."), this); tmpaction->setMenuRole(QAction::AboutRole); cmd = ActionManager::registerAction(tmpaction, Constants::ABOUT_QTCREATOR); mhelp->addAction(cmd, Constants::G_HELP_ABOUT); tmpaction->setEnabled(true); connect(tmpaction, &QAction::triggered, this, &MainWindow::aboutQtCreator); //About Plugins Action tmpaction = new QAction(tr("About &Plugins..."), this); tmpaction->setMenuRole(QAction::ApplicationSpecificRole); cmd = ActionManager::registerAction(tmpaction, Constants::ABOUT_PLUGINS); mhelp->addAction(cmd, Constants::G_HELP_ABOUT); tmpaction->setEnabled(true); connect(tmpaction, &QAction::triggered, this, &MainWindow::aboutPlugins); // About Qt Action // tmpaction = new QAction(tr("About &Qt..."), this); // cmd = ActionManager::registerAction(tmpaction, Constants:: ABOUT_QT); // mhelp->addAction(cmd, Constants::G_HELP_ABOUT); // tmpaction->setEnabled(true); // connect(tmpaction, SIGNAL(triggered()), qApp, SLOT(aboutQt())); // About sep if (!HostOsInfo::isMacHost()) { // doesn't have the "About" actions in the Help menu tmpaction = new QAction(this); tmpaction->setSeparator(true); cmd = ActionManager::registerAction(tmpaction, "QtCreator.Help.Sep.About"); mhelp->addAction(cmd, Constants::G_HELP_ABOUT); } }
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; }