forked from qt-creator/qt-creator
QmlDesigner: Fix triggering "Edit in 3D view" from 2D view
If activating another view hides 2D view, 2D view detaches, which caused custom notification to not be sent as view no longer had model. Refactored the relevant cases to store node's internal id before the view gets detached and emit notification directly via model pointer. Fixes: QDS-13402 Change-Id: I21400646aed8871474a4618da69ba8a001bad361 Reviewed-by: Mahmoud Badri <mahmoud.badri@qt.io>
This commit is contained in:
@@ -1695,12 +1695,15 @@ void editIn3dView(const SelectionContext &selectionContext)
|
||||
}
|
||||
|
||||
if (targetNode.isValid()) {
|
||||
qint32 id = targetNode.internalId();
|
||||
Model *model = selectionContext.model();
|
||||
QmlDesignerPlugin::instance()->mainWidget()->showDockWidget("Editor3D", true);
|
||||
if (scenePos.isNull()) {
|
||||
selectionContext.model()->emitView3DAction(View3DActionType::AlignViewToCamera, true);
|
||||
model->emitView3DAction(View3DActionType::AlignViewToCamera, true);
|
||||
} else {
|
||||
selectionContext.view()->emitCustomNotification("pick_3d_node_from_2d_scene",
|
||||
{targetNode}, {scenePos});
|
||||
model->emitCustomNotification(selectionContext.view(),
|
||||
"pick_3d_node_from_2d_scene",
|
||||
{}, {scenePos, id});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -456,16 +456,16 @@ void Edit3DView::customNotification([[maybe_unused]] const AbstractView *view,
|
||||
[[maybe_unused]] const QList<ModelNode> &nodeList,
|
||||
[[maybe_unused]] const QList<QVariant> &data)
|
||||
{
|
||||
if (identifier == "pick_3d_node_from_2d_scene" && data.size() == 1 && nodeList.size() == 1) {
|
||||
if (identifier == "pick_3d_node_from_2d_scene" && data.size() == 2) {
|
||||
// Pick via 2D view, data has pick coordinates in main scene coordinates
|
||||
QTimer::singleShot(0, this, [=, self = QPointer{this}]() {
|
||||
if (!self)
|
||||
return;
|
||||
|
||||
self->emitView3DAction(View3DActionType::GetNodeAtMainScenePos,
|
||||
QVariantList{data[0], nodeList[0].internalId()});
|
||||
QVariantList{data[0], data[1]});
|
||||
self->m_nodeAtPosReqType = NodeAtPosReqType::MainScenePick;
|
||||
self->m_pickView3dNode = nodeList[0];
|
||||
self->m_pickView3dNode = self->modelNodeForInternalId(qint32(data[1].toInt()));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@@ -54,9 +54,11 @@ void View3DTool::mouseReleaseEvent(const QList<QGraphicsItem *> &,
|
||||
QGraphicsSceneMouseEvent *event)
|
||||
{
|
||||
if (m_view3dNode.isValid()) {
|
||||
Model *model = view()->model();
|
||||
qint32 id = m_view3dNode.internalId();
|
||||
QmlDesignerPlugin::instance()->mainWidget()->showDockWidget("Editor3D", true);
|
||||
view()->emitCustomNotification("pick_3d_node_from_2d_scene",
|
||||
{m_view3dNode}, {event->scenePos()});
|
||||
model->emitCustomNotification(view(), "pick_3d_node_from_2d_scene",
|
||||
{}, {event->scenePos(), id});
|
||||
}
|
||||
|
||||
view()->changeToSelectionTool();
|
||||
|
Reference in New Issue
Block a user