forked from qt-creator/qt-creator
QmlDesigner: Add camera-view align actions to 3d context menu
The following items are added to the context menu of the 3d editor:
1. Align Camera to View
2. Align View to Camera
Task-number: QDS-8063
Change-Id: I7b5b966aba2b5e96b7cd4d8a88cf4e7db8cdc0ac
Reviewed-by: Mahmoud Badri <mahmoud.badri@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Samuel Ghinet <samuel.ghinet@qt.io>
Reviewed-by: Miikka Heikkinen <miikka.heikkinen@qt.io>
This commit is contained in:
@@ -188,6 +188,16 @@ void Edit3DWidget::createContextMenu()
|
|||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
m_contextMenu->addSeparator();
|
||||||
|
|
||||||
|
m_alignCameraAction = m_contextMenu->addAction(tr("Align Camera to View"), [&] {
|
||||||
|
view()->emitView3DAction(View3DActionType::AlignCamerasToView, true);
|
||||||
|
});
|
||||||
|
|
||||||
|
m_alignViewAction = m_contextMenu->addAction(tr("Align View to Camera"), [&] {
|
||||||
|
view()->emitView3DAction(View3DActionType::AlignViewToCamera, true);
|
||||||
|
});
|
||||||
|
|
||||||
m_contextMenu->addSeparator();
|
m_contextMenu->addSeparator();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -312,11 +322,14 @@ void Edit3DWidget::showContextMenu(const QPoint &pos, const ModelNode &modelNode
|
|||||||
|
|
||||||
const bool isValid = modelNode.isValid();
|
const bool isValid = modelNode.isValid();
|
||||||
const bool isModel = modelNode.metaInfo().isQtQuick3DModel();
|
const bool isModel = modelNode.metaInfo().isQtQuick3DModel();
|
||||||
const bool isValidNotRoot = isValid && !modelNode.isRootNode();
|
const bool isNotRoot = isValid && !modelNode.isRootNode();
|
||||||
|
const bool isCamera = isValid && modelNode.metaInfo().isQtQuick3DCamera();
|
||||||
|
|
||||||
m_editMaterialAction->setEnabled(isModel);
|
m_editMaterialAction->setEnabled(isModel);
|
||||||
m_deleteAction->setEnabled(isValidNotRoot);
|
m_deleteAction->setEnabled(isNotRoot);
|
||||||
m_copyAction->setEnabled(isValidNotRoot);
|
m_copyAction->setEnabled(isNotRoot);
|
||||||
|
m_alignCameraAction->setEnabled(isCamera);
|
||||||
|
m_alignViewAction->setEnabled(isCamera);
|
||||||
|
|
||||||
m_contextMenu->popup(mapToGlobal(pos));
|
m_contextMenu->popup(mapToGlobal(pos));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -63,6 +63,8 @@ private:
|
|||||||
QPointer<QAction> m_editMaterialAction;
|
QPointer<QAction> m_editMaterialAction;
|
||||||
QPointer<QAction> m_deleteAction;
|
QPointer<QAction> m_deleteAction;
|
||||||
QPointer<QAction> m_copyAction;
|
QPointer<QAction> m_copyAction;
|
||||||
|
QPointer<QAction> m_alignCameraAction;
|
||||||
|
QPointer<QAction> m_alignViewAction;
|
||||||
QPointer<QMenu> m_createSubMenu;
|
QPointer<QMenu> m_createSubMenu;
|
||||||
ModelNode m_contextMenuTarget;
|
ModelNode m_contextMenuTarget;
|
||||||
QVector3D m_contextMenuPos3d;
|
QVector3D m_contextMenuPos3d;
|
||||||
|
|||||||
Reference in New Issue
Block a user