forked from qt-creator/qt-creator
Edit3DWidget: Avoid using sender()
Amendsb662c50e0a
Amends23f12f7b42
Change-Id: I71adb71c47e90aa257158eb7e600b99860432b3e Reviewed-by: Miikka Heikkinen <miikka.heikkinen@qt.io>
This commit is contained in:
@@ -8,7 +8,6 @@
|
|||||||
#include "edit3dcanvas.h"
|
#include "edit3dcanvas.h"
|
||||||
#include "edit3dtoolbarmenu.h"
|
#include "edit3dtoolbarmenu.h"
|
||||||
#include "edit3dview.h"
|
#include "edit3dview.h"
|
||||||
#include "edit3dviewconfig.h"
|
|
||||||
#include "externaldependenciesinterface.h"
|
#include "externaldependenciesinterface.h"
|
||||||
#include "materialutils.h"
|
#include "materialutils.h"
|
||||||
#include "metainfo.h"
|
#include "metainfo.h"
|
||||||
@@ -312,8 +311,8 @@ void Edit3DWidget::createContextMenu()
|
|||||||
|
|
||||||
auto addOverrideMenuAction = [&](const QString &label, const QString &toolTip,
|
auto addOverrideMenuAction = [&](const QString &label, const QString &toolTip,
|
||||||
MaterialOverrideType type) {
|
MaterialOverrideType type) {
|
||||||
QAction *action = overridesSubMenu->addAction(
|
QAction *action = overridesSubMenu->addAction(label);
|
||||||
label, this, &Edit3DWidget::onMatOverrideAction);
|
connect(action, &QAction::triggered, this, [this, action] { onMatOverrideAction(action); });
|
||||||
action->setData(int(type));
|
action->setData(int(type));
|
||||||
action->setCheckable(true);
|
action->setCheckable(true);
|
||||||
action->setToolTip(toolTip);
|
action->setToolTip(toolTip);
|
||||||
@@ -457,11 +456,8 @@ void Edit3DWidget::updateCreateSubMenu(const QList<ItemLibraryDetails> &entriesL
|
|||||||
m_createSubMenu->addMenu(catMenu);
|
m_createSubMenu->addMenu(catMenu);
|
||||||
}
|
}
|
||||||
|
|
||||||
QAction *action = catMenu->addAction(
|
QAction *action = catMenu->addAction(getEntryIcon(entry), entry.name());
|
||||||
getEntryIcon(entry),
|
connect(action, &QAction::triggered, this, [this, action] { onCreateAction(action); });
|
||||||
entry.name(),
|
|
||||||
this,
|
|
||||||
&Edit3DWidget::onCreateAction);
|
|
||||||
action->setData(entry.name());
|
action->setData(entry.name());
|
||||||
m_nameToEntry.insert(entry.name(), entry);
|
m_nameToEntry.insert(entry.name(), entry);
|
||||||
}
|
}
|
||||||
@@ -469,10 +465,9 @@ void Edit3DWidget::updateCreateSubMenu(const QList<ItemLibraryDetails> &entriesL
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Action triggered from the "create" sub-menu
|
// Action triggered from the "create" sub-menu
|
||||||
void Edit3DWidget::onCreateAction()
|
void Edit3DWidget::onCreateAction(QAction *action)
|
||||||
{
|
{
|
||||||
QAction *action = qobject_cast<QAction *>(sender());
|
if (!m_view || !m_view->model() || isSceneLocked())
|
||||||
if (!action || !m_view || !m_view->model() || isSceneLocked())
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
m_view->executeInTransaction(__FUNCTION__, [&] {
|
m_view->executeInTransaction(__FUNCTION__, [&] {
|
||||||
@@ -499,10 +494,9 @@ void Edit3DWidget::onCreateAction()
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void Edit3DWidget::onMatOverrideAction()
|
void Edit3DWidget::onMatOverrideAction(QAction *action)
|
||||||
{
|
{
|
||||||
QAction *action = qobject_cast<QAction *>(sender());
|
if (!m_view || !m_view->model())
|
||||||
if (!action || !m_view || !m_view->model())
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
QVariantList list;
|
QVariantList list;
|
||||||
@@ -522,17 +516,16 @@ void Edit3DWidget::onMatOverrideAction()
|
|||||||
|
|
||||||
void Edit3DWidget::onWireframeAction()
|
void Edit3DWidget::onWireframeAction()
|
||||||
{
|
{
|
||||||
QAction *action = qobject_cast<QAction *>(sender());
|
if (!m_view || !m_view->model())
|
||||||
if (!action || !m_view || !m_view->model())
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
QVariantList list;
|
QVariantList list;
|
||||||
for (int i = 0; i < m_view->splitToolStates().size(); ++i) {
|
for (int i = 0; i < m_view->splitToolStates().size(); ++i) {
|
||||||
Edit3DView::SplitToolState state = m_view->splitToolStates()[i];
|
Edit3DView::SplitToolState state = m_view->splitToolStates()[i];
|
||||||
if (i == m_view->activeSplit()) {
|
if (i == m_view->activeSplit()) {
|
||||||
state.showWireframe = action->isChecked();
|
state.showWireframe = m_wireFrameAction->isChecked();
|
||||||
m_view->setSplitToolState(i, state);
|
m_view->setSplitToolState(i, state);
|
||||||
list.append(action->isChecked());
|
list.append(m_wireFrameAction->isChecked());
|
||||||
} else {
|
} else {
|
||||||
list.append(state.showWireframe);
|
list.append(state.showWireframe);
|
||||||
}
|
}
|
||||||
|
@@ -53,8 +53,8 @@ public:
|
|||||||
void updateCreateSubMenu(const QList<ItemLibraryDetails> &entriesList);
|
void updateCreateSubMenu(const QList<ItemLibraryDetails> &entriesList);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void onCreateAction();
|
void onCreateAction(QAction *action);
|
||||||
void onMatOverrideAction();
|
void onMatOverrideAction(QAction *action);
|
||||||
void onWireframeAction();
|
void onWireframeAction();
|
||||||
void onResetAllOverridesAction();
|
void onResetAllOverridesAction();
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user