From c894eb6bc1a8e5c592305ef6933ea3a22f66f22e Mon Sep 17 00:00:00 2001 From: Orgad Shaneh Date: Tue, 19 Jul 2016 22:53:08 +0300 Subject: [PATCH] Designer: Replace QSignalMapper with a lambda Change-Id: I0bf3b1e33188b98525cf717f799466994c494c11 Reviewed-by: Eike Ziller --- src/plugins/designer/formeditorw.cpp | 23 ++++++----------------- 1 file changed, 6 insertions(+), 17 deletions(-) diff --git a/src/plugins/designer/formeditorw.cpp b/src/plugins/designer/formeditorw.cpp index b00d0849dd5..58f82a0a7f9 100644 --- a/src/plugins/designer/formeditorw.cpp +++ b/src/plugins/designer/formeditorw.cpp @@ -75,7 +75,6 @@ #include #include -#include #include #include @@ -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(&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(&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); - 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)