forked from qt-creator/qt-creator
Core: Simplify ActionManager::setOnTriggered
Allows the same functionality as QObject::connect Change-Id: I4416d991dc8bcdf24893435c30b530a6b4d3fda4 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
@@ -146,16 +146,6 @@ void ActionBuilder::setOnTriggered(const std::function<void ()> &func)
|
|||||||
QObject::connect(d->action, &QAction::triggered, d->action, func);
|
QObject::connect(d->action, &QAction::triggered, d->action, func);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ActionBuilder::setOnTriggered(QObject *guard, const std::function<void()> &func)
|
|
||||||
{
|
|
||||||
QObject::connect(d->action, &QAction::triggered, guard, func);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ActionBuilder::setOnTriggered(QObject *guard, const std::function<void(bool)> &func)
|
|
||||||
{
|
|
||||||
QObject::connect(d->action, &QAction::triggered, guard, func);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ActionBuilder::setOnToggled(QObject *guard, const std::function<void (bool)> &func)
|
void ActionBuilder::setOnToggled(QObject *guard, const std::function<void (bool)> &func)
|
||||||
{
|
{
|
||||||
QObject::connect(d->action, &QAction::toggled, guard, func);
|
QObject::connect(d->action, &QAction::toggled, guard, func);
|
||||||
|
|||||||
@@ -44,9 +44,20 @@ public:
|
|||||||
void setCommandDescription(const QString &desc);
|
void setCommandDescription(const QString &desc);
|
||||||
void setContainer(Utils::Id containerId, Utils::Id groupId = {}, bool needsToExist = true);
|
void setContainer(Utils::Id containerId, Utils::Id groupId = {}, bool needsToExist = true);
|
||||||
void setOnTriggered(const std::function<void()> &func);
|
void setOnTriggered(const std::function<void()> &func);
|
||||||
void setOnTriggered(QObject *guard, const std::function<void()> &func);
|
|
||||||
void setOnTriggered(QObject *guard, const std::function<void(bool)> &func);
|
|
||||||
void setOnToggled(QObject *guard, const std::function<void(bool)> &func);
|
void setOnToggled(QObject *guard, const std::function<void(bool)> &func);
|
||||||
|
|
||||||
|
template<class T, typename F>
|
||||||
|
void setOnTriggered(T *guard,
|
||||||
|
F &&function,
|
||||||
|
Qt::ConnectionType connectionType = Qt::AutoConnection)
|
||||||
|
{
|
||||||
|
QObject::connect(commandAction(),
|
||||||
|
&QAction::triggered,
|
||||||
|
guard,
|
||||||
|
std::forward<F>(function),
|
||||||
|
connectionType);
|
||||||
|
}
|
||||||
|
|
||||||
void setDefaultKeySequence(const QKeySequence &seq);
|
void setDefaultKeySequence(const QKeySequence &seq);
|
||||||
void setDefaultKeySequences(const QList<QKeySequence> &seqs);
|
void setDefaultKeySequences(const QList<QKeySequence> &seqs);
|
||||||
void setDefaultKeySequence(const QString &mac, const QString &nonMac);
|
void setDefaultKeySequence(const QString &mac, const QString &nonMac);
|
||||||
|
|||||||
Reference in New Issue
Block a user