forked from qt-creator/qt-creator
Core: Allow setting all Command attributes at once
Change-Id: I3e483a26cbd3e20166739ed677760d05ad9575b1 Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
@@ -60,6 +60,12 @@ QAction *ProxyAction::action() const
|
|||||||
return m_action;
|
return m_action;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ProxyAction::setAttributes(ProxyAction::Attributes attributes)
|
||||||
|
{
|
||||||
|
m_attributes = attributes;
|
||||||
|
updateState();
|
||||||
|
}
|
||||||
|
|
||||||
void ProxyAction::setAttribute(ProxyAction::Attribute attribute)
|
void ProxyAction::setAttribute(ProxyAction::Attribute attribute)
|
||||||
{
|
{
|
||||||
m_attributes |= attribute;
|
m_attributes |= attribute;
|
||||||
|
@@ -31,6 +31,7 @@ public:
|
|||||||
bool shortcutVisibleInToolTip() const;
|
bool shortcutVisibleInToolTip() const;
|
||||||
void setShortcutVisibleInToolTip(bool visible);
|
void setShortcutVisibleInToolTip(bool visible);
|
||||||
|
|
||||||
|
void setAttributes(Attributes attributes);
|
||||||
void setAttribute(Attribute attribute);
|
void setAttribute(Attribute attribute);
|
||||||
void removeAttribute(Attribute attribute);
|
void removeAttribute(Attribute attribute);
|
||||||
bool hasAttribute(Attribute attribute);
|
bool hasAttribute(Attribute attribute);
|
||||||
|
@@ -211,6 +211,12 @@ ActionBuilder &ActionBuilder::setCommandAttribute(Command::CommandAttribute attr
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ActionBuilder &ActionBuilder::setCommandAttributes(Command::CommandAttributes attr)
|
||||||
|
{
|
||||||
|
d->command->setAttributes(attr);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
ActionBuilder &ActionBuilder::setCommandDescription(const QString &desc)
|
ActionBuilder &ActionBuilder::setCommandDescription(const QString &desc)
|
||||||
{
|
{
|
||||||
d->command->setDescription(desc);
|
d->command->setDescription(desc);
|
||||||
|
@@ -36,6 +36,7 @@ public:
|
|||||||
ActionBuilder &setIconText(const QString &iconText);
|
ActionBuilder &setIconText(const QString &iconText);
|
||||||
ActionBuilder &setToolTip(const QString &toolTip);
|
ActionBuilder &setToolTip(const QString &toolTip);
|
||||||
ActionBuilder &setCommandAttribute(Core::Command::CommandAttribute attr);
|
ActionBuilder &setCommandAttribute(Core::Command::CommandAttribute attr);
|
||||||
|
ActionBuilder &setCommandAttributes(Core::Command::CommandAttributes attr);
|
||||||
ActionBuilder &setCommandDescription(const QString &desc);
|
ActionBuilder &setCommandDescription(const QString &desc);
|
||||||
ActionBuilder &addToContainer(Utils::Id containerId, Utils::Id groupId = {}, bool needsToExist = true);
|
ActionBuilder &addToContainer(Utils::Id containerId, Utils::Id groupId = {}, bool needsToExist = true);
|
||||||
ActionBuilder &addToContainers(QList<Utils::Id> containerIds, Utils::Id groupId = {},
|
ActionBuilder &addToContainers(QList<Utils::Id> containerIds, Utils::Id groupId = {},
|
||||||
|
@@ -454,6 +454,18 @@ bool Command::isScriptable(const Context &context) const
|
|||||||
return false;
|
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)
|
void Command::setAttribute(CommandAttribute attr)
|
||||||
{
|
{
|
||||||
d->m_attributes |= attr;
|
d->m_attributes |= attr;
|
||||||
|
@@ -61,6 +61,7 @@ public:
|
|||||||
|
|
||||||
Context context() const;
|
Context context() const;
|
||||||
|
|
||||||
|
void setAttributes(CommandAttributes attributes);
|
||||||
void setAttribute(CommandAttribute attr);
|
void setAttribute(CommandAttribute attr);
|
||||||
void removeAttribute(CommandAttribute attr);
|
void removeAttribute(CommandAttribute attr);
|
||||||
bool hasAttribute(CommandAttribute attr) const;
|
bool hasAttribute(CommandAttribute attr) const;
|
||||||
|
@@ -45,7 +45,7 @@ void setupActionModule()
|
|||||||
else if (key == "toolTip")
|
else if (key == "toolTip")
|
||||||
b.setToolTip(v.as<QString>());
|
b.setToolTip(v.as<QString>());
|
||||||
else if (key == "commandAttributes")
|
else if (key == "commandAttributes")
|
||||||
b.setCommandAttribute((Core::Command::CommandAttribute) v.as<int>());
|
b.setCommandAttributes(Core::Command::CommandAttributes::fromInt(v.as<int>()));
|
||||||
else if (key == "commandDescription")
|
else if (key == "commandDescription")
|
||||||
b.setCommandDescription(v.as<QString>());
|
b.setCommandDescription(v.as<QString>());
|
||||||
else if (key == "defaultKeySequence")
|
else if (key == "defaultKeySequence")
|
||||||
|
Reference in New Issue
Block a user