Designer: Replace QSignalMapper with a lambda

Change-Id: I0bf3b1e33188b98525cf717f799466994c494c11
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
Orgad Shaneh
2016-07-19 22:53:08 +03:00
committed by Orgad Shaneh
parent be684dc754
commit c894eb6bc1

View File

@@ -75,7 +75,6 @@
#include <QDebug>
#include <QSettings>
#include <QSignalMapper>
#include <QPluginLoader>
#include <QTime>
@@ -155,7 +154,7 @@ public:
void toolChanged(int);
void print();
void setPreviewMenuEnabled(bool e);
void updateShortcut(QObject *command);
void updateShortcut(Command *command);
void fullInit();
@@ -207,7 +206,6 @@ public:
QActionGroup *m_actionGroupPreviewInStyle;
QMenu *m_previewInStyleMenu;
QAction *m_actionAboutPlugins;
QSignalMapper m_shortcutMapper;
DesignerContext *m_context;
Context m_contexts;
@@ -284,9 +282,6 @@ FormEditorData::FormEditorData() :
}
});
QObject::connect(&m_shortcutMapper, static_cast<void(QSignalMapper::*)(QObject *)>(&QSignalMapper::mapped),
[this](QObject *ob) { updateShortcut(ob); });
m_xmlEditorFactory = new FormWindowEditorFactory;
}
@@ -736,12 +731,9 @@ void FormEditorData::critical(const QString &errorMessage)
// Apply the command shortcut to the action and connects to the command's keySequenceChanged signal
void FormEditorData::bindShortcut(Command *command, QAction *action)
{
typedef void (QSignalMapper::*SignalMapperVoidSlot)();
m_commandToDesignerAction.insert(command, action);
QObject::connect(command, &Command::keySequenceChanged,
&m_shortcutMapper, static_cast<SignalMapperVoidSlot>(&QSignalMapper::map));
m_shortcutMapper.setMapping(command, command);
command, [this, command] { updateShortcut(command); });
updateShortcut(command);
}
@@ -837,15 +829,12 @@ FormWindowEditor *FormEditorW::activeEditor()
return 0;
}
void FormEditorData::updateShortcut(QObject *command)
void FormEditorData::updateShortcut(Command *command)
{
Command *c = qobject_cast<Command *>(command);
if (!c)
if (!command)
return;
QAction *a = m_commandToDesignerAction.value(c);
if (!a)
return;
a->setShortcut(c->action()->shortcut());
if (QAction *a = m_commandToDesignerAction.value(command))
a->setShortcut(command->action()->shortcut());
}
void FormEditorData::activateEditMode(int id)