forked from qt-creator/qt-creator
Macros: Use Qt5-style connects
The heavy lifting was done by clazy. Change-Id: I0154e09c1a9e028f3a80772c4c07751f4e282091 Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
committed by
Orgad Shaneh
parent
34a7ff07b7
commit
8641a5e956
@@ -48,12 +48,8 @@ namespace Internal {
|
||||
static const char EVENTNAME[] = "Action";
|
||||
static quint8 ACTIONNAME = 0;
|
||||
|
||||
ActionMacroHandler::ActionMacroHandler():
|
||||
m_mapper(new QSignalMapper(this))
|
||||
ActionMacroHandler::ActionMacroHandler()
|
||||
{
|
||||
connect(m_mapper, SIGNAL(mapped(QString)),
|
||||
this, SLOT(addActionEvent(QString)));
|
||||
|
||||
connect(ActionManager::instance(), &ActionManager::commandAdded,
|
||||
this, &ActionMacroHandler::addCommand);
|
||||
|
||||
@@ -80,30 +76,23 @@ bool ActionMacroHandler::executeEvent(const MacroEvent ¯oEvent)
|
||||
return true;
|
||||
}
|
||||
|
||||
void ActionMacroHandler::addActionEvent(const QString &name)
|
||||
{
|
||||
if (!isRecording())
|
||||
return;
|
||||
|
||||
const Id id = Id::fromString(name);
|
||||
const Command *command = ActionManager::command(id);
|
||||
if (command->isScriptable(command->context())) {
|
||||
MacroEvent e;
|
||||
e.setId(EVENTNAME);
|
||||
e.setValue(ACTIONNAME, id.toSetting());
|
||||
addMacroEvent(e);
|
||||
}
|
||||
}
|
||||
|
||||
void ActionMacroHandler::registerCommand(Id id)
|
||||
{
|
||||
if (!m_commandIds.contains(id)) {
|
||||
m_commandIds.insert(id);
|
||||
const Command *command = ActionManager::command(id);
|
||||
if (QAction *action = command->action()) {
|
||||
connect(action, SIGNAL(triggered()), m_mapper, SLOT(map()));
|
||||
m_mapper->setMapping(action, id.toString());
|
||||
return;
|
||||
connect(action, &QAction::triggered, this, [this, id, command]() {
|
||||
if (!isRecording())
|
||||
return;
|
||||
|
||||
if (command->isScriptable(command->context())) {
|
||||
MacroEvent e;
|
||||
e.setId(EVENTNAME);
|
||||
e.setValue(ACTIONNAME, id.toSetting());
|
||||
addMacroEvent(e);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user