aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOrgad Shaneh <orgad.shaneh@audiocodes.com>2016-07-19 22:53:08 +0300
committerOrgad Shaneh <orgads@gmail.com>2016-07-20 08:12:20 +0000
commitc894eb6bc1a8e5c592305ef6933ea3a22f66f22e (patch)
treeac313d0423bec9e2bda56c12a9f219a470f859c9
parentbe684dc754701f690fb28d1ce70164fa71d26f3d (diff)
Designer: Replace QSignalMapper with a lambda
Change-Id: I0bf3b1e33188b98525cf717f799466994c494c11 Reviewed-by: Eike Ziller <eike.ziller@qt.io>
-rw-r--r--src/plugins/designer/formeditorw.cpp23
1 files changed, 6 insertions, 17 deletions
diff --git a/src/plugins/designer/formeditorw.cpp b/src/plugins/designer/formeditorw.cpp
index b00d0849dd..58f82a0a7f 100644
--- a/src/plugins/designer/formeditorw.cpp
+++ b/src/plugins/designer/formeditorw.cpp
@@ -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)
- return;
- QAction *a = m_commandToDesignerAction.value(c);
- if (!a)
+ if (!command)
return;
- a->setShortcut(c->action()->shortcut());
+ if (QAction *a = m_commandToDesignerAction.value(command))
+ a->setShortcut(command->action()->shortcut());
}
void FormEditorData::activateEditMode(int id)