forked from qt-creator/qt-creator
Core: Some ActionBuilder API polish
Change-Id: I8a59b5dd9277833361a7c8ed848e2da80972afcb Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
@@ -141,6 +141,12 @@ void ActionBuilder::addToContainer(Id containerId, Id groupId, bool needsToExist
|
||||
QTC_CHECK(!needsToExist);
|
||||
}
|
||||
|
||||
void ActionBuilder::addToContainers(QList<Id> containerIds, Id groupId, bool needsToExist)
|
||||
{
|
||||
for (const Id &containerId : containerIds)
|
||||
addToContainer(containerId, groupId, needsToExist);
|
||||
}
|
||||
|
||||
void ActionBuilder::addOnTriggered(const std::function<void ()> &func)
|
||||
{
|
||||
QObject::connect(d->contextAction, &QAction::triggered, d->contextAction, func);
|
||||
@@ -176,6 +182,11 @@ void ActionBuilder::setTouchBarIcon(const QIcon &icon)
|
||||
d->command->setTouchBarIcon(icon);
|
||||
}
|
||||
|
||||
void ActionBuilder::setTouchBarText(const QString &text)
|
||||
{
|
||||
d->command->setTouchBarText(text);
|
||||
}
|
||||
|
||||
void ActionBuilder::setEnabled(bool on)
|
||||
{
|
||||
d->contextAction->setEnabled(on);
|
||||
@@ -221,6 +232,11 @@ void ActionBuilder::setParameterText(const QString ¶meterText,
|
||||
d->contextAction->setText(emptyText);
|
||||
}
|
||||
|
||||
Id ActionBuilder::id() const
|
||||
{
|
||||
return d->actionId;
|
||||
}
|
||||
|
||||
Command *ActionBuilder::command() const
|
||||
{
|
||||
return d->command;
|
||||
@@ -258,11 +274,6 @@ void ActionBuilder::augmentActionWithShortcutToolTip()
|
||||
d->command->augmentActionWithShortcutToolTip(d->contextAction);
|
||||
}
|
||||
|
||||
void ActionBuilder::setId(Id id)
|
||||
{
|
||||
d->actionId = id;
|
||||
}
|
||||
|
||||
void ActionBuilder::setContext(Id id)
|
||||
{
|
||||
d->context = Context(id);
|
||||
|
@@ -9,7 +9,6 @@
|
||||
#include "command.h"
|
||||
|
||||
#include <QAction>
|
||||
#include <QList>
|
||||
|
||||
#include <functional>
|
||||
|
||||
@@ -18,8 +17,6 @@ namespace Utils { class ParameterAction; }
|
||||
namespace Core {
|
||||
|
||||
class ActionContainer;
|
||||
class Command;
|
||||
class Context;
|
||||
class ICore;
|
||||
|
||||
namespace Internal {
|
||||
@@ -31,10 +28,9 @@ class MainWindow;
|
||||
class CORE_EXPORT ActionBuilder
|
||||
{
|
||||
public:
|
||||
ActionBuilder(QObject *contextActionParent, const Utils::Id actionId = {});
|
||||
ActionBuilder(QObject *contextActionParent, const Utils::Id actionId);
|
||||
~ActionBuilder();
|
||||
|
||||
void setId(Utils::Id id);
|
||||
void setContext(const Utils::Id id);
|
||||
void setContext(const Core::Context &context);
|
||||
void setText(const QString &text);
|
||||
@@ -43,6 +39,8 @@ public:
|
||||
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 = {},
|
||||
bool needsToExist = true);
|
||||
void addOnTriggered(const std::function<void()> &func);
|
||||
|
||||
template<class T, typename F>
|
||||
@@ -75,6 +73,7 @@ public:
|
||||
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);
|
||||
@@ -88,6 +87,7 @@ public:
|
||||
EnablingMode mode = EnabledWithParameter);
|
||||
|
||||
|
||||
Utils::Id id() const;
|
||||
Command *command() const;
|
||||
QAction *commandAction() const;
|
||||
QAction *contextAction() const;
|
||||
|
Reference in New Issue
Block a user