本文整理汇总了C++中core::Command类的典型用法代码示例。如果您正苦于以下问题:C++ Command类的具体用法?C++ Command怎么用?C++ Command使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Command类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: createEpisodeToolBar
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);
}
示例2: connect
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;
}
示例3: polishActions
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.
}
}
}
示例4: initialize
////////////////////////////////////////////////////
//
// 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;
}
示例5: setupFilterMenuItems
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()));
}
示例6: QObject
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);
}
示例7: initialize
////////////////////////////////////////////////////
//
// 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;
}
示例8: foreach
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);
}
示例9: initialize
/**
* 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;
}
示例10: initialize
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;
}
示例11: createMenuItems
void DoNothingPlugin::createMenuItems()
{
// Fetch the action manager
Core::ActionManager* am = Core::ICore::instance()->actionManager();
// Create a command for "About DoNothing"
Core::Command* cmd = am->registerAction(new QAction(this), "DoNothingPlugin.AboutDoNothingItem", QList<int>() << Core::Constants::C_GLOBAL_ID);
cmd->action()->setText("About DoNothing");
// Add the command "Do Nothing" in the beginning of Help menu
am->actionContainer(Core::Constants::M_HELP)->addAction(cmd);
// Since menu-items are QActions, we can connect to their triggered(bool) or
// toggled(bool) signal and respond to trigger/toggled events
connect(cmd->action(), SIGNAL(triggered(bool)), this, SLOT(about()));
// Create a command for "About DoNothing 2"
Core::Command* cmd2 = am->registerAction(new QAction(this), "DoNothingPlugin.AboutDoNothing2Item", QList<int>() << Core::Constants::C_GLOBAL_ID);
cmd2->action()->setText("About DoNothing 2");
// Insert the "DoNothing 2" item before "About Plugins..."
QMenu* helpMenu = am->actionContainer(Core::Constants::M_HELP)->menu();
QAction* aboutPluginsAction = am->command(Core::Constants::ABOUT_PLUGINS)->action();
helpMenu->insertAction(aboutPluginsAction, cmd2->action());
// Connect the action
connect(cmd2->action(), SIGNAL(triggered(bool)), this, SLOT(about()));
}
示例12: setupMenu
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()));
}
示例13: connect
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()));
}
示例14: initialize
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;
}
示例15: createActions
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);
}