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