forked from qt-creator/qt-creator
Core: Return *this from ActionBuilder settings
Useful to chain operations and avoid the repetitive local variable name. Change-Id: I4327dbb90d97cbeed370b311c3ade7925ddada0b Reviewed-by: Orgad Shaneh <orgads@gmail.com>
This commit is contained in:
@@ -54,82 +54,76 @@ CMakeManager::CMakeManager()
|
|||||||
|
|
||||||
const Context projectContext(CMakeProjectManager::Constants::CMAKE_PROJECT_ID);
|
const Context projectContext(CMakeProjectManager::Constants::CMAKE_PROJECT_ID);
|
||||||
|
|
||||||
ActionBuilder runCMakeAction(this, Constants::RUN_CMAKE);
|
ActionBuilder(this, Constants::RUN_CMAKE)
|
||||||
runCMakeAction.setText(Tr::tr("Run CMake"));
|
.setText(Tr::tr("Run CMake"))
|
||||||
runCMakeAction.setIcon(ProjectExplorer::Icons::CMAKE_LOGO.icon());
|
.setIcon(ProjectExplorer::Icons::CMAKE_LOGO.icon())
|
||||||
runCMakeAction.bindContextAction(&m_runCMakeAction);
|
.bindContextAction(&m_runCMakeAction)
|
||||||
runCMakeAction.setCommandAttribute(Command::CA_Hide);
|
.setCommandAttribute(Command::CA_Hide)
|
||||||
runCMakeAction.addToContainer(PEC::M_BUILDPROJECT, PEC::G_BUILD_BUILD);
|
.addToContainer(PEC::M_BUILDPROJECT, PEC::G_BUILD_BUILD)
|
||||||
runCMakeAction.addOnTriggered(this, [this] { runCMake(ProjectManager::startupBuildSystem()); });
|
.addOnTriggered(this, [this] { runCMake(ProjectManager::startupBuildSystem()); });
|
||||||
|
|
||||||
ActionBuilder clearCMakeCacheAction(this, Constants::CLEAR_CMAKE_CACHE);
|
ActionBuilder(this, Constants::CLEAR_CMAKE_CACHE)
|
||||||
clearCMakeCacheAction.setText(Tr::tr("Clear CMake Configuration"));
|
.setText(Tr::tr("Clear CMake Configuration"))
|
||||||
clearCMakeCacheAction.bindContextAction(&m_clearCMakeCacheAction);
|
.bindContextAction(&m_clearCMakeCacheAction)
|
||||||
clearCMakeCacheAction.setCommandAttribute(Command::CA_Hide);
|
.setCommandAttribute(Command::CA_Hide)
|
||||||
clearCMakeCacheAction.addToContainer(PEC::M_BUILDPROJECT, PEC::G_BUILD_BUILD);
|
.addToContainer(PEC::M_BUILDPROJECT, PEC::G_BUILD_BUILD)
|
||||||
clearCMakeCacheAction.addOnTriggered(this, [this] {
|
.addOnTriggered(this, [this] { clearCMakeCache(ProjectManager::startupBuildSystem()); });
|
||||||
clearCMakeCache(ProjectManager::startupBuildSystem());
|
|
||||||
});
|
|
||||||
|
|
||||||
ActionBuilder runCMakeActionContextMenu(this, Constants::RUN_CMAKE_CONTEXT_MENU);
|
ActionBuilder(this, Constants::RUN_CMAKE_CONTEXT_MENU)
|
||||||
runCMakeActionContextMenu.setText(Tr::tr("Run CMake"));
|
.setText(Tr::tr("Run CMake"))
|
||||||
runCMakeActionContextMenu.setIcon(ProjectExplorer::Icons::CMAKE_LOGO.icon());
|
.setIcon(ProjectExplorer::Icons::CMAKE_LOGO.icon())
|
||||||
runCMakeActionContextMenu.setContext(projectContext);
|
.setContext(projectContext)
|
||||||
runCMakeActionContextMenu.bindContextAction(&m_runCMakeActionContextMenu);
|
.bindContextAction(&m_runCMakeActionContextMenu)
|
||||||
runCMakeActionContextMenu.setCommandAttribute(Command::CA_Hide);
|
.setCommandAttribute(Command::CA_Hide)
|
||||||
runCMakeActionContextMenu.addToContainer(PEC::M_PROJECTCONTEXT, PEC::G_PROJECT_BUILD);
|
.addToContainer(PEC::M_PROJECTCONTEXT, PEC::G_PROJECT_BUILD)
|
||||||
runCMakeActionContextMenu.addOnTriggered(this, [this] {
|
.addOnTriggered(this, [this] { runCMake(ProjectTree::currentBuildSystem()); });
|
||||||
runCMake(ProjectTree::currentBuildSystem());
|
|
||||||
});
|
|
||||||
|
|
||||||
ActionBuilder buildFileContextAction(this, Constants::BUILD_FILE_CONTEXT_MENU);
|
ActionBuilder(this, Constants::BUILD_FILE_CONTEXT_MENU)
|
||||||
buildFileContextAction.setText(Tr::tr("Build"));
|
.setText(Tr::tr("Build"))
|
||||||
buildFileContextAction.bindContextAction(&m_buildFileContextMenu);
|
.bindContextAction(&m_buildFileContextMenu)
|
||||||
buildFileContextAction.setContext(projectContext);
|
.setContext(projectContext)
|
||||||
buildFileContextAction.setCommandAttribute(Command::CA_Hide);
|
.setCommandAttribute(Command::CA_Hide)
|
||||||
buildFileContextAction.addToContainer(PEC::M_FILECONTEXT, PEC::G_FILE_OTHER);
|
.addToContainer(PEC::M_FILECONTEXT, PEC::G_FILE_OTHER)
|
||||||
buildFileContextAction.addOnTriggered(this, [this] { buildFileContextMenu(); });
|
.addOnTriggered(this, [this] { buildFileContextMenu(); });
|
||||||
|
|
||||||
ActionBuilder rescanProjectAction(this, Constants::RESCAN_PROJECT);
|
ActionBuilder(this, Constants::RESCAN_PROJECT)
|
||||||
rescanProjectAction.setText(Tr::tr("Rescan Project"));
|
.setText(Tr::tr("Rescan Project"))
|
||||||
rescanProjectAction.bindContextAction(&m_rescanProjectAction);
|
.bindContextAction(&m_rescanProjectAction)
|
||||||
rescanProjectAction.setCommandAttribute(Command::CA_Hide);
|
.setCommandAttribute(Command::CA_Hide)
|
||||||
rescanProjectAction.addToContainer(PEC::M_BUILDPROJECT, PEC::G_BUILD_BUILD);
|
.addToContainer(PEC::M_BUILDPROJECT, PEC::G_BUILD_BUILD)
|
||||||
rescanProjectAction.addOnTriggered(this, [this] {
|
.addOnTriggered(this, [this] { rescanProject(ProjectTree::currentBuildSystem()); });
|
||||||
rescanProject(ProjectTree::currentBuildSystem());
|
|
||||||
});
|
|
||||||
|
|
||||||
ActionBuilder reloadCMakePresetsAction(this, Constants::RELOAD_CMAKE_PRESETS);
|
ActionBuilder(this, Constants::RELOAD_CMAKE_PRESETS)
|
||||||
reloadCMakePresetsAction.setText(Tr::tr("Reload CMake Presets"));
|
.setText(Tr::tr("Reload CMake Presets"))
|
||||||
reloadCMakePresetsAction.setIcon(Utils::Icons::RELOAD.icon());
|
.setIcon(Utils::Icons::RELOAD.icon())
|
||||||
reloadCMakePresetsAction.bindContextAction(&m_reloadCMakePresetsAction);
|
.bindContextAction(&m_reloadCMakePresetsAction)
|
||||||
reloadCMakePresetsAction.setCommandAttribute(Command::CA_Hide);
|
.setCommandAttribute(Command::CA_Hide)
|
||||||
reloadCMakePresetsAction.addToContainer(PEC::M_BUILDPROJECT, PEC::G_BUILD_BUILD);
|
.addToContainer(PEC::M_BUILDPROJECT, PEC::G_BUILD_BUILD)
|
||||||
reloadCMakePresetsAction.addOnTriggered(this, [this] { reloadCMakePresets(); });
|
.addOnTriggered(this, [this] { reloadCMakePresets(); });
|
||||||
|
|
||||||
ActionBuilder buildFileAction(this, Constants::BUILD_FILE);
|
ActionBuilder(this, Constants::BUILD_FILE)
|
||||||
buildFileAction.setParameterText(Tr::tr("Build File \"%1\""), Tr::tr("Build File"),
|
.setParameterText(Tr::tr("Build File \"%1\""), Tr::tr("Build File"),
|
||||||
ActionBuilder::AlwaysEnabled);
|
ActionBuilder::AlwaysEnabled)
|
||||||
buildFileAction.bindContextAction(&m_buildFileAction);
|
.bindContextAction(&m_buildFileAction)
|
||||||
buildFileAction.setCommandAttribute(Command::CA_Hide);
|
.setCommandAttribute(Command::CA_Hide)
|
||||||
buildFileAction.setCommandAttribute(Command::CA_UpdateText);
|
.setCommandAttribute(Command::CA_UpdateText)
|
||||||
buildFileAction.setCommandDescription(m_buildFileAction->text());
|
.setCommandDescription(m_buildFileAction->text())
|
||||||
buildFileAction.setDefaultKeySequence(Tr::tr("Ctrl+Alt+B"));
|
.setDefaultKeySequence(Tr::tr("Ctrl+Alt+B"))
|
||||||
buildFileAction.addToContainer(PEC::M_BUILDPROJECT, PEC::G_BUILD_BUILD);
|
.addToContainer(PEC::M_BUILDPROJECT, PEC::G_BUILD_BUILD)
|
||||||
buildFileAction.addOnTriggered(this, [this] { buildFile(); });
|
.addOnTriggered(this, [this] { buildFile(); });
|
||||||
|
|
||||||
// CMake Profiler
|
// CMake Profiler
|
||||||
ActionBuilder cmakeProfilerAction(this, Constants::RUN_CMAKE_PROFILER);
|
ActionBuilder(this, Constants::RUN_CMAKE_PROFILER)
|
||||||
cmakeProfilerAction.setIcon(ProjectExplorer::Icons::CMAKE_LOGO.icon());
|
.setIcon(ProjectExplorer::Icons::CMAKE_LOGO.icon())
|
||||||
cmakeProfilerAction.setText(Tr::tr("CMake Profiler"));
|
.setText(Tr::tr("CMake Profiler"))
|
||||||
cmakeProfilerAction.bindContextAction(&m_cmakeProfilerAction);
|
.bindContextAction(&m_cmakeProfilerAction)
|
||||||
cmakeProfilerAction.setCommandDescription(m_cmakeProfilerAction->text());
|
.setCommandDescription(m_cmakeProfilerAction->text())
|
||||||
cmakeProfilerAction.addToContainer(Debugger::Constants::M_DEBUG_ANALYZER,
|
.addToContainer(Debugger::Constants::M_DEBUG_ANALYZER,
|
||||||
Debugger::Constants::G_ANALYZER_TOOLS,
|
Debugger::Constants::G_ANALYZER_TOOLS,
|
||||||
false);
|
false)
|
||||||
cmakeProfilerAction.addOnTriggered(this, [this] {
|
.addOnTriggered(this, [this] {
|
||||||
runCMakeWithProfiling(ProjectManager::startupBuildSystem());
|
runCMakeWithProfiling(ProjectManager::startupBuildSystem());
|
||||||
});
|
});
|
||||||
|
|
||||||
// CMake Debugger
|
// CMake Debugger
|
||||||
ActionContainer *mdebugger = ActionManager::actionContainer(PEC::M_DEBUG_STARTDEBUGGING);
|
ActionContainer *mdebugger = ActionManager::actionContainer(PEC::M_DEBUG_STARTDEBUGGING);
|
||||||
@@ -138,16 +132,16 @@ CMakeManager::CMakeManager()
|
|||||||
Constants::CMAKE_DEBUGGING_GROUP,
|
Constants::CMAKE_DEBUGGING_GROUP,
|
||||||
&m_cmakeDebuggerSeparator);
|
&m_cmakeDebuggerSeparator);
|
||||||
|
|
||||||
ActionBuilder cmakeDebuggerAction(this, Constants::RUN_CMAKE_DEBUGGER);
|
ActionBuilder(this, Constants::RUN_CMAKE_DEBUGGER)
|
||||||
cmakeDebuggerAction.setText(Tr::tr("Start CMake Debugging"));
|
.setText(Tr::tr("Start CMake Debugging"))
|
||||||
cmakeDebuggerAction.setIcon(ProjectExplorer::Icons::CMAKE_LOGO.icon());
|
.setIcon(ProjectExplorer::Icons::CMAKE_LOGO.icon())
|
||||||
cmakeDebuggerAction.bindContextAction(&m_cmakeDebuggerAction);
|
.bindContextAction(&m_cmakeDebuggerAction)
|
||||||
cmakeDebuggerAction.setCommandDescription(m_cmakeDebuggerAction->text());
|
.setCommandDescription(m_cmakeDebuggerAction->text())
|
||||||
cmakeDebuggerAction.addToContainer(PEC::M_DEBUG_STARTDEBUGGING, Constants::CMAKE_DEBUGGING_GROUP);
|
.addToContainer(PEC::M_DEBUG_STARTDEBUGGING, Constants::CMAKE_DEBUGGING_GROUP)
|
||||||
cmakeDebuggerAction.addOnTriggered(this, [] {
|
.addOnTriggered(this, [] {
|
||||||
ProjectExplorerPlugin::runStartupProject(PEC::DAP_CMAKE_DEBUG_RUN_MODE,
|
ProjectExplorerPlugin::runStartupProject(PEC::DAP_CMAKE_DEBUG_RUN_MODE,
|
||||||
/*forceSkipDeploy=*/true);
|
/*forceSkipDeploy=*/true);
|
||||||
});
|
});
|
||||||
|
|
||||||
connect(ProjectManager::instance(), &ProjectManager::startupProjectChanged, this, [this] {
|
connect(ProjectManager::instance(), &ProjectManager::startupProjectChanged, this, [this] {
|
||||||
auto cmakeBuildSystem = qobject_cast<CMakeBuildSystem *>(
|
auto cmakeBuildSystem = qobject_cast<CMakeBuildSystem *>(
|
||||||
|
@@ -106,123 +106,145 @@ ActionBuilder::~ActionBuilder()
|
|||||||
delete d;
|
delete d;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ActionBuilder::setText(const QString &text)
|
ActionBuilder &ActionBuilder::setText(const QString &text)
|
||||||
{
|
{
|
||||||
d->contextAction->setText(text);
|
d->contextAction->setText(text);
|
||||||
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ActionBuilder::setIconText(const QString &text)
|
ActionBuilder &ActionBuilder::setIconText(const QString &text)
|
||||||
{
|
{
|
||||||
d->contextAction->setIconText(text);
|
d->contextAction->setIconText(text);
|
||||||
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ActionBuilder::setToolTip(const QString &toolTip)
|
ActionBuilder &ActionBuilder::setToolTip(const QString &toolTip)
|
||||||
{
|
{
|
||||||
d->contextAction->setToolTip(toolTip);
|
d->contextAction->setToolTip(toolTip);
|
||||||
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ActionBuilder::setCommandAttribute(Command::CommandAttribute attr)
|
ActionBuilder &ActionBuilder::setCommandAttribute(Command::CommandAttribute attr)
|
||||||
{
|
{
|
||||||
d->command->setAttribute(attr);
|
d->command->setAttribute(attr);
|
||||||
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ActionBuilder::setCommandDescription(const QString &desc)
|
ActionBuilder &ActionBuilder::setCommandDescription(const QString &desc)
|
||||||
{
|
{
|
||||||
d->command->setDescription(desc);
|
d->command->setDescription(desc);
|
||||||
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ActionBuilder::addToContainer(Id containerId, Id groupId, bool needsToExist)
|
ActionBuilder &ActionBuilder::addToContainer(Id containerId, Id groupId, bool needsToExist)
|
||||||
{
|
{
|
||||||
QTC_ASSERT(containerId.isValid(), return);
|
QTC_ASSERT(containerId.isValid(), return *this);
|
||||||
if (ActionContainer *container = ActionManager::actionContainer(containerId)) {
|
if (ActionContainer *container = ActionManager::actionContainer(containerId)) {
|
||||||
container->addAction(d->command, groupId);
|
container->addAction(d->command, groupId);
|
||||||
return;
|
return *this;
|
||||||
}
|
}
|
||||||
QTC_CHECK(!needsToExist);
|
QTC_CHECK(!needsToExist);
|
||||||
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ActionBuilder::addToContainers(QList<Id> containerIds, Id groupId, bool needsToExist)
|
ActionBuilder &ActionBuilder::addToContainers(QList<Id> containerIds, Id groupId, bool needsToExist)
|
||||||
{
|
{
|
||||||
for (const Id &containerId : containerIds)
|
for (const Id &containerId : containerIds)
|
||||||
addToContainer(containerId, groupId, needsToExist);
|
addToContainer(containerId, groupId, needsToExist);
|
||||||
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ActionBuilder::addOnTriggered(const std::function<void ()> &func)
|
ActionBuilder &ActionBuilder::addOnTriggered(const std::function<void()> &func)
|
||||||
{
|
{
|
||||||
QObject::connect(d->contextAction, &QAction::triggered, d->contextAction, func);
|
QObject::connect(d->contextAction, &QAction::triggered, d->contextAction, func);
|
||||||
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ActionBuilder::setDefaultKeySequence(const QKeySequence &seq)
|
ActionBuilder &ActionBuilder::setDefaultKeySequence(const QKeySequence &seq)
|
||||||
{
|
{
|
||||||
d->command->setDefaultKeySequence(seq);
|
d->command->setDefaultKeySequence(seq);
|
||||||
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ActionBuilder::setDefaultKeySequences(const QList<QKeySequence> &seqs)
|
ActionBuilder &ActionBuilder::setDefaultKeySequences(const QList<QKeySequence> &seqs)
|
||||||
{
|
{
|
||||||
d->command->setDefaultKeySequences(seqs);
|
d->command->setDefaultKeySequences(seqs);
|
||||||
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ActionBuilder::setDefaultKeySequence(const QString &mac, const QString &nonMac)
|
ActionBuilder &ActionBuilder::setDefaultKeySequence(const QString &mac, const QString &nonMac)
|
||||||
{
|
{
|
||||||
d->command->setDefaultKeySequence(QKeySequence(useMacShortcuts ? mac : nonMac));
|
d->command->setDefaultKeySequence(QKeySequence(useMacShortcuts ? mac : nonMac));
|
||||||
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ActionBuilder::setIcon(const QIcon &icon)
|
ActionBuilder &ActionBuilder::setIcon(const QIcon &icon)
|
||||||
{
|
{
|
||||||
d->contextAction->setIcon(icon);
|
d->contextAction->setIcon(icon);
|
||||||
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ActionBuilder::setIconVisibleInMenu(bool on)
|
ActionBuilder &ActionBuilder::setIconVisibleInMenu(bool on)
|
||||||
{
|
{
|
||||||
d->contextAction->setIconVisibleInMenu(on);
|
d->contextAction->setIconVisibleInMenu(on);
|
||||||
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ActionBuilder::setTouchBarIcon(const QIcon &icon)
|
ActionBuilder &ActionBuilder::setTouchBarIcon(const QIcon &icon)
|
||||||
{
|
{
|
||||||
d->command->setTouchBarIcon(icon);
|
d->command->setTouchBarIcon(icon);
|
||||||
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ActionBuilder::setTouchBarText(const QString &text)
|
ActionBuilder &ActionBuilder::setTouchBarText(const QString &text)
|
||||||
{
|
{
|
||||||
d->command->setTouchBarText(text);
|
d->command->setTouchBarText(text);
|
||||||
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ActionBuilder::setEnabled(bool on)
|
ActionBuilder &ActionBuilder::setEnabled(bool on)
|
||||||
{
|
{
|
||||||
d->contextAction->setEnabled(on);
|
d->contextAction->setEnabled(on);
|
||||||
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ActionBuilder::setChecked(bool on)
|
ActionBuilder &ActionBuilder::setChecked(bool on)
|
||||||
{
|
{
|
||||||
d->contextAction->setChecked(on);
|
d->contextAction->setChecked(on);
|
||||||
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ActionBuilder::setVisible(bool on)
|
ActionBuilder &ActionBuilder::setVisible(bool on)
|
||||||
{
|
{
|
||||||
d->contextAction->setVisible(on);
|
d->contextAction->setVisible(on);
|
||||||
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ActionBuilder::setCheckable(bool on)
|
ActionBuilder &ActionBuilder::setCheckable(bool on)
|
||||||
{
|
{
|
||||||
d->contextAction->setCheckable(on);
|
d->contextAction->setCheckable(on);
|
||||||
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ActionBuilder::setSeperator(bool on)
|
ActionBuilder &ActionBuilder::setSeperator(bool on)
|
||||||
{
|
{
|
||||||
d->contextAction->setSeparator(on);
|
d->contextAction->setSeparator(on);
|
||||||
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ActionBuilder::setScriptable(bool on)
|
ActionBuilder &ActionBuilder::setScriptable(bool on)
|
||||||
{
|
{
|
||||||
d->scriptable = on;
|
d->scriptable = on;
|
||||||
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ActionBuilder::setMenuRole(QAction::MenuRole role)
|
ActionBuilder &ActionBuilder::setMenuRole(QAction::MenuRole role)
|
||||||
{
|
{
|
||||||
d->contextAction->setMenuRole(role);
|
d->contextAction->setMenuRole(role);
|
||||||
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ActionBuilder::setParameterText(const QString ¶meterText,
|
ActionBuilder &ActionBuilder::setParameterText(const QString ¶meterText,
|
||||||
const QString &emptyText,
|
const QString &emptyText,
|
||||||
EnablingMode mode)
|
EnablingMode mode)
|
||||||
{
|
{
|
||||||
@@ -235,6 +257,7 @@ void ActionBuilder::setParameterText(const QString ¶meterText,
|
|||||||
? ParameterAction::AlwaysEnabled
|
? ParameterAction::AlwaysEnabled
|
||||||
: ParameterAction::EnabledWithParameter);
|
: ParameterAction::EnabledWithParameter);
|
||||||
d->contextAction->setText(emptyText);
|
d->contextAction->setText(emptyText);
|
||||||
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
Id ActionBuilder::id() const
|
Id ActionBuilder::id() const
|
||||||
@@ -262,32 +285,37 @@ ParameterAction *ActionBuilder::contextParameterAction() const
|
|||||||
return d->contextAction;
|
return d->contextAction;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ActionBuilder::bindContextAction(QAction **dest)
|
ActionBuilder &ActionBuilder::bindContextAction(QAction **dest)
|
||||||
{
|
{
|
||||||
QTC_ASSERT(dest, return);
|
QTC_ASSERT(dest, return *this);
|
||||||
*dest = d->contextAction;
|
*dest = d->contextAction;
|
||||||
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ActionBuilder::bindContextAction(Utils::ParameterAction **dest)
|
ActionBuilder &ActionBuilder::bindContextAction(Utils::ParameterAction **dest)
|
||||||
{
|
{
|
||||||
QTC_ASSERT(dest, return);
|
QTC_ASSERT(dest, return *this);
|
||||||
*dest = d->contextAction;
|
*dest = d->contextAction;
|
||||||
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ActionBuilder::augmentActionWithShortcutToolTip()
|
ActionBuilder &ActionBuilder::augmentActionWithShortcutToolTip()
|
||||||
{
|
{
|
||||||
d->command->augmentActionWithShortcutToolTip(d->contextAction);
|
d->command->augmentActionWithShortcutToolTip(d->contextAction);
|
||||||
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ActionBuilder::setContext(Id id)
|
ActionBuilder &ActionBuilder::setContext(Id id)
|
||||||
{
|
{
|
||||||
d->context = Context(id);
|
d->context = Context(id);
|
||||||
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ActionBuilder::setContext(const Context &context)
|
ActionBuilder &ActionBuilder::setContext(const Context &context)
|
||||||
{
|
{
|
||||||
QTC_ASSERT(!context.isEmpty(), return);
|
QTC_ASSERT(!context.isEmpty(), return *this);
|
||||||
d->context = context;
|
d->context = context;
|
||||||
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Separator
|
// Separator
|
||||||
|
@@ -31,20 +31,20 @@ public:
|
|||||||
ActionBuilder(QObject *contextActionParent, const Utils::Id actionId);
|
ActionBuilder(QObject *contextActionParent, const Utils::Id actionId);
|
||||||
~ActionBuilder();
|
~ActionBuilder();
|
||||||
|
|
||||||
void setContext(const Utils::Id id);
|
ActionBuilder &setContext(const Utils::Id id);
|
||||||
void setContext(const Core::Context &context);
|
ActionBuilder &setContext(const Core::Context &context);
|
||||||
void setText(const QString &text);
|
ActionBuilder &setText(const QString &text);
|
||||||
void setIconText(const QString &text);
|
ActionBuilder &setIconText(const QString &text);
|
||||||
void setToolTip(const QString &toolTip);
|
ActionBuilder &setToolTip(const QString &toolTip);
|
||||||
void setCommandAttribute(Core::Command::CommandAttribute attr);
|
ActionBuilder &setCommandAttribute(Core::Command::CommandAttribute attr);
|
||||||
void setCommandDescription(const QString &desc);
|
ActionBuilder &setCommandDescription(const QString &desc);
|
||||||
void addToContainer(Utils::Id containerId, Utils::Id groupId = {}, bool needsToExist = true);
|
ActionBuilder &addToContainer(Utils::Id containerId, Utils::Id groupId = {}, bool needsToExist = true);
|
||||||
void addToContainers(QList<Utils::Id> containerIds, Utils::Id groupId = {},
|
ActionBuilder &addToContainers(QList<Utils::Id> containerIds, Utils::Id groupId = {},
|
||||||
bool needsToExist = true);
|
bool needsToExist = true);
|
||||||
void addOnTriggered(const std::function<void()> &func);
|
ActionBuilder &addOnTriggered(const std::function<void()> &func);
|
||||||
|
|
||||||
template<class T, typename F>
|
template<class T, typename F>
|
||||||
void addOnTriggered(T *guard,
|
ActionBuilder &addOnTriggered(T *guard,
|
||||||
F &&function,
|
F &&function,
|
||||||
Qt::ConnectionType connectionType = Qt::AutoConnection)
|
Qt::ConnectionType connectionType = Qt::AutoConnection)
|
||||||
{
|
{
|
||||||
@@ -53,10 +53,11 @@ public:
|
|||||||
guard,
|
guard,
|
||||||
std::forward<F>(function),
|
std::forward<F>(function),
|
||||||
connectionType);
|
connectionType);
|
||||||
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class T, typename F>
|
template<class T, typename F>
|
||||||
void addOnToggled(T *guard,
|
ActionBuilder &addOnToggled(T *guard,
|
||||||
F &&function,
|
F &&function,
|
||||||
Qt::ConnectionType connectionType = Qt::AutoConnection)
|
Qt::ConnectionType connectionType = Qt::AutoConnection)
|
||||||
{
|
{
|
||||||
@@ -65,37 +66,38 @@ public:
|
|||||||
guard,
|
guard,
|
||||||
std::forward<F>(function),
|
std::forward<F>(function),
|
||||||
connectionType);
|
connectionType);
|
||||||
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setDefaultKeySequence(const QKeySequence &seq);
|
ActionBuilder &setDefaultKeySequence(const QKeySequence &seq);
|
||||||
void setDefaultKeySequences(const QList<QKeySequence> &seqs);
|
ActionBuilder &setDefaultKeySequences(const QList<QKeySequence> &seqs);
|
||||||
void setDefaultKeySequence(const QString &mac, const QString &nonMac);
|
ActionBuilder &setDefaultKeySequence(const QString &mac, const QString &nonMac);
|
||||||
void setIcon(const QIcon &icon);
|
ActionBuilder &setIcon(const QIcon &icon);
|
||||||
void setIconVisibleInMenu(bool on);
|
ActionBuilder &setIconVisibleInMenu(bool on);
|
||||||
void setTouchBarIcon(const QIcon &icon);
|
ActionBuilder &setTouchBarIcon(const QIcon &icon);
|
||||||
void setTouchBarText(const QString &text);
|
ActionBuilder &setTouchBarText(const QString &text);
|
||||||
void setEnabled(bool on);
|
ActionBuilder &setEnabled(bool on);
|
||||||
void setChecked(bool on);
|
ActionBuilder &setChecked(bool on);
|
||||||
void setVisible(bool on);
|
ActionBuilder &setVisible(bool on);
|
||||||
void setCheckable(bool on);
|
ActionBuilder &setCheckable(bool on);
|
||||||
void setSeperator(bool on);
|
ActionBuilder &setSeperator(bool on);
|
||||||
void setScriptable(bool on);
|
ActionBuilder &setScriptable(bool on);
|
||||||
void setMenuRole(QAction::MenuRole role);
|
ActionBuilder &setMenuRole(QAction::MenuRole role);
|
||||||
|
|
||||||
enum EnablingMode { AlwaysEnabled, EnabledWithParameter };
|
enum EnablingMode { AlwaysEnabled, EnabledWithParameter };
|
||||||
void setParameterText(const QString ¶metrizedText,
|
ActionBuilder &setParameterText(const QString ¶metrizedText,
|
||||||
const QString &emptyText,
|
const QString &emptyText,
|
||||||
EnablingMode mode = EnabledWithParameter);
|
EnablingMode mode = EnabledWithParameter);
|
||||||
|
|
||||||
|
ActionBuilder &bindContextAction(QAction **dest);
|
||||||
|
ActionBuilder &bindContextAction(Utils::ParameterAction **dest);
|
||||||
|
ActionBuilder &augmentActionWithShortcutToolTip();
|
||||||
|
|
||||||
Utils::Id id() const;
|
Utils::Id id() const;
|
||||||
Command *command() const;
|
Command *command() const;
|
||||||
QAction *commandAction() const;
|
QAction *commandAction() const;
|
||||||
QAction *contextAction() const;
|
QAction *contextAction() const;
|
||||||
Utils::ParameterAction *contextParameterAction() const;
|
Utils::ParameterAction *contextParameterAction() const;
|
||||||
void bindContextAction(QAction **dest);
|
|
||||||
void bindContextAction(Utils::ParameterAction **dest);
|
|
||||||
void augmentActionWithShortcutToolTip();
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
class ActionBuilderPrivate *d = nullptr;
|
class ActionBuilderPrivate *d = nullptr;
|
||||||
|
Reference in New Issue
Block a user