diff --git a/src/libs/utils/proxyaction.cpp b/src/libs/utils/proxyaction.cpp index 977ea983548..25acdb7b63c 100644 --- a/src/libs/utils/proxyaction.cpp +++ b/src/libs/utils/proxyaction.cpp @@ -60,6 +60,12 @@ QAction *ProxyAction::action() const return m_action; } +void ProxyAction::setAttributes(ProxyAction::Attributes attributes) +{ + m_attributes = attributes; + updateState(); +} + void ProxyAction::setAttribute(ProxyAction::Attribute attribute) { m_attributes |= attribute; diff --git a/src/libs/utils/proxyaction.h b/src/libs/utils/proxyaction.h index e199582ddcf..794c05d6454 100644 --- a/src/libs/utils/proxyaction.h +++ b/src/libs/utils/proxyaction.h @@ -31,6 +31,7 @@ public: bool shortcutVisibleInToolTip() const; void setShortcutVisibleInToolTip(bool visible); + void setAttributes(Attributes attributes); void setAttribute(Attribute attribute); void removeAttribute(Attribute attribute); bool hasAttribute(Attribute attribute); diff --git a/src/plugins/coreplugin/actionmanager/actionmanager.cpp b/src/plugins/coreplugin/actionmanager/actionmanager.cpp index b9bbf23f85f..b6cda842765 100644 --- a/src/plugins/coreplugin/actionmanager/actionmanager.cpp +++ b/src/plugins/coreplugin/actionmanager/actionmanager.cpp @@ -211,6 +211,12 @@ ActionBuilder &ActionBuilder::setCommandAttribute(Command::CommandAttribute attr return *this; } +ActionBuilder &ActionBuilder::setCommandAttributes(Command::CommandAttributes attr) +{ + d->command->setAttributes(attr); + return *this; +} + ActionBuilder &ActionBuilder::setCommandDescription(const QString &desc) { d->command->setDescription(desc); diff --git a/src/plugins/coreplugin/actionmanager/actionmanager.h b/src/plugins/coreplugin/actionmanager/actionmanager.h index e0e0343d2fb..2038b8b6f6b 100644 --- a/src/plugins/coreplugin/actionmanager/actionmanager.h +++ b/src/plugins/coreplugin/actionmanager/actionmanager.h @@ -36,6 +36,7 @@ public: ActionBuilder &setIconText(const QString &iconText); ActionBuilder &setToolTip(const QString &toolTip); ActionBuilder &setCommandAttribute(Core::Command::CommandAttribute attr); + ActionBuilder &setCommandAttributes(Core::Command::CommandAttributes attr); ActionBuilder &setCommandDescription(const QString &desc); ActionBuilder &addToContainer(Utils::Id containerId, Utils::Id groupId = {}, bool needsToExist = true); ActionBuilder &addToContainers(QList containerIds, Utils::Id groupId = {}, diff --git a/src/plugins/coreplugin/actionmanager/command.cpp b/src/plugins/coreplugin/actionmanager/command.cpp index c48d55c30ef..c9b05746c74 100644 --- a/src/plugins/coreplugin/actionmanager/command.cpp +++ b/src/plugins/coreplugin/actionmanager/command.cpp @@ -454,6 +454,18 @@ bool Command::isScriptable(const Context &context) const return false; } +void Command::setAttributes(CommandAttributes attributes) +{ + d->m_attributes = attributes; + + ProxyAction::Attributes proxyAttributes = {}; + proxyAttributes.setFlag(ProxyAction::UpdateText, attributes & CA_UpdateText); + proxyAttributes.setFlag(ProxyAction::UpdateIcon, attributes & CA_UpdateIcon); + proxyAttributes.setFlag(ProxyAction::Hide, attributes & CA_Hide); + + d->m_action->setAttributes(proxyAttributes); +} + void Command::setAttribute(CommandAttribute attr) { d->m_attributes |= attr; diff --git a/src/plugins/coreplugin/actionmanager/command.h b/src/plugins/coreplugin/actionmanager/command.h index 03f2d594bd6..4c6bbea875e 100644 --- a/src/plugins/coreplugin/actionmanager/command.h +++ b/src/plugins/coreplugin/actionmanager/command.h @@ -61,6 +61,7 @@ public: Context context() const; + void setAttributes(CommandAttributes attributes); void setAttribute(CommandAttribute attr); void removeAttribute(CommandAttribute attr); bool hasAttribute(CommandAttribute attr) const; diff --git a/src/plugins/lua/bindings/action.cpp b/src/plugins/lua/bindings/action.cpp index a8323ac827b..27a42c65c94 100644 --- a/src/plugins/lua/bindings/action.cpp +++ b/src/plugins/lua/bindings/action.cpp @@ -45,7 +45,7 @@ void setupActionModule() else if (key == "toolTip") b.setToolTip(v.as()); else if (key == "commandAttributes") - b.setCommandAttribute((Core::Command::CommandAttribute) v.as()); + b.setCommandAttributes(Core::Command::CommandAttributes::fromInt(v.as())); else if (key == "commandDescription") b.setCommandDescription(v.as()); else if (key == "defaultKeySequence")