QmlDesigner: Disable apply material to selected when no selection exist

When there is no valid model selected, disable the "apply to selected"
actions in the material editor and browser.

Change-Id: Id8e771c64e69c0ba2f42dff01d19ffbf4afafb77
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
This commit is contained in:
Mahmoud Badri
2022-05-24 14:14:14 +03:00
parent c5818fc844
commit 71e553f497
8 changed files with 52 additions and 12 deletions

View File

@@ -118,10 +118,6 @@ void MaterialBrowserView::modelAboutToBeDetached(Model *model)
void MaterialBrowserView::selectedNodesChanged(const QList<ModelNode> &selectedNodeList,
const QList<ModelNode> &lastSelectedNodeList)
{
if (!m_autoSelectModelMaterial)
return;
// if selected object is a model, select its material in the material browser and editor
ModelNode selectedModel;
for (const ModelNode &node : selectedNodeList) {
@@ -131,6 +127,11 @@ void MaterialBrowserView::selectedNodesChanged(const QList<ModelNode> &selectedN
}
}
m_widget->materialBrowserModel()->setHasModelSelection(selectedModel.isValid());
if (!m_autoSelectModelMaterial)
return;
if (selectedNodeList.size() > 1 || !selectedModel.isValid())
return;
@@ -144,6 +145,7 @@ void MaterialBrowserView::selectedNodesChanged(const QList<ModelNode> &selectedN
if (!mat.isValid())
return;
// if selected object is a model, select its material in the material browser and editor
int idx = m_widget->materialBrowserModel()->materialIndex(mat);
m_widget->materialBrowserModel()->selectMaterial(idx);
}