forked from qt-creator/qt-creator
QmlDesigner: Fix asset drag to material browser
Drag now correctly accepts only assets that can be used as textures. "selected_texture_changed" custom notification was used in two semantically slightly different cases, both to indicate selected texture had changed and that selection should change, which was little confusing. Split the two cases to separate custom notifications to clarify the situation and allow "select_texture" to be handled in material browser even if it sent it. This fixes the issue of newly added texture not getting selected after drag, because creation was done by material browser view. Similar issue was fixed with "selected_material_changed" as well. Also fixed a couple of cases of drag not being properly ended. Change-Id: Ie1cae01ef13b687d9e611ac1c91443688001fe49 Reviewed-by: Mahmoud Badri <mahmoud.badri@qt.io>
This commit is contained in:
@@ -164,7 +164,7 @@ WidgetInfo MaterialBrowserView::widgetInfo()
|
||||
MaterialBrowserTexturesModel *texturesModel = m_widget->materialBrowserTexturesModel().data();
|
||||
connect(texturesModel, &MaterialBrowserTexturesModel::selectedIndexChanged, this, [&] (int idx) {
|
||||
ModelNode texNode = m_widget->materialBrowserTexturesModel()->textureAt(idx);
|
||||
emitCustomNotification("selected_texture_changed", {texNode}, {});
|
||||
emitCustomNotification("selected_texture_changed", {texNode});
|
||||
});
|
||||
connect(texturesModel, &MaterialBrowserTexturesModel::duplicateTextureTriggered, this,
|
||||
[&] (const ModelNode &texture) {
|
||||
@@ -499,14 +499,14 @@ void MaterialBrowserView::customNotification(const AbstractView *view,
|
||||
const QList<ModelNode> &nodeList,
|
||||
const QList<QVariant> &data)
|
||||
{
|
||||
if (view == this)
|
||||
if (view == this && identifier != "select_texture")
|
||||
return;
|
||||
|
||||
if (identifier == "selected_material_changed") {
|
||||
if (identifier == "select_material") {
|
||||
int idx = m_widget->materialBrowserModel()->materialIndex(nodeList.first());
|
||||
if (idx != -1)
|
||||
m_widget->materialBrowserModel()->selectMaterial(idx);
|
||||
} else if (identifier == "selected_texture_changed") {
|
||||
} else if (identifier == "select_texture") {
|
||||
int idx = m_widget->materialBrowserTexturesModel()->textureIndex(nodeList.first());
|
||||
if (idx != -1) {
|
||||
m_widget->materialBrowserTexturesModel()->selectTexture(idx);
|
||||
|
||||
Reference in New Issue
Block a user