void createEpisodeToolBar() { _episodeToolBar = new QToolBar(q); _episodeToolBar->setIconSize(QSize(16,16)); QStringList actions; actions << Constants::A_ADDEPISODE << Constants::A_RENEWEPISODE << "--" << Constants::A_REMOVEEPISODE << "--" << Constants::A_VALIDATEEPISODE << "--" << Core::Constants::A_FILE_SAVE << Core::Constants::A_FILE_PRINT << "--" << Constants::A_TAKESCREENSHOT; Core::Command *cmd = 0; foreach(const QString &action, actions) { // Actions are created, managed and connected in the Form::Internal::FormActionHandler // We just need to add the user visible actions in the toolbar if (action=="--") { _episodeToolBar->addSeparator(); continue; } cmd = actionManager()->command(Core::Id(action)); _episodeToolBar->addAction(cmd->action()); } ui->toolbarLayout->addWidget(_episodeToolBar); }
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; }
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. } } }
//////////////////////////////////////////////////// // // 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; }
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())); }
ActionManager::ActionManager(QObject *parent) : QObject(parent), runAction(new QAction(QIcon(":/icons/images/run.png"), tr("Run tests"), this)), waitAction(new QAction(QIcon(":/icons/images/stop.png"), tr("Stop coverage execution"), this)), renderAction(new QAction(QIcon(":/icons/images/render.png"), tr("Show code coverage"), this)) { renderAction->setCheckable(true); // Add action to menu Core::ActionManager *pluginActionManager = Core::ICore::actionManager(); Core::Command *runCommand = pluginActionManager->registerAction(runAction, RUN_ACTION_ID, Core::Context(Core::Constants::C_GLOBAL)); Core::Command *renderCommand = pluginActionManager->registerAction(renderAction, RENDER_ACTION_ID, Core::Context(Core::Constants::C_GLOBAL)); runCommand->setKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_E); renderCommand->setKeySequence(Qt::CTRL + Qt::Key_H); Core::ActionContainer *menu = pluginActionManager->createMenu(MENU_ID); menu->menu()->setTitle(tr("CodeCoverage")); menu->addAction(runCommand); menu->addAction(renderCommand); pluginActionManager->actionContainer(Core::Constants::M_TOOLS)->addMenu(menu); // Add action as icon to left bar Core::ModeManager *modeManager = Core::ModeManager::instance(); modeManager->addAction(runAction, RUN_ACTION_PRIORITY); modeManager->addAction(waitAction, WAIT_ACTION_PRIORITY); }
//////////////////////////////////////////////////// // // 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; }
Core::ActionContainer *FormEditorW::createPreviewStyleMenu(Core::ActionManager *am, QActionGroup *actionGroup) { const QString menuId = QLatin1String(M_FORMEDITOR_PREVIEW); Core::ActionContainer *menuPreviewStyle = am->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(); Core::Command *command = am->registerAction(a, Core::Id(name), m_contexts); bindShortcut(command, a); if (isDeviceProfile) { command->setAttribute(Core::Command::CA_UpdateText); command->setAttribute(Core::Command::CA_NonConfigurable); } menuPreviewStyle->addAction(command); }
/** * 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 DoNothingPlugin::createMenuItems() { // Fetch the action manager Core::ActionManager* am = Core::ICore::instance()->actionManager(); // Create a command for "About DoNothing" Core::Command* cmd = am->registerAction(new QAction(this), "DoNothingPlugin.AboutDoNothingItem", QList<int>() << Core::Constants::C_GLOBAL_ID); cmd->action()->setText("About DoNothing"); // Add the command "Do Nothing" in the beginning of Help menu am->actionContainer(Core::Constants::M_HELP)->addAction(cmd); // Since menu-items are QActions, we can connect to their triggered(bool) or // toggled(bool) signal and respond to trigger/toggled events connect(cmd->action(), SIGNAL(triggered(bool)), this, SLOT(about())); // Create a command for "About DoNothing 2" Core::Command* cmd2 = am->registerAction(new QAction(this), "DoNothingPlugin.AboutDoNothing2Item", QList<int>() << Core::Constants::C_GLOBAL_ID); cmd2->action()->setText("About DoNothing 2"); // Insert the "DoNothing 2" item before "About Plugins..." QMenu* helpMenu = am->actionContainer(Core::Constants::M_HELP)->menu(); QAction* aboutPluginsAction = am->command(Core::Constants::ABOUT_PLUGINS)->action(); helpMenu->insertAction(aboutPluginsAction, cmd2->action()); // Connect the action connect(cmd2->action(), SIGNAL(triggered(bool)), this, SLOT(about())); }
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())); }
CMakeManager::CMakeManager(CMakeSettingsPage *cmakeSettingsPage) : m_settingsPage(cmakeSettingsPage) { ProjectExplorer::ProjectExplorerPlugin *projectExplorer = ProjectExplorer::ProjectExplorerPlugin::instance(); connect(projectExplorer, SIGNAL(aboutToShowContextMenu(ProjectExplorer::Project*,ProjectExplorer::Node*)), this, SLOT(updateContextMenu(ProjectExplorer::Project*,ProjectExplorer::Node*))); Core::ActionContainer *mbuild = Core::ActionManager::actionContainer(ProjectExplorer::Constants::M_BUILDPROJECT); Core::ActionContainer *mproject = Core::ActionManager::actionContainer(ProjectExplorer::Constants::M_PROJECTCONTEXT); Core::ActionContainer *msubproject = Core::ActionManager::actionContainer(ProjectExplorer::Constants::M_SUBPROJECTCONTEXT); const Core::Context projectContext(CMakeProjectManager::Constants::PROJECTCONTEXT); m_runCMakeAction = new QAction(QIcon(), tr("Run CMake"), this); Core::Command *command = Core::ActionManager::registerAction(m_runCMakeAction, Constants::RUNCMAKE, projectContext); command->setAttribute(Core::Command::CA_Hide); mbuild->addAction(command, ProjectExplorer::Constants::G_BUILD_DEPLOY); connect(m_runCMakeAction, SIGNAL(triggered()), this, SLOT(runCMake())); m_runCMakeActionContextMenu = new QAction(QIcon(), tr("Run CMake"), this); command = Core::ActionManager::registerAction(m_runCMakeActionContextMenu, Constants::RUNCMAKECONTEXTMENU, projectContext); command->setAttribute(Core::Command::CA_Hide); mproject->addAction(command, ProjectExplorer::Constants::G_PROJECT_BUILD); msubproject->addAction(command, ProjectExplorer::Constants::G_PROJECT_BUILD); connect(m_runCMakeActionContextMenu, SIGNAL(triggered()), this, SLOT(runCMakeContextMenu())); }
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; }
void ActionHandler::createActions() { Core::ActionContainer *medit = Core::ActionManager::actionContainer(Core::Constants::M_EDIT); d->undoAction = registerCommand(Core::Constants::UNDO, [this]() { undo(); })->action(); d->redoAction = registerCommand(Core::Constants::REDO, [this]() { redo(); })->action(); d->cutAction = registerCommand(Core::Constants::CUT, [this]() { cut(); })->action(); d->copyAction = registerCommand(Core::Constants::COPY, [this]() { copy(); })->action(); d->pasteAction = registerCommand(Core::Constants::PASTE, [this]() { paste(); })->action(); Core::Command *removeCommand = registerCommand( Constants::REMOVE_SELECTED_ELEMENTS, [this]() { removeSelectedElements(); }, true, tr("&Remove"), QKeySequence::Delete); medit->addAction(removeCommand, Core::Constants::G_EDIT_COPYPASTE); d->removeAction = removeCommand->action(); Core::Command *deleteCommand = registerCommand( Constants::DELETE_SELECTED_ELEMENTS, [this]() { deleteSelectedElements(); }, true, tr("&Delete"), QKeySequence(QStringLiteral("Ctrl+D"))); medit->addAction(deleteCommand, Core::Constants::G_EDIT_COPYPASTE); d->deleteAction = deleteCommand->action(); d->selectAllAction = registerCommand(Core::Constants::SELECTALL, [this]() { selectAll(); })->action(); registerCommand(Constants::ACTION_ADD_PACKAGE, nullptr); registerCommand(Constants::ACTION_ADD_COMPONENT, nullptr); registerCommand(Constants::ACTION_ADD_CLASS, nullptr); registerCommand(Constants::ACTION_ADD_CANVAS_DIAGRAM, nullptr); }
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); }
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::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; }
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())); }
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; }
/** \brief Creates actions and toolbar */ void PrescriptionViewer::createActionsAndToolbar() { Core::Command *cmd = 0; // populate toolbar m_ToolBar = new QToolBar(this); int iconSize = settings()->value(Constants::S_TOOLBARICONSIZE).toInt(); if (iconSize < 8) iconSize = 16; m_ToolBar->setIconSize(QSize(iconSize, iconSize)); QStringList actionsToAdd; #ifdef FREEMEDFORMS actionsToAdd << Constants::A_TOGGLE_DRUGSELECTOR << Core::Constants::A_FILE_OPEN << Constants::A_SAVE_PRESCRIPTION << Core::Constants::A_TEMPLATE_CREATE << Core::Constants::A_FILE_PRINTPREVIEW << DrugsWidget::Constants::A_PRINT_PRESCRIPTION; #else actionsToAdd << Core::Constants::A_FILE_OPEN << Core::Constants::A_FILE_SAVE << Core::Constants::A_FILE_SAVEAS << Core::Constants::A_TEMPLATE_CREATE << Core::Constants::A_FILE_PRINTPREVIEW << DrugsWidget::Constants::A_PRINT_PRESCRIPTION; #endif actionsToAdd << "--"; actionsToAdd << DrugsWidget::Constants::A_CLEAR_PRESCRIPTION << Core::Constants::A_LIST_REMOVE << Core::Constants::A_LIST_MOVEDOWN << Core::Constants::A_LIST_MOVEUP << Core::Constants::A_LIST_SORT ; actionsToAdd << "--"; actionsToAdd << DrugsWidget::Constants::A_TOGGLE_TESTINGDRUGS << DrugsWidget::Constants::A_VIEW_INTERACTIONS << DrugsWidget::Constants::A_CHANGE_DURATION << DrugsWidget::Constants::A_TOGGLEDRUGPRECAUTIONS; foreach(const QString &s, actionsToAdd) { if (s=="--") { m_ToolBar->addSeparator(); continue; } cmd = actionManager()->command(Core::Id(s)); if (cmd) m_ToolBar->addAction(cmd->action()); } m_ToolBar->setFocusPolicy(Qt::ClickFocus); }
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 AgendaMode::updateEnableState() { if (!m_UserCalendarModel) return; // Disable the mode if there are no user calendar int nbCals = m_UserCalendarModel->rowCount(); setEnabled(nbCals>0); m_Viewer->setEnabled(nbCals>0); // idem for action mode Core::Command *cmd = actionManager()->command(Agenda::Constants::A_NEW_AGENDAEVENT); cmd->action()->setEnabled(nbCals>0); }
OutputPane::OutputPane() : m_mainWidget(new QWidget) { QIcon runIcon(Constants::ICON_RUN); runIcon.addFile(Constants::ICON_RUN_SMALL); // Rerun m_reRunButton = new QToolButton; m_reRunButton->setIcon(runIcon); m_reRunButton->setToolTip(tr("Re-run this run-configuration")); m_reRunButton->setAutoRaise(true); m_reRunButton->setEnabled(false); connect(m_reRunButton, SIGNAL(clicked()), this, SLOT(reRunRunControl())); // Stop Core::ActionManager *am = Core::ICore::instance()->actionManager(); QList<int> globalcontext; globalcontext.append(Core::Constants::C_GLOBAL_ID); m_stopAction = new QAction(QIcon(Constants::ICON_STOP), tr("Stop"), this); m_stopAction->setToolTip(tr("Stop")); m_stopAction->setEnabled(false); Core::Command *cmd = am->registerAction(m_stopAction, Constants::STOP, globalcontext); m_stopButton = new QToolButton; m_stopButton->setDefaultAction(cmd->action()); m_stopButton->setAutoRaise(true); connect(m_stopAction, SIGNAL(triggered()), this, SLOT(stopRunControl())); // Spacer (?) QVBoxLayout *layout = new QVBoxLayout; layout->setMargin(0); m_tabWidget = new QTabWidget; m_tabWidget->setDocumentMode(true); m_tabWidget->setTabsClosable(true); m_tabWidget->setMovable(true); connect(m_tabWidget, SIGNAL(tabCloseRequested(int)), this, SLOT(closeTab(int))); layout->addWidget(m_tabWidget); connect(m_tabWidget, SIGNAL(currentChanged(int)), this, SLOT(tabChanged(int))); m_mainWidget->setLayout(layout); connect(Core::ICore::instance(), SIGNAL(coreAboutToClose()), this, SLOT(coreAboutToClose())); }
// Create a parameter action ParameterActionCommandPair GitPlugin::createParameterAction(Core::ActionManager *am, Core::ActionContainer *ac, const QString &defaultText, const QString ¶meterText, const QString &id, const Core::Context &context, bool addToLocator) { Utils::ParameterAction *action = new Utils::ParameterAction(defaultText, parameterText, Utils::ParameterAction::EnabledWithParameter, this); Core::Command *command = am->registerAction(action, id, context); command->setAttribute(Core::Command::CA_UpdateText); ac->addAction(command); if (addToLocator) m_commandLocator->appendCommand(command); return ParameterActionCommandPair(action, command); }
QToolBar * DesignNetFormManager::createEditorToolBar() const { QToolBar *editorToolBar = new QToolBar; const QList<Core::Id>::const_iterator cend = d->m_toolActionIds.constEnd(); for (QList<Core::Id>::const_iterator it = d->m_toolActionIds.constBegin(); it != cend; ++it) { Core::Command *cmd = Core::ActionManager::instance()->command(*it); QAction *action = cmd->action(); if (!action->icon().isNull()) editorToolBar->addAction(action); } const int size = editorToolBar->style()->pixelMetric(QStyle::PM_SmallIconSize); editorToolBar->setIconSize(QSize(size, size)); editorToolBar->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding); return editorToolBar; }