UAVSettingsImportExportFactory::UAVSettingsImportExportFactory(QObject *parent) : QObject(parent) { // Add Menu entry Core::ActionManager *am = Core::ICore::instance()->actionManager(); Core::ActionContainer *ac = am->actionContainer(Core::Constants::M_FILE); Core::Command *cmd = am->registerAction(new QAction(this), "UAVSettingsImportExportPlugin.UAVSettingsExport", QList<int>() << Core::Constants::C_GLOBAL_ID); cmd->setDefaultKeySequence(QKeySequence("Ctrl+E")); cmd->action()->setText(tr("Export UAV Settings...")); ac->addAction(cmd, Core::Constants::G_FILE_SAVE); connect(cmd->action(), SIGNAL(triggered(bool)), this, SLOT(exportUAVSettings())); cmd = am->registerAction(new QAction(this), "UAVSettingsImportExportPlugin.UAVSettingsImport", QList<int>() << Core::Constants::C_GLOBAL_ID); cmd->setDefaultKeySequence(QKeySequence("Ctrl+I")); cmd->action()->setText(tr("Import UAV Settings...")); ac->addAction(cmd, Core::Constants::G_FILE_SAVE); connect(cmd->action(), SIGNAL(triggered(bool)), this, SLOT(importUAVSettings())); ac = am->actionContainer(Core::Constants::M_HELP); cmd = am->registerAction(new QAction(this), "UAVSettingsImportExportPlugin.UAVDataExport", QList<int>() << Core::Constants::C_GLOBAL_ID); cmd->action()->setText(tr("Export UAV Data...")); ac->addAction(cmd, Core::Constants::G_HELP_HELP); connect(cmd->action(), SIGNAL(triggered(bool)), this, SLOT(exportUAVData())); }
void BazaarPlugin::createFileActions(const Core::Context &context) { Core::Command *command; m_annotateFile = new Utils::ParameterAction(tr("Annotate Current File"), tr("Annotate \"%1\""), Utils::ParameterAction::EnabledWithParameter, this); command = m_actionManager->registerAction(m_annotateFile, Core::Id(Constants::ANNOTATE), context); command->setAttribute(Core::Command::CA_UpdateText); connect(m_annotateFile, SIGNAL(triggered()), this, SLOT(annotateCurrentFile())); m_bazaarContainer->addAction(command); m_commandLocator->appendCommand(command); m_diffFile = new Utils::ParameterAction(tr("Diff Current File"), tr("Diff \"%1\""), Utils::ParameterAction::EnabledWithParameter, this); command = m_actionManager->registerAction(m_diffFile, Core::Id(Constants::DIFF), context); command->setAttribute(Core::Command::CA_UpdateText); command->setDefaultKeySequence(QKeySequence(tr("Alt+B,Alt+D"))); connect(m_diffFile, SIGNAL(triggered()), this, SLOT(diffCurrentFile())); m_bazaarContainer->addAction(command); m_commandLocator->appendCommand(command); m_logFile = new Utils::ParameterAction(tr("Log Current File"), tr("Log \"%1\""), Utils::ParameterAction::EnabledWithParameter, this); command = m_actionManager->registerAction(m_logFile, Core::Id(Constants::LOG), context); command->setAttribute(Core::Command::CA_UpdateText); command->setDefaultKeySequence(QKeySequence(tr("Alt+B,Alt+L"))); connect(m_logFile, SIGNAL(triggered()), this, SLOT(logCurrentFile())); m_bazaarContainer->addAction(command); m_commandLocator->appendCommand(command); m_statusFile = new Utils::ParameterAction(tr("Status Current File"), tr("Status \"%1\""), Utils::ParameterAction::EnabledWithParameter, this); command = m_actionManager->registerAction(m_statusFile, Core::Id(Constants::STATUS), context); command->setAttribute(Core::Command::CA_UpdateText); command->setDefaultKeySequence(QKeySequence(tr("Alt+B,Alt+S"))); connect(m_statusFile, SIGNAL(triggered()), this, SLOT(statusCurrentFile())); m_bazaarContainer->addAction(command); m_commandLocator->appendCommand(command); createSeparator(context, Core::Id("Bazaar.FileDirSeperator1")); m_addAction = new Utils::ParameterAction(tr("Add"), tr("Add \"%1\""), Utils::ParameterAction::EnabledWithParameter, this); command = m_actionManager->registerAction(m_addAction, Core::Id(Constants::ADD), context); command->setAttribute(Core::Command::CA_UpdateText); connect(m_addAction, SIGNAL(triggered()), this, SLOT(addCurrentFile())); m_bazaarContainer->addAction(command); m_commandLocator->appendCommand(command); m_deleteAction = new Utils::ParameterAction(tr("Delete..."), tr("Delete \"%1\"..."), Utils::ParameterAction::EnabledWithParameter, this); command = m_actionManager->registerAction(m_deleteAction, Core::Id(Constants::DELETE), context); command->setAttribute(Core::Command::CA_UpdateText); connect(m_deleteAction, SIGNAL(triggered()), this, SLOT(promptToDeleteCurrentFile())); m_bazaarContainer->addAction(command); m_commandLocator->appendCommand(command); m_revertFile = new Utils::ParameterAction(tr("Revert Current File..."), tr("Revert \"%1\"..."), Utils::ParameterAction::EnabledWithParameter, this); command = m_actionManager->registerAction(m_revertFile, Core::Id(Constants::REVERT), context); command->setAttribute(Core::Command::CA_UpdateText); connect(m_revertFile, SIGNAL(triggered()), this, SLOT(revertCurrentFile())); m_bazaarContainer->addAction(command); m_commandLocator->appendCommand(command); }
void BazaarPlugin::createFileActions(const Context &context) { Core::Command *command; m_annotateFile = new ParameterAction(tr("Annotate Current File"), tr("Annotate \"%1\""), ParameterAction::EnabledWithParameter, this); command = ActionManager::registerAction(m_annotateFile, ANNOTATE, context); command->setAttribute(Core::Command::CA_UpdateText); connect(m_annotateFile, SIGNAL(triggered()), this, SLOT(annotateCurrentFile())); m_bazaarContainer->addAction(command); m_commandLocator->appendCommand(command); m_diffFile = new ParameterAction(tr("Diff Current File"), tr("Diff \"%1\""), ParameterAction::EnabledWithParameter, this); command = ActionManager::registerAction(m_diffFile, DIFF, context); command->setAttribute(Core::Command::CA_UpdateText); command->setDefaultKeySequence(QKeySequence(UseMacShortcuts ? tr("Meta+Z,Meta+D") : tr("ALT+Z,Alt+D"))); connect(m_diffFile, SIGNAL(triggered()), this, SLOT(diffCurrentFile())); m_bazaarContainer->addAction(command); m_commandLocator->appendCommand(command); m_logFile = new ParameterAction(tr("Log Current File"), tr("Log \"%1\""), ParameterAction::EnabledWithParameter, this); command = ActionManager::registerAction(m_logFile, LOG, context); command->setAttribute(Core::Command::CA_UpdateText); command->setDefaultKeySequence(QKeySequence(UseMacShortcuts ? tr("Meta+Z,Meta+L") : tr("ALT+Z,Alt+L"))); connect(m_logFile, SIGNAL(triggered()), this, SLOT(logCurrentFile())); m_bazaarContainer->addAction(command); m_commandLocator->appendCommand(command); m_statusFile = new ParameterAction(tr("Status Current File"), tr("Status \"%1\""), ParameterAction::EnabledWithParameter, this); command = ActionManager::registerAction(m_statusFile, STATUS, context); command->setAttribute(Core::Command::CA_UpdateText); command->setDefaultKeySequence(QKeySequence(UseMacShortcuts ? tr("Meta+Z,Meta+S") : tr("ALT+Z,Alt+S"))); connect(m_statusFile, SIGNAL(triggered()), this, SLOT(statusCurrentFile())); m_bazaarContainer->addAction(command); m_commandLocator->appendCommand(command); m_bazaarContainer->addSeparator(context); m_addAction = new ParameterAction(tr("Add"), tr("Add \"%1\""), ParameterAction::EnabledWithParameter, this); command = ActionManager::registerAction(m_addAction, ADD, context); command->setAttribute(Core::Command::CA_UpdateText); connect(m_addAction, SIGNAL(triggered()), this, SLOT(addCurrentFile())); m_bazaarContainer->addAction(command); m_commandLocator->appendCommand(command); m_deleteAction = new ParameterAction(tr("Delete..."), tr("Delete \"%1\"..."), ParameterAction::EnabledWithParameter, this); command = ActionManager::registerAction(m_deleteAction, DELETE, context); command->setAttribute(Core::Command::CA_UpdateText); connect(m_deleteAction, SIGNAL(triggered()), this, SLOT(promptToDeleteCurrentFile())); m_bazaarContainer->addAction(command); m_commandLocator->appendCommand(command); m_revertFile = new ParameterAction(tr("Revert Current File..."), tr("Revert \"%1\"..."), ParameterAction::EnabledWithParameter, this); command = ActionManager::registerAction(m_revertFile, REVERT, context); command->setAttribute(Core::Command::CA_UpdateText); connect(m_revertFile, SIGNAL(triggered()), this, SLOT(revertCurrentFile())); m_bazaarContainer->addAction(command); m_commandLocator->appendCommand(command); }
TabBar::TabBar(QWidget *parent) : QTabBar(parent) { setExpanding(false); setMovable(true); setTabsClosable(true); setUsesScrollButtons(true); QSizePolicy sp(QSizePolicy::Preferred, QSizePolicy::Fixed); sp.setHorizontalStretch(1); sp.setVerticalStretch(0); sp.setHeightForWidth(sizePolicy().hasHeightForWidth()); setSizePolicy(sp); connect(this, &QTabBar::tabMoved, [this](int from, int to) { m_editors.move(from, to); }); Core::EditorManager *em = Core::EditorManager::instance(); connect(em, &Core::EditorManager::editorOpened, this, &TabBar::addEditorTab); connect(em, &Core::EditorManager::editorsClosed, this, &TabBar::removeEditorTabs); connect(em, SIGNAL(currentEditorChanged(Core::IEditor*)), SLOT(selectEditorTab(Core::IEditor*))); connect(this, &QTabBar::currentChanged, this, &TabBar::activateEditor); connect(this, &QTabBar::tabCloseRequested, this, &TabBar::closeTab); ProjectExplorer::SessionManager *sm = ProjectExplorer::SessionManager::instance(); connect(sm, &ProjectExplorer::SessionManager::sessionLoaded, [this, em]() { foreach (Core::DocumentModel::Entry *entry, Core::DocumentModel::entries()) em->activateEditorForEntry(entry, Core::EditorManager::DoNotChangeCurrentEditor); }); const QString shortCutSequence = QStringLiteral("Ctrl+Alt+%1"); for (int i = 1; i <= 10; ++i) { QShortcut *shortcut = new QShortcut(shortCutSequence.arg(i % 10), this); connect(shortcut, &QShortcut::activated, [this, shortcut]() { setCurrentIndex(m_shortcuts.indexOf(shortcut)); }); m_shortcuts.append(shortcut); } QAction *prevTabAction = new QAction(tr("Switch to previous tab"), this); Core::Command *prevTabCommand = Core::ActionManager::registerAction(prevTabAction, TabbedEditor::Constants::PREV_TAB_ID, Core::Context(Core::Constants::C_GLOBAL)); prevTabCommand->setDefaultKeySequence(QKeySequence(tr("Ctrl+Shift+J"))); connect(prevTabAction, SIGNAL(triggered()), this, SLOT(prevTabAction())); QAction *nextTabAction = new QAction(tr("Switch to next tab"), this); Core::Command *nextTabCommand = Core::ActionManager::registerAction(nextTabAction, TabbedEditor::Constants::NEXT_TAB_ID, Core::Context(Core::Constants::C_GLOBAL)); nextTabCommand->setDefaultKeySequence(QKeySequence(tr("Ctrl+Shift+K"))); connect(nextTabAction, SIGNAL(triggered()), this, SLOT(nextTabAction())); }
void MercurialPlugin::createFileActions(const Core::Context &context) { Core::Command *command; annotateFile = new ParameterAction(tr("Annotate Current File"), tr("Annotate \"%1\""), ParameterAction::EnabledWithParameter, this); command = Core::ActionManager::registerAction(annotateFile, Core::Id(Constants::ANNOTATE), context); command->setAttribute(Core::Command::CA_UpdateText); connect(annotateFile, &QAction::triggered, this, &MercurialPlugin::annotateCurrentFile); m_mercurialContainer->addAction(command); m_commandLocator->appendCommand(command); diffFile = new ParameterAction(tr("Diff Current File"), tr("Diff \"%1\""), ParameterAction::EnabledWithParameter, this); command = Core::ActionManager::registerAction(diffFile, Core::Id(Constants::DIFF), context); command->setAttribute(Core::Command::CA_UpdateText); command->setDefaultKeySequence(QKeySequence(Core::UseMacShortcuts ? tr("Meta+H,Meta+D") : tr("Alt+G,Alt+D"))); connect(diffFile, &QAction::triggered, this, &MercurialPlugin::diffCurrentFile); m_mercurialContainer->addAction(command); m_commandLocator->appendCommand(command); logFile = new ParameterAction(tr("Log Current File"), tr("Log \"%1\""), ParameterAction::EnabledWithParameter, this); command = Core::ActionManager::registerAction(logFile, Core::Id(Constants::LOG), context); command->setAttribute(Core::Command::CA_UpdateText); command->setDefaultKeySequence(QKeySequence(Core::UseMacShortcuts ? tr("Meta+H,Meta+L") : tr("Alt+G,Alt+L"))); connect(logFile, &QAction::triggered, this, &MercurialPlugin::logCurrentFile); m_mercurialContainer->addAction(command); m_commandLocator->appendCommand(command); statusFile = new ParameterAction(tr("Status Current File"), tr("Status \"%1\""), ParameterAction::EnabledWithParameter, this); command = Core::ActionManager::registerAction(statusFile, Core::Id(Constants::STATUS), context); command->setAttribute(Core::Command::CA_UpdateText); command->setDefaultKeySequence(QKeySequence(Core::UseMacShortcuts ? tr("Meta+H,Meta+S") : tr("Alt+G,Alt+S"))); connect(statusFile, &QAction::triggered, this, &MercurialPlugin::statusCurrentFile); m_mercurialContainer->addAction(command); m_commandLocator->appendCommand(command); m_mercurialContainer->addSeparator(context); m_addAction = new ParameterAction(tr("Add"), tr("Add \"%1\""), ParameterAction::EnabledWithParameter, this); command = Core::ActionManager::registerAction(m_addAction, Core::Id(Constants::ADD), context); command->setAttribute(Core::Command::CA_UpdateText); connect(m_addAction, &QAction::triggered, this, &MercurialPlugin::addCurrentFile); m_mercurialContainer->addAction(command); m_commandLocator->appendCommand(command); m_deleteAction = new ParameterAction(tr("Delete..."), tr("Delete \"%1\"..."), ParameterAction::EnabledWithParameter, this); command = Core::ActionManager::registerAction(m_deleteAction, Core::Id(Constants::DELETE), context); command->setAttribute(Core::Command::CA_UpdateText); connect(m_deleteAction, &QAction::triggered, this, &MercurialPlugin::promptToDeleteCurrentFile); m_mercurialContainer->addAction(command); m_commandLocator->appendCommand(command); revertFile = new ParameterAction(tr("Revert Current File..."), tr("Revert \"%1\"..."), ParameterAction::EnabledWithParameter, this); command = Core::ActionManager::registerAction(revertFile, Core::Id(Constants::REVERT), context); command->setAttribute(Core::Command::CA_UpdateText); connect(revertFile, &QAction::triggered, this, &MercurialPlugin::revertCurrentFile); m_mercurialContainer->addAction(command); m_commandLocator->appendCommand(command); }
bool ExamplePlugin::initialize(const QStringList &arguments, QString *errorString) { // Register objects in the plugin manager's object pool // Load settings // Add actions to menus // Connect to other plugins' signals // In the initialize function, a plugin can be sure that the plugins it // depends on have initialized their members. Q_UNUSED(arguments) Q_UNUSED(errorString) //! [add action] QAction *action = new QAction(tr("Example action"), this); Core::Command *cmd = Core::ActionManager::registerAction(action, Constants::ACTION_ID, Core::Context(Core::Constants::C_GLOBAL)); cmd->setDefaultKeySequence(QKeySequence(tr("Ctrl+Alt+Meta+A"))); connect(action, SIGNAL(triggered()), this, SLOT(triggerAction())); //! [add action] //! [add menu] Core::ActionContainer *menu = Core::ActionManager::createMenu(Constants::MENU_ID); menu->menu()->setTitle(tr("Example")); menu->addAction(cmd); Core::ActionManager::actionContainer(Core::Constants::M_TOOLS)->addMenu(menu); //! [add menu] return true; }
/** * Add Logging plugin to File menu */ bool LoggingPlugin::initialize(const QStringList& args, QString *errMsg) { Q_UNUSED(args); Q_UNUSED(errMsg); loggingThread = NULL; // Add Menu entry Core::ActionManager* am = Core::ICore::instance()->actionManager(); Core::ActionContainer* ac = am->actionContainer(Core::Constants::M_TOOLS); // Command to start logging Core::Command* cmd = am->registerAction(new QAction(this), "LoggingPlugin.Logging", QList<int>() << Core::Constants::C_GLOBAL_ID); cmd->setDefaultKeySequence(QKeySequence("Ctrl+L")); cmd->action()->setText("Start logging..."); ac->menu()->addSeparator(); ac->appendGroup("Logging"); ac->addAction(cmd, "Logging"); connect(cmd->action(), SIGNAL(triggered(bool)), this, SLOT(toggleLogging())); mf = new LoggingGadgetFactory(this); addAutoReleasedObject(mf); // Map signal from end of replay to replay stopped connect(getLogfile(),SIGNAL(replayFinished()), this, SLOT(replayStopped())); return true; }
bool ImportExportPlugin::initialize(const QStringList& args, QString *errMsg) { Q_UNUSED(args); Q_UNUSED(errMsg); // Add Menu entry Core::ActionManager* am = Core::ICore::instance()->actionManager(); Core::ActionContainer* ac = am->actionContainer(Core::Constants::M_FILE); Core::Command* cmd = am->registerAction(new QAction(this), "ImportExportPlugin.ImportExport", QList<int>() << Core::Constants::C_GLOBAL_ID); cmd->setDefaultKeySequence(QKeySequence("Ctrl+S")); cmd->action()->setText(tr("GCS Settings Import/Export...")); // ac->menu()->addSeparator(); // ac->appendGroup("ImportExport"); // ac->addAction(cmd, "ImportExport"); ac->addAction(cmd, Core::Constants::G_FILE_SAVE); connect(cmd->action(), SIGNAL(triggered(bool)), this, SLOT(importExport())); return true; }
void FindPlugin::setupMenu() { Core::ActionContainer *medit = Core::ActionManager::actionContainer(Core::Constants::M_EDIT); Core::ActionContainer *mfind = Core::ActionManager::createMenu(Constants::M_FIND); medit->addMenu(mfind, Core::Constants::G_EDIT_FIND); mfind->menu()->setTitle(tr("&Find/Replace")); mfind->appendGroup(Constants::G_FIND_CURRENTDOCUMENT); mfind->appendGroup(Constants::G_FIND_FILTERS); mfind->appendGroup(Constants::G_FIND_FLAGS); mfind->appendGroup(Constants::G_FIND_ACTIONS); Core::Context globalcontext(Core::Constants::C_GLOBAL); Core::Command *cmd; mfind->addSeparator(globalcontext, Constants::G_FIND_FLAGS); mfind->addSeparator(globalcontext, Constants::G_FIND_ACTIONS); Core::ActionContainer *mfindadvanced = Core::ActionManager::createMenu(Constants::M_FIND_ADVANCED); mfindadvanced->menu()->setTitle(tr("Advanced Find")); mfind->addMenu(mfindadvanced, Constants::G_FIND_FILTERS); d->m_openFindDialog = new QAction(tr("Open Advanced Find..."), this); d->m_openFindDialog->setIconText(tr("Advanced...")); cmd = Core::ActionManager::registerAction(d->m_openFindDialog, Constants::ADVANCED_FIND, globalcontext); cmd->setDefaultKeySequence(QKeySequence(tr("Ctrl+Shift+F"))); mfindadvanced->addAction(cmd); connect(d->m_openFindDialog, SIGNAL(triggered()), this, SLOT(openFindFilter())); }
void FindPlugin::setupFilterMenuItems() { QList<IFindFilter*> findInterfaces = ExtensionSystem::PluginManager::getObjects<IFindFilter>(); Core::Command *cmd; Core::Context globalcontext(Core::Constants::C_GLOBAL); Core::ActionContainer *mfindadvanced = Core::ActionManager::actionContainer(Constants::M_FIND_ADVANCED); d->m_filterActions.clear(); bool haveEnabledFilters = false; const Core::Id base("FindFilter."); foreach (IFindFilter *filter, findInterfaces) { QAction *action = new QAction(QLatin1String(" ") + filter->displayName(), this); bool isEnabled = filter->isEnabled(); if (isEnabled) haveEnabledFilters = true; action->setEnabled(isEnabled); action->setData(qVariantFromValue(filter)); cmd = Core::ActionManager::registerAction(action, base.withSuffix(filter->id()), globalcontext); cmd->setDefaultKeySequence(filter->defaultShortcut()); mfindadvanced->addAction(cmd); d->m_filterActions.insert(filter, action); connect(action, SIGNAL(triggered(bool)), this, SLOT(openFindFilter())); connect(filter, SIGNAL(enabledChanged(bool)), this, SLOT(filterChanged())); }
void DesignerActionManager::polishActions() const { QList<ActionInterface* > actions = Utils::filtered(designerActions(), [](ActionInterface *action) { return action->type() != ActionInterface::ContextMenu; }); Core::Context qmlDesignerFormEditorContext(Constants::C_QMLFORMEDITOR); Core::Context qmlDesignerNavigatorContext(Constants::C_QMLNAVIGATOR); Core::Context qmlDesignerUIContext; qmlDesignerUIContext.add(qmlDesignerFormEditorContext); qmlDesignerUIContext.add(qmlDesignerNavigatorContext); for (auto *action : actions) { if (!action->menuId().isEmpty()) { const QString id = QString("QmlDesigner.%1").arg(QString::fromLatin1(action->menuId())); Core::Command *cmd = Core::ActionManager::registerAction(action->action(), id.toLatin1().constData(), qmlDesignerUIContext); cmd->setDefaultKeySequence(action->action()->shortcut()); cmd->setDescription(action->action()->toolTip()); action->action()->setToolTip(cmd->action()->toolTip()); action->action()->setShortcut(cmd->action()->shortcut()); action->action()->setShortcutContext(Qt::WidgetShortcut); //Hack to avoid conflicting shortcuts. We use the Core::Command for the shortcut. } } }
bool Tester::Internal::Plugin::initialize(const QStringList &arguments, QString *errorString) { // Register objects in the plugin manager's object pool // Load settings // Add actions to menus // Connect to other plugins' signals // In the initialize method, a plugin can be sure that the plugins it // depends on have initialized their members. Q_UNUSED(arguments) Q_UNUSED(errorString) Core::Command *cmd = Core::ActionManager::registerAction(Controller->startAction(), Constants::ACTION_ID, Core::Context(Core::Constants::C_GLOBAL)); cmd->setDefaultKeySequence(QKeySequence(tr("Ctrl+Alt+Meta+A"))); connect(Controller->startAction(), SIGNAL(triggered()), this, SLOT(triggerAction())); Core::ActionContainer *menu = Core::ActionManager::createMenu(Constants::MENU_ID); menu->menu()->setTitle(tr("TesterPlugin")); menu->addAction(cmd); Core::ActionManager::actionContainer(Core::Constants::M_TOOLS)->addMenu(menu); MonitoringViewFactory = new Tester::Internal::MonitoringViewFactory; MonitoringViewFactory->setController(Controller); addAutoReleasedObject(MonitoringViewFactory); Mode = new Tester::Internal::Mode(this); Mode->setController(Controller); addAutoReleasedObject(Mode); return true; }
//////////////////////////////////////////////////// // // INHERITED FROM ExtensionSystem::Plugin // //////////////////////////////////////////////////// bool QmlDesignerPlugin::initialize(const QStringList & /*arguments*/, QString *errorMessage/* = 0*/) // =0; { if (!Utils::HostOsInfo::canCreateOpenGLContext(errorMessage)) return false; d = new QmlDesignerPluginPrivate; d->settings.fromSettings(Core::ICore::settings()); d->viewManager.registerViewTakingOwnership(new QmlDesigner::Internal::ConnectionView()); d->viewManager.registerFormEditorToolTakingOwnership(new QmlDesigner::SourceTool); d->viewManager.registerFormEditorToolTakingOwnership(new QmlDesigner::ColorTool); d->viewManager.registerFormEditorToolTakingOwnership(new QmlDesigner::TextTool); d->viewManager.registerFormEditorToolTakingOwnership(new QmlDesigner::PathTool); const Core::Context switchContext(QmlDesigner::Constants::C_QMLDESIGNER, QmlJSEditor::Constants::C_QMLJSEDITOR_ID); QAction *switchTextDesignAction = new QAction(tr("Switch Text/Design"), this); Core::Command *command = Core::ActionManager::registerAction( switchTextDesignAction, QmlDesigner::Constants::SWITCH_TEXT_DESIGN, switchContext); command->setDefaultKeySequence(QKeySequence(Qt::Key_F4)); createDesignModeWidget(); connect(switchTextDesignAction, &QAction::triggered, this, &switchTextDesign); addAutoReleasedObject(new Internal::SettingsPage); return true; }
//////////////////////////////////////////////////// // // INHERITED FROM ExtensionSystem::Plugin // //////////////////////////////////////////////////// bool QmlDesignerPlugin::initialize(const QStringList & /*arguments*/, QString *errorMessage/* = 0*/) // =0; { const Core::Context switchContext(QmlDesigner::Constants::C_QMLDESIGNER, QmlJSEditor::Constants::C_QMLJSEDITOR_ID); QAction *switchAction = new QAction(tr("Switch Text/Design"), this); Core::Command *command = Core::ActionManager::registerAction( switchAction, QmlDesigner::Constants::SWITCH_TEXT_DESIGN, switchContext); command->setDefaultKeySequence(QKeySequence(Qt::Key_F4)); m_instance = this; const QString pluginPath = Utils::HostOsInfo::isMacHost() ? QString(QCoreApplication::applicationDirPath() + "/../PlugIns/QmlDesigner") : QString(QCoreApplication::applicationDirPath() + "/../" + QLatin1String(IDE_LIBRARY_BASENAME) + "/qtcreator/qmldesigner"); m_pluginManager.setPluginPaths(QStringList() << pluginPath); createDesignModeWidget(); connect(switchAction, SIGNAL(triggered()), this, SLOT(switchTextDesign())); addAutoReleasedObject(new Internal::SettingsPage); m_settings.fromSettings(Core::ICore::settings()); errorMessage->clear(); return true; }
bool MacrosPlugin::initialize(const QStringList &arguments, QString *errorMessage) { Q_UNUSED(arguments); Q_UNUSED(errorMessage); addAutoReleasedObject(new MacroOptionsPage); addAutoReleasedObject(new MacroLocatorFilter); Core::Context globalcontext(Core::Constants::C_GLOBAL); Core::Context textContext(TextEditor::Constants::C_TEXTEDITOR); m_macroManager = new MacroManager(this); // Menus Core::ActionContainer *mtools = Core::ActionManager::actionContainer(Core::Constants::M_TOOLS); Core::ActionContainer *mmacrotools = Core::ActionManager::createMenu(Constants::M_TOOLS_MACRO); QMenu *menu = mmacrotools->menu(); menu->setTitle(tr("&Macros")); menu->setEnabled(true); mtools->addMenu(mmacrotools); QAction *startMacro = new QAction(tr("Record Macro"), this); Core::Command *command = Core::ActionManager::registerAction(startMacro, Constants::START_MACRO, textContext); command->setDefaultKeySequence(QKeySequence(Core::UseMacShortcuts ? tr("Ctrl+(") : tr("Alt+("))); mmacrotools->addAction(command); connect(startMacro, SIGNAL(triggered()), m_macroManager, SLOT(startMacro())); QAction *endMacro = new QAction(tr("Stop Recording Macro"), this); endMacro->setEnabled(false); command = Core::ActionManager::registerAction(endMacro, Constants::END_MACRO, globalcontext); command->setDefaultKeySequence(QKeySequence(Core::UseMacShortcuts ? tr("Ctrl+)") : tr("Alt+)"))); mmacrotools->addAction(command); connect(endMacro, SIGNAL(triggered()), m_macroManager, SLOT(endMacro())); QAction *executeLastMacro = new QAction(tr("Play Last Macro"), this); command = Core::ActionManager::registerAction(executeLastMacro, Constants::EXECUTE_LAST_MACRO, textContext); command->setDefaultKeySequence(QKeySequence(Core::UseMacShortcuts ? tr("Meta+R") : tr("Alt+R"))); mmacrotools->addAction(command); connect(executeLastMacro, SIGNAL(triggered()), m_macroManager, SLOT(executeLastMacro())); QAction *saveLastMacro = new QAction(tr("Save Last Macro"), this); saveLastMacro->setEnabled(false); command = Core::ActionManager::registerAction(saveLastMacro, Constants::SAVE_LAST_MACRO, textContext); mmacrotools->addAction(command); connect(saveLastMacro, SIGNAL(triggered()), m_macroManager, SLOT(saveLastMacro())); return true; }
void ActionHandler::createEditPropertiesShortcut(const Core::Id &shortcutId) { auto editAction = new QAction(tr("Edit selected element in properties view"), Core::ICore::mainWindow()); Core::Command *editCommand = Core::ActionManager::registerAction( editAction, shortcutId, d->context); editCommand->setDefaultKeySequence(QKeySequence(tr("F2"))); connect(editAction, &QAction::triggered, this, &ActionHandler::onEditProperties); }
void MercurialPlugin::createRepositoryActions(const Core::Context &context) { QAction *action = new QAction(tr("Pull..."), this); m_repositoryActionList.append(action); Core::Command *command = actionManager->registerAction(action, Core::Id(Constants::PULL), context); connect(action, SIGNAL(triggered()), this, SLOT(pull())); mercurialContainer->addAction(command); m_commandLocator->appendCommand(command); action = new QAction(tr("Push..."), this); m_repositoryActionList.append(action); command = actionManager->registerAction(action, Core::Id(Constants::PUSH), context); connect(action, SIGNAL(triggered()), this, SLOT(push())); mercurialContainer->addAction(command); m_commandLocator->appendCommand(command); action = new QAction(tr("Update..."), this); m_repositoryActionList.append(action); command = actionManager->registerAction(action, Core::Id(Constants::UPDATE), context); connect(action, SIGNAL(triggered()), this, SLOT(update())); mercurialContainer->addAction(command); m_commandLocator->appendCommand(command); action = new QAction(tr("Import..."), this); m_repositoryActionList.append(action); command = actionManager->registerAction(action, Core::Id(Constants::IMPORT), context); connect(action, SIGNAL(triggered()), this, SLOT(import())); mercurialContainer->addAction(command); m_commandLocator->appendCommand(command); action = new QAction(tr("Incoming..."), this); m_repositoryActionList.append(action); command = actionManager->registerAction(action, Core::Id(Constants::INCOMING), context); connect(action, SIGNAL(triggered()), this, SLOT(incoming())); mercurialContainer->addAction(command); m_commandLocator->appendCommand(command); action = new QAction(tr("Outgoing..."), this); m_repositoryActionList.append(action); command = actionManager->registerAction(action, Core::Id(Constants::OUTGOING), context); connect(action, SIGNAL(triggered()), this, SLOT(outgoing())); mercurialContainer->addAction(command); m_commandLocator->appendCommand(command); action = new QAction(tr("Commit..."), this); m_repositoryActionList.append(action); command = actionManager->registerAction(action, Core::Id(Constants::COMMIT), context); command->setDefaultKeySequence(QKeySequence(tr("Alt+H,Alt+C"))); connect(action, SIGNAL(triggered()), this, SLOT(commit())); mercurialContainer->addAction(command); m_commandLocator->appendCommand(command); m_createRepositoryAction = new QAction(tr("Create Repository..."), this); command = actionManager->registerAction(m_createRepositoryAction, Core::Id(Constants::CREATE_REPOSITORY), context); connect(m_createRepositoryAction, SIGNAL(triggered()), this, SLOT(createRepository())); mercurialContainer->addAction(command); }
void MercurialPlugin::createRepositoryActions(const Core::Context &context) { auto action = new QAction(tr("Pull..."), this); m_repositoryActionList.append(action); Core::Command *command = Core::ActionManager::registerAction(action, Core::Id(Constants::PULL), context); connect(action, &QAction::triggered, this, &MercurialPlugin::pull); m_mercurialContainer->addAction(command); m_commandLocator->appendCommand(command); action = new QAction(tr("Push..."), this); m_repositoryActionList.append(action); command = Core::ActionManager::registerAction(action, Core::Id(Constants::PUSH), context); connect(action, &QAction::triggered, this, &MercurialPlugin::push); m_mercurialContainer->addAction(command); m_commandLocator->appendCommand(command); action = new QAction(tr("Update..."), this); m_repositoryActionList.append(action); command = Core::ActionManager::registerAction(action, Core::Id(Constants::UPDATE), context); connect(action, &QAction::triggered, this, &MercurialPlugin::update); m_mercurialContainer->addAction(command); m_commandLocator->appendCommand(command); action = new QAction(tr("Import..."), this); m_repositoryActionList.append(action); command = Core::ActionManager::registerAction(action, Core::Id(Constants::IMPORT), context); connect(action, &QAction::triggered, this, &MercurialPlugin::import); m_mercurialContainer->addAction(command); m_commandLocator->appendCommand(command); action = new QAction(tr("Incoming..."), this); m_repositoryActionList.append(action); command = Core::ActionManager::registerAction(action, Core::Id(Constants::INCOMING), context); connect(action, &QAction::triggered, this, &MercurialPlugin::incoming); m_mercurialContainer->addAction(command); m_commandLocator->appendCommand(command); action = new QAction(tr("Outgoing..."), this); m_repositoryActionList.append(action); command = Core::ActionManager::registerAction(action, Core::Id(Constants::OUTGOING), context); connect(action, &QAction::triggered, this, &MercurialPlugin::outgoing); m_mercurialContainer->addAction(command); m_commandLocator->appendCommand(command); action = new QAction(tr("Commit..."), this); m_repositoryActionList.append(action); command = Core::ActionManager::registerAction(action, Core::Id(Constants::COMMIT), context); command->setDefaultKeySequence(QKeySequence(Core::UseMacShortcuts ? tr("Meta+H,Meta+C") : tr("Alt+G,Alt+C"))); connect(action, &QAction::triggered, this, &MercurialPlugin::commit); m_mercurialContainer->addAction(command); m_commandLocator->appendCommand(command); m_createRepositoryAction = new QAction(tr("Create Repository..."), this); command = Core::ActionManager::registerAction(m_createRepositoryAction, Core::Id(Constants::CREATE_REPOSITORY), context); connect(m_createRepositoryAction, &QAction::triggered, this, &MercurialPlugin::createRepository); m_mercurialContainer->addAction(command); }
void ImageViewerActionHandler::registerNewAction(int actionId, const Core::Id &id, const QString &title, const QKeySequence &key) { Core::Context context(Constants::IMAGEVIEWER_ID); QAction *action = new QAction(title, this); Core::Command *command = Core::ActionManager::registerAction(action, id, context); command->setDefaultKeySequence(key); connect(action, SIGNAL(triggered()), m_signalMapper, SLOT(map())); m_signalMapper->setMapping(action, actionId); }
Core::Command *GLSLEditorPlugin::addToolAction(QAction *a, Core::ActionManager *am, Core::Context &context, const QString &name, Core::ActionContainer *c1, const QString &keySequence) { Core::Command *command = am->registerAction(a, name, context); if (!keySequence.isEmpty()) command->setDefaultKeySequence(QKeySequence(keySequence)); c1->addAction(command); return command; }
Core::Command *QmlJSEditorPlugin::addToolAction(QAction *a, Core::Context &context, Core::Id id, Core::ActionContainer *c1, const QString &keySequence) { Core::Command *command = Core::ActionManager::registerAction(a, id, context); if (!keySequence.isEmpty()) command->setDefaultKeySequence(QKeySequence(keySequence)); c1->addAction(command); return command; }
bool CppToolsPlugin::initialize(const QStringList &arguments, QString *error) { Q_UNUSED(arguments) Q_UNUSED(error) qRegisterMetaType<CppTools::CppCodeStyleSettings>("CppTools::CppCodeStyleSettings"); Core::ICore *core = Core::ICore::instance(); Core::ActionManager *am = core->actionManager(); m_settings = new CppToolsSettings(this); // force registration of cpp tools settings // Objects m_modelManager = new CppModelManager(this); Core::VcsManager *vcsManager = core->vcsManager(); Core::FileManager *fileManager = core->fileManager(); connect(vcsManager, SIGNAL(repositoryChanged(QString)), m_modelManager, SLOT(updateModifiedSourceFiles())); connect(fileManager, SIGNAL(filesChangedInternally(QStringList)), m_modelManager, SLOT(updateSourceFiles(QStringList))); addAutoReleasedObject(m_modelManager); addAutoReleasedObject(new CppCompletionAssistProvider); addAutoReleasedObject(new CppLocatorFilter(m_modelManager)); addAutoReleasedObject(new CppClassesFilter(m_modelManager)); addAutoReleasedObject(new CppFunctionsFilter(m_modelManager)); addAutoReleasedObject(new CppCurrentDocumentFilter(m_modelManager, core->editorManager())); addAutoReleasedObject(new CompletionSettingsPage); addAutoReleasedObject(new CppFileSettingsPage(m_fileSettings)); addAutoReleasedObject(new SymbolsFindFilter(m_modelManager)); addAutoReleasedObject(new CppCodeStyleSettingsPage); TextEditor::CodeStylePreferencesManager::instance()->registerFactory( new CppTools::CppCodeStylePreferencesFactory()); // Menus Core::ActionContainer *mtools = am->actionContainer(Core::Constants::M_TOOLS); Core::ActionContainer *mcpptools = am->createMenu(CppTools::Constants::M_TOOLS_CPP); QMenu *menu = mcpptools->menu(); menu->setTitle(tr("&C++")); menu->setEnabled(true); mtools->addMenu(mcpptools); // Actions Core::Context context(CppEditor::Constants::C_CPPEDITOR); QAction *switchAction = new QAction(tr("Switch Header/Source"), this); Core::Command *command = am->registerAction(switchAction, Constants::SWITCH_HEADER_SOURCE, context, true); command->setDefaultKeySequence(QKeySequence(Qt::Key_F4)); mcpptools->addAction(command); connect(switchAction, SIGNAL(triggered()), this, SLOT(switchHeaderSource())); return true; }
Core::Command *ActionHandler::registerCommand(const Core::Id &id, const std::function<void()> &slot, bool scriptable, const QString &title, const QKeySequence &keySequence) { auto action = new QAction(title, this); Core::Command *command = Core::ActionManager::registerAction(action, id, d->context, scriptable); if (!keySequence.isEmpty()) command->setDefaultKeySequence(keySequence); if (slot) connect(action, &QAction::triggered, this, slot); return command; }
void BazaarPlugin::createRepositoryActions(const Core::Context &context) { QAction *action = 0; Core::Command *command = 0; action = new QAction(tr("Pull..."), this); m_repositoryActionList.append(action); command = Core::ActionManager::registerAction(action, Core::Id(Constants::PULL), context); connect(action, SIGNAL(triggered()), this, SLOT(pull())); m_bazaarContainer->addAction(command); m_commandLocator->appendCommand(command); action = new QAction(tr("Push..."), this); m_repositoryActionList.append(action); command = Core::ActionManager::registerAction(action, Core::Id(Constants::PUSH), context); connect(action, SIGNAL(triggered()), this, SLOT(push())); m_bazaarContainer->addAction(command); m_commandLocator->appendCommand(command); action = new QAction(tr("Update..."), this); m_repositoryActionList.append(action); command = Core::ActionManager::registerAction(action, Core::Id(Constants::UPDATE), context); connect(action, SIGNAL(triggered()), this, SLOT(update())); m_bazaarContainer->addAction(command); m_commandLocator->appendCommand(command); action = new QAction(tr("Commit..."), this); m_repositoryActionList.append(action); command = Core::ActionManager::registerAction(action, Core::Id(Constants::COMMIT), context); command->setDefaultKeySequence(QKeySequence(Core::UseMacShortcuts ? tr("Meta+Z,Meta+C") : tr("ALT+Z,Alt+C"))); connect(action, SIGNAL(triggered()), this, SLOT(commit())); m_bazaarContainer->addAction(command); m_commandLocator->appendCommand(command); action = new QAction(tr("Uncommit..."), this); m_repositoryActionList.append(action); command = Core::ActionManager::registerAction(action, Core::Id(Constants::UNCOMMIT), context); connect(action, SIGNAL(triggered()), this, SLOT(uncommit())); m_bazaarContainer->addAction(command); m_commandLocator->appendCommand(command); QAction *createRepositoryAction = new QAction(tr("Create Repository..."), this); command = Core::ActionManager::registerAction(createRepositoryAction, Core::Id(Constants::CREATE_REPOSITORY), context); connect(createRepositoryAction, SIGNAL(triggered()), this, SLOT(createRepository())); m_bazaarContainer->addAction(command); }
QAction *TextEditorActionHandler::registerAction(const Core::Id &id, const char *slot, bool scriptable, const QString &title, const QKeySequence &keySequence, const char *menueGroup, Core::ActionContainer *container) { QAction *result = new QAction(title, this); Core::Command *command = Core::ActionManager::registerAction(result, id, Core::Context(m_contextId), scriptable); if (!keySequence.isEmpty()) command->setDefaultKeySequence(keySequence); if (container && menueGroup) container->addAction(command, menueGroup); connect(result, SIGNAL(triggered(bool)), this, slot); return result; }
void NavigationWidget::objectAdded(QObject * obj) { INavigationWidgetFactory *factory = Aggregation::query<INavigationWidgetFactory>(obj); if (!factory) return; ICore *core = ICore::instance(); ActionManager *am = core->actionManager(); QList<int> navicontext = QList<int>() << core->uniqueIDManager()-> uniqueIdentifier(Core::Constants::C_NAVIGATION_PANE); QString displayName = factory->displayName(); QShortcut *shortcut = new QShortcut(this); shortcut->setWhatsThis(tr("Activate %1 Pane").arg(displayName)); Core::Command *cmd = am->registerShortcut(shortcut, QLatin1String("QtCreator.Sidebar.") + displayName, navicontext); cmd->setDefaultKeySequence(factory->activationSequence()); connect(shortcut, SIGNAL(activated()), this, SLOT(activateSubWidget())); m_shortcutMap.insert(shortcut, displayName); m_commandMap.insert(displayName, cmd); }
bool LocatorPlugin::initialize(const QStringList &, QString *) { m_settingsPage = new SettingsPage(this); addObject(m_settingsPage); m_locatorWidget = new LocatorWidget(this); m_locatorWidget->setEnabled(false); Core::StatusBarWidget *view = new Core::StatusBarWidget; view->setWidget(m_locatorWidget); view->setContext(Core::Context("LocatorWidget")); view->setPosition(Core::StatusBarWidget::First); addAutoReleasedObject(view); QAction *action = new QAction(m_locatorWidget->windowIcon(), m_locatorWidget->windowTitle(), this); Core::Command *cmd = Core::ActionManager::registerAction(action, "QtCreator.Locate", Core::Context(Core::Constants::C_GLOBAL)); cmd->setDefaultKeySequence(QKeySequence(tr("Ctrl+K"))); connect(action, SIGNAL(triggered()), this, SLOT(openLocator())); connect(cmd, SIGNAL(keySequenceChanged()), this, SLOT(updatePlaceholderText())); updatePlaceholderText(cmd); Core::ActionContainer *mtools = Core::ActionManager::actionContainer(Core::Constants::M_TOOLS); mtools->addAction(cmd); addObject(new LocatorManager(m_locatorWidget)); m_openDocumentsFilter = new OpenDocumentsFilter(Core::ICore::editorManager()); addObject(m_openDocumentsFilter); m_fileSystemFilter = new FileSystemFilter(Core::ICore::editorManager(), m_locatorWidget); addObject(m_fileSystemFilter); m_executeFilter = new ExecuteFilter(); addObject(m_executeFilter); addAutoReleasedObject(new LocatorFiltersFilter(this, m_locatorWidget)); return true; }
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 QbsProjectManagerPlugin::initialize(const QStringList &arguments, QString *errorMessage) { Q_UNUSED(arguments); Q_UNUSED(errorMessage); const Core::Context projectContext(::QbsProjectManager::Constants::PROJECT_ID); const Core::Context globalcontext(Core::Constants::C_GLOBAL); Core::FileIconProvider::registerIconOverlayForSuffix(QtSupport::Constants::ICON_QT_PROJECT, "qbs"); //create and register objects addAutoReleasedObject(new QbsManager); addAutoReleasedObject(new QbsBuildConfigurationFactory); addAutoReleasedObject(new QbsBuildStepFactory); addAutoReleasedObject(new QbsCleanStepFactory); addAutoReleasedObject(new QbsInstallStepFactory); addAutoReleasedObject(new QbsDeployConfigurationFactory); addAutoReleasedObject(new QbsRunConfigurationFactory); addAutoReleasedObject(new QbsProfilesSettingsPage); //menus // Build Menu: Core::ActionContainer *mbuild = Core::ActionManager::actionContainer(ProjectExplorer::Constants::M_BUILDPROJECT); // PE Context menu for projects Core::ActionContainer *mproject = Core::ActionManager::actionContainer(ProjectExplorer::Constants::M_PROJECTCONTEXT); Core::ActionContainer *msubproject = Core::ActionManager::actionContainer(ProjectExplorer::Constants::M_SUBPROJECTCONTEXT); Core::ActionContainer *mfile = Core::ActionManager::actionContainer(ProjectExplorer::Constants::M_FILECONTEXT); //register actions Core::Command *command; m_reparseQbs = new QAction(tr("Reparse Qbs"), this); command = Core::ActionManager::registerAction(m_reparseQbs, Constants::ACTION_REPARSE_QBS, projectContext); command->setAttribute(Core::Command::CA_Hide); mbuild->addAction(command, ProjectExplorer::Constants::G_BUILD_BUILD); connect(m_reparseQbs, SIGNAL(triggered()), this, SLOT(reparseCurrentProject())); m_reparseQbsCtx = new QAction(tr("Reparse Qbs"), this); command = Core::ActionManager::registerAction(m_reparseQbsCtx, Constants::ACTION_REPARSE_QBS_CONTEXT, projectContext); command->setAttribute(Core::Command::CA_Hide); mproject->addAction(command, ProjectExplorer::Constants::G_PROJECT_BUILD); connect(m_reparseQbsCtx, SIGNAL(triggered()), this, SLOT(reparseSelectedProject())); m_buildFileCtx = new QAction(tr("Build"), this); command = Core::ActionManager::registerAction(m_buildFileCtx, Constants::ACTION_BUILD_FILE_CONTEXT, projectContext); command->setAttribute(Core::Command::CA_Hide); mfile->addAction(command, ProjectExplorer::Constants::G_FILE_OTHER); connect(m_buildFileCtx, SIGNAL(triggered()), this, SLOT(buildFileContextMenu())); m_buildFile = new Utils::ParameterAction(tr("Build File"), tr("Build File \"%1\""), Utils::ParameterAction::AlwaysEnabled, this); command = Core::ActionManager::registerAction(m_buildFile, Constants::ACTION_BUILD_FILE, globalcontext); command->setAttribute(Core::Command::CA_Hide); command->setAttribute(Core::Command::CA_UpdateText); command->setDescription(m_buildFile->text()); command->setDefaultKeySequence(QKeySequence(tr("Ctrl+Alt+B"))); mbuild->addAction(command, ProjectExplorer::Constants::G_BUILD_BUILD); connect(m_buildFile, SIGNAL(triggered()), this, SLOT(buildFile())); m_buildProductCtx = new QAction(tr("Build"), this); command = Core::ActionManager::registerAction(m_buildProductCtx, Constants::ACTION_BUILD_PRODUCT_CONTEXT, projectContext); command->setAttribute(Core::Command::CA_Hide); msubproject->addAction(command, ProjectExplorer::Constants::G_PROJECT_BUILD); connect(m_buildProductCtx, SIGNAL(triggered()), this, SLOT(buildProductContextMenu())); m_buildProduct = new Utils::ParameterAction(tr("Build Product"), tr("Build Product \"%1\""), Utils::ParameterAction::AlwaysEnabled, this); command = Core::ActionManager::registerAction(m_buildProduct, Constants::ACTION_BUILD_PRODUCT, globalcontext); command->setAttribute(Core::Command::CA_Hide); command->setAttribute(Core::Command::CA_UpdateText); command->setDescription(m_buildFile->text()); command->setDefaultKeySequence(QKeySequence(tr("Ctrl+Alt+Shift+B"))); mbuild->addAction(command, ProjectExplorer::Constants::G_BUILD_BUILD); connect(m_buildProduct, SIGNAL(triggered()), this, SLOT(buildProduct())); m_buildSubprojectCtx = new QAction(tr("Build"), this); command = Core::ActionManager::registerAction(m_buildSubprojectCtx, Constants::ACTION_BUILD_SUBPROJECT_CONTEXT, projectContext); command->setAttribute(Core::Command::CA_Hide); msubproject->addAction(command, ProjectExplorer::Constants::G_PROJECT_BUILD); connect(m_buildSubprojectCtx, SIGNAL(triggered()), this, SLOT(buildSubprojectContextMenu())); m_buildSubproject = new Utils::ParameterAction(tr("Build Subproject"), tr("Build Subproject \"%1\""), Utils::ParameterAction::AlwaysEnabled, this); command = Core::ActionManager::registerAction(m_buildSubproject, Constants::ACTION_BUILD_SUBPROJECT, globalcontext); command->setAttribute(Core::Command::CA_Hide); command->setAttribute(Core::Command::CA_UpdateText); command->setDescription(m_buildFile->text()); command->setDefaultKeySequence(QKeySequence(tr("Ctrl+Shift+B"))); mbuild->addAction(command, ProjectExplorer::Constants::G_BUILD_BUILD); connect(m_buildSubproject, SIGNAL(triggered()), this, SLOT(buildSubproject())); // Connect connect(ProjectTree::instance(), &ProjectTree::currentNodeChanged, this, &QbsProjectManagerPlugin::nodeSelectionChanged); connect(BuildManager::instance(), SIGNAL(buildStateChanged(ProjectExplorer::Project*)), this, SLOT(buildStateChanged(ProjectExplorer::Project*))); connect(Core::EditorManager::instance(), SIGNAL(currentEditorChanged(Core::IEditor*)), this, SLOT(currentEditorChanged())); connect(SessionManager::instance(), SIGNAL(projectAdded(ProjectExplorer::Project*)), this, SLOT(projectWasAdded(ProjectExplorer::Project*))); connect(SessionManager::instance(), SIGNAL(projectRemoved(ProjectExplorer::Project*)), this, SLOT(projectWasRemoved())); connect(SessionManager::instance(), SIGNAL(startupProjectChanged(ProjectExplorer::Project*)), this, SLOT(currentProjectWasChanged(ProjectExplorer::Project*))); // Run initial setup routines updateContextActions(); updateReparseQbsAction(); updateBuildActions(); return true; }
bool CodepasterPlugin::initialize(const QStringList &arguments, QString *error_message) { Q_UNUSED(arguments) Q_UNUSED(error_message) // Create the globalcontext list to register actions accordingly Core::Context globalcontext(Core::Constants::C_GLOBAL); // Create the settings Page m_settings->fromSettings(Core::ICore::instance()->settings()); SettingsPage *settingsPage = new SettingsPage(m_settings); addAutoReleasedObject(settingsPage); // Create the protocols and append them to the Settings const QSharedPointer<NetworkAccessManagerProxy> networkAccessMgrProxy(new NetworkAccessManagerProxy); Protocol *protos[] = { new PasteBinDotComProtocol(networkAccessMgrProxy), new PasteBinDotCaProtocol(networkAccessMgrProxy), new CodePasterProtocol(networkAccessMgrProxy), new FileShareProtocol }; const int count = sizeof(protos) / sizeof(Protocol *); for(int i = 0; i < count; ++i) { connect(protos[i], SIGNAL(pasteDone(QString)), this, SLOT(finishPost(QString))); connect(protos[i], SIGNAL(fetchDone(QString,QString,bool)), this, SLOT(finishFetch(QString,QString,bool))); settingsPage->addProtocol(protos[i]->name()); if (protos[i]->hasSettings()) addAutoReleasedObject(protos[i]->settingsPage()); m_protocols.append(protos[i]); } //register actions Core::ActionManager *actionManager = ICore::instance()->actionManager(); Core::ActionContainer *toolsContainer = actionManager->actionContainer(Core::Constants::M_TOOLS); Core::ActionContainer *cpContainer = actionManager->createMenu(Core::Id("CodePaster")); cpContainer->menu()->setTitle(tr("&Code Pasting")); toolsContainer->addMenu(cpContainer); Core::Command *command; m_postEditorAction = new QAction(tr("Paste Snippet..."), this); command = actionManager->registerAction(m_postEditorAction, "CodePaster.Post", globalcontext); command->setDefaultKeySequence(QKeySequence(tr("Alt+C,Alt+P"))); connect(m_postEditorAction, SIGNAL(triggered()), this, SLOT(postEditor())); cpContainer->addAction(command); m_postClipboardAction = new QAction(tr("Paste Clipboard..."), this); command = actionManager->registerAction(m_postClipboardAction, "CodePaster.PostClipboard", globalcontext); connect(m_postClipboardAction, SIGNAL(triggered()), this, SLOT(postClipboard())); cpContainer->addAction(command); m_fetchAction = new QAction(tr("Fetch Snippet..."), this); command = actionManager->registerAction(m_fetchAction, "CodePaster.Fetch", globalcontext); command->setDefaultKeySequence(QKeySequence(tr("Alt+C,Alt+F"))); connect(m_fetchAction, SIGNAL(triggered()), this, SLOT(fetch())); cpContainer->addAction(command); connect(Core::EditorManager::instance(), SIGNAL(currentEditorChanged(Core::IEditor*)), this, SLOT(updateActions())); updateActions(); return true; }