forked from qt-creator/qt-creator
QmlDesigner: Add "Edit Material" context menu option for material nodes
Fixes: QDS-12372 Change-Id: Ie412216514973aa6d108f3595489f92e13497576 Reviewed-by: Mahmoud Badri <mahmoud.badri@qt.io> Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: Qt CI Patch Build Bot <ci_patchbuild_bot@qt.io>
This commit is contained in:
@@ -1988,8 +1988,8 @@ void DesignerActionManager::createDefaultDesignerActions()
|
||||
QKeySequence(),
|
||||
44,
|
||||
&editMaterial,
|
||||
&modelHasMaterial,
|
||||
&isModel));
|
||||
&hasEditableMaterial,
|
||||
&isModelOrMaterial));
|
||||
|
||||
addDesignerAction(new ModelNodeContextMenuAction(
|
||||
mergeTemplateCommandId,
|
||||
|
@@ -64,16 +64,19 @@ inline bool addMouseAreaFillCheck(const SelectionContext &selectionContext)
|
||||
return false;
|
||||
}
|
||||
|
||||
inline bool isModel(const SelectionContext &selectionState)
|
||||
inline bool isModelOrMaterial(const SelectionContext &selectionState)
|
||||
{
|
||||
ModelNode node = selectionState.currentSingleSelectedNode();
|
||||
return node.metaInfo().isQtQuick3DModel();
|
||||
return node.metaInfo().isQtQuick3DModel() || node.metaInfo().isQtQuick3DMaterial();
|
||||
}
|
||||
|
||||
inline bool modelHasMaterial(const SelectionContext &selectionState)
|
||||
inline bool hasEditableMaterial(const SelectionContext &selectionState)
|
||||
{
|
||||
ModelNode node = selectionState.currentSingleSelectedNode();
|
||||
|
||||
if (node.metaInfo().isQtQuick3DMaterial())
|
||||
return true;
|
||||
|
||||
BindingProperty prop = node.bindingProperty("materials");
|
||||
|
||||
return prop.exists() && (!prop.expression().isEmpty() || !prop.resolveToModelNodeList().empty());
|
||||
|
@@ -817,21 +817,25 @@ void editMaterial(const SelectionContext &selectionContext)
|
||||
|
||||
QTC_ASSERT(modelNode.isValid(), return);
|
||||
|
||||
BindingProperty prop = modelNode.bindingProperty("materials");
|
||||
if (!prop.exists())
|
||||
return;
|
||||
|
||||
AbstractView *view = selectionContext.view();
|
||||
|
||||
ModelNode material;
|
||||
|
||||
if (view->hasId(prop.expression())) {
|
||||
material = view->modelNodeForId(prop.expression());
|
||||
if (modelNode.metaInfo().isQtQuick3DMaterial()) {
|
||||
material = modelNode;
|
||||
} else {
|
||||
QList<ModelNode> materials = prop.resolveToModelNodeList();
|
||||
BindingProperty prop = modelNode.bindingProperty("materials");
|
||||
if (!prop.exists())
|
||||
return;
|
||||
|
||||
if (materials.size() > 0)
|
||||
material = materials.first();
|
||||
if (view->hasId(prop.expression())) {
|
||||
material = view->modelNodeForId(prop.expression());
|
||||
} else {
|
||||
QList<ModelNode> materials = prop.resolveToModelNodeList();
|
||||
|
||||
if (materials.size() > 0)
|
||||
material = materials.first();
|
||||
}
|
||||
}
|
||||
|
||||
if (material.isValid()) {
|
||||
|
Reference in New Issue
Block a user