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(),
|
QKeySequence(),
|
||||||
44,
|
44,
|
||||||
&editMaterial,
|
&editMaterial,
|
||||||
&modelHasMaterial,
|
&hasEditableMaterial,
|
||||||
&isModel));
|
&isModelOrMaterial));
|
||||||
|
|
||||||
addDesignerAction(new ModelNodeContextMenuAction(
|
addDesignerAction(new ModelNodeContextMenuAction(
|
||||||
mergeTemplateCommandId,
|
mergeTemplateCommandId,
|
||||||
|
@@ -64,16 +64,19 @@ inline bool addMouseAreaFillCheck(const SelectionContext &selectionContext)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool isModel(const SelectionContext &selectionState)
|
inline bool isModelOrMaterial(const SelectionContext &selectionState)
|
||||||
{
|
{
|
||||||
ModelNode node = selectionState.currentSingleSelectedNode();
|
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();
|
ModelNode node = selectionState.currentSingleSelectedNode();
|
||||||
|
|
||||||
|
if (node.metaInfo().isQtQuick3DMaterial())
|
||||||
|
return true;
|
||||||
|
|
||||||
BindingProperty prop = node.bindingProperty("materials");
|
BindingProperty prop = node.bindingProperty("materials");
|
||||||
|
|
||||||
return prop.exists() && (!prop.expression().isEmpty() || !prop.resolveToModelNodeList().empty());
|
return prop.exists() && (!prop.expression().isEmpty() || !prop.resolveToModelNodeList().empty());
|
||||||
|
@@ -817,14 +817,17 @@ void editMaterial(const SelectionContext &selectionContext)
|
|||||||
|
|
||||||
QTC_ASSERT(modelNode.isValid(), return);
|
QTC_ASSERT(modelNode.isValid(), return);
|
||||||
|
|
||||||
BindingProperty prop = modelNode.bindingProperty("materials");
|
|
||||||
if (!prop.exists())
|
|
||||||
return;
|
|
||||||
|
|
||||||
AbstractView *view = selectionContext.view();
|
AbstractView *view = selectionContext.view();
|
||||||
|
|
||||||
ModelNode material;
|
ModelNode material;
|
||||||
|
|
||||||
|
if (modelNode.metaInfo().isQtQuick3DMaterial()) {
|
||||||
|
material = modelNode;
|
||||||
|
} else {
|
||||||
|
BindingProperty prop = modelNode.bindingProperty("materials");
|
||||||
|
if (!prop.exists())
|
||||||
|
return;
|
||||||
|
|
||||||
if (view->hasId(prop.expression())) {
|
if (view->hasId(prop.expression())) {
|
||||||
material = view->modelNodeForId(prop.expression());
|
material = view->modelNodeForId(prop.expression());
|
||||||
} else {
|
} else {
|
||||||
@@ -833,6 +836,7 @@ void editMaterial(const SelectionContext &selectionContext)
|
|||||||
if (materials.size() > 0)
|
if (materials.size() > 0)
|
||||||
material = materials.first();
|
material = materials.first();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (material.isValid()) {
|
if (material.isValid()) {
|
||||||
QmlDesignerPlugin::instance()->mainWidget()->showDockWidget("MaterialEditor");
|
QmlDesignerPlugin::instance()->mainWidget()->showDockWidget("MaterialEditor");
|
||||||
|
Reference in New Issue
Block a user