forked from qt-creator/qt-creator
Designer: Replace QSignalMapper with a lambda
Change-Id: I0bf3b1e33188b98525cf717f799466994c494c11 Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
committed by
Orgad Shaneh
parent
be684dc754
commit
c894eb6bc1
@@ -75,7 +75,6 @@
|
|||||||
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QSettings>
|
#include <QSettings>
|
||||||
#include <QSignalMapper>
|
|
||||||
#include <QPluginLoader>
|
#include <QPluginLoader>
|
||||||
#include <QTime>
|
#include <QTime>
|
||||||
|
|
||||||
@@ -155,7 +154,7 @@ public:
|
|||||||
void toolChanged(int);
|
void toolChanged(int);
|
||||||
void print();
|
void print();
|
||||||
void setPreviewMenuEnabled(bool e);
|
void setPreviewMenuEnabled(bool e);
|
||||||
void updateShortcut(QObject *command);
|
void updateShortcut(Command *command);
|
||||||
|
|
||||||
void fullInit();
|
void fullInit();
|
||||||
|
|
||||||
@@ -207,7 +206,6 @@ public:
|
|||||||
QActionGroup *m_actionGroupPreviewInStyle;
|
QActionGroup *m_actionGroupPreviewInStyle;
|
||||||
QMenu *m_previewInStyleMenu;
|
QMenu *m_previewInStyleMenu;
|
||||||
QAction *m_actionAboutPlugins;
|
QAction *m_actionAboutPlugins;
|
||||||
QSignalMapper m_shortcutMapper;
|
|
||||||
|
|
||||||
DesignerContext *m_context;
|
DesignerContext *m_context;
|
||||||
Context m_contexts;
|
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;
|
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
|
// Apply the command shortcut to the action and connects to the command's keySequenceChanged signal
|
||||||
void FormEditorData::bindShortcut(Command *command, QAction *action)
|
void FormEditorData::bindShortcut(Command *command, QAction *action)
|
||||||
{
|
{
|
||||||
typedef void (QSignalMapper::*SignalMapperVoidSlot)();
|
|
||||||
|
|
||||||
m_commandToDesignerAction.insert(command, action);
|
m_commandToDesignerAction.insert(command, action);
|
||||||
QObject::connect(command, &Command::keySequenceChanged,
|
QObject::connect(command, &Command::keySequenceChanged,
|
||||||
&m_shortcutMapper, static_cast<SignalMapperVoidSlot>(&QSignalMapper::map));
|
command, [this, command] { updateShortcut(command); });
|
||||||
m_shortcutMapper.setMapping(command, command);
|
|
||||||
updateShortcut(command);
|
updateShortcut(command);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -837,15 +829,12 @@ FormWindowEditor *FormEditorW::activeEditor()
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void FormEditorData::updateShortcut(QObject *command)
|
void FormEditorData::updateShortcut(Command *command)
|
||||||
{
|
{
|
||||||
Command *c = qobject_cast<Command *>(command);
|
if (!command)
|
||||||
if (!c)
|
|
||||||
return;
|
return;
|
||||||
QAction *a = m_commandToDesignerAction.value(c);
|
if (QAction *a = m_commandToDesignerAction.value(command))
|
||||||
if (!a)
|
a->setShortcut(command->action()->shortcut());
|
||||||
return;
|
|
||||||
a->setShortcut(c->action()->shortcut());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void FormEditorData::activateEditMode(int id)
|
void FormEditorData::activateEditMode(int id)
|
||||||
|
Reference in New Issue
Block a user