forked from qt-creator/qt-creator
QmlDesigner: Add delete action to 3D Editor's context menu
This entails selecting a model upon right-clicking if it is not selected. Also fixed a memory leak and small tweaks. Fixes: QDS-7401 Change-Id: I592acb3fff30ecc3236f3cf2fbe126de4fb389dc Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: Miikka Heikkinen <miikka.heikkinen@qt.io>
This commit is contained in:
@@ -185,7 +185,12 @@ void Edit3DWidget::createContextMenu()
|
||||
ModelNodeOperations::editMaterial(selCtx);
|
||||
});
|
||||
|
||||
// TODO: add more actions: delete, create, etc
|
||||
m_deleteAction = m_contextMenu->addAction(tr("Delete"), [&] {
|
||||
view()->executeInTransaction("Edit3DWidget::createContextMenu", [&] {
|
||||
for (ModelNode &node : m_view->selectedModelNodes())
|
||||
node.destroy();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
void Edit3DWidget::contextHelp(const Core::IContext::HelpCallback &callback) const
|
||||
@@ -241,6 +246,7 @@ void Edit3DWidget::showContextMenu(const QPoint &pos, const ModelNode &modelNode
|
||||
m_contextMenuTarget = modelNode;
|
||||
|
||||
m_editMaterialAction->setEnabled(modelNode.isValid());
|
||||
m_deleteAction->setEnabled(modelNode.isValid());
|
||||
|
||||
m_contextMenu->popup(mapToGlobal(pos));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user