QmlDesigner: Fix focus issues in material browser

Fixed focus loss on context menu close.
Fixed an issue with main view also handling cursor and enter keys when
editing material name.
Expanding a section now focuses the expanded section.
Dragging items from content library now focuses correct section.

Fixes: QDS-9215
Change-Id: I2176c7e52d8855c547db426b55ab739ca8f1db06
Reviewed-by: Mahmoud Badri <mahmoud.badri@qt.io>
This commit is contained in:
Miikka Heikkinen
2023-02-20 15:39:42 +02:00
parent 8b5c454881
commit d39f469e51
6 changed files with 35 additions and 4 deletions

View File

@@ -323,6 +323,8 @@ ModelNode ContentLibraryView::createMaterial(const NodeMetaInfo &metaInfo)
VariantProperty objNameProp = newMatNode.variantProperty("objectName");
objNameProp.setValue(newName);
emitCustomNotification("focus_material_section", {});
return newMatNode;
}

View File

@@ -36,7 +36,7 @@ ModelNode CreateTexture::execute(const QString &filePath, AddTextureMode mode, i
QTimer::singleShot(0, m_view, [this, texture]() {
if (m_view->model())
m_view->emitCustomNotification("selected_texture_changed", {texture});
m_view->emitCustomNotification("selected_texture_changed", {texture}, {true});
});
return texture;

View File

@@ -497,6 +497,8 @@ void MaterialBrowserView::customNotification(const AbstractView *view,
if (idx != -1) {
m_widget->materialBrowserTexturesModel()->selectTexture(idx);
m_widget->materialBrowserTexturesModel()->refreshSearch();
if (!data.isEmpty() && data[0].toBool())
m_widget->focusMaterialSection(false);
}
} else if (identifier == "refresh_material_browser") {
QTimer::singleShot(0, model(), [this]() {
@@ -511,6 +513,8 @@ void MaterialBrowserView::customNotification(const AbstractView *view,
applyTextureToModel3D(nodeList.at(0), nodeList.at(1));
} else if (identifier == "apply_texture_to_material") {
applyTextureToMaterial({nodeList.at(0)}, nodeList.at(1));
} else if (identifier == "focus_material_section") {
m_widget->focusMaterialSection(true);
}
}