forked from qt-creator/qt-creator
QmlDesigner: Take exportedTypeNamesChanged notifications into use
Added exportedTypeNamesChanged triggers for 3d view context menu update and asset menu .q3d files sync. Fixes: QDS-15158 Change-Id: I1bcb1659d70e4c52c75b21ea578f45c9c413d063 Reviewed-by: Mahmoud Badri <mahmoud.badri@qt.io>
This commit is contained in:
@@ -25,6 +25,7 @@
|
|||||||
#include <sqlitedatabase.h>
|
#include <sqlitedatabase.h>
|
||||||
#include <synchronousimagecache.h>
|
#include <synchronousimagecache.h>
|
||||||
#include <utils/algorithm.h>
|
#include <utils/algorithm.h>
|
||||||
|
#include <utils3d.h>
|
||||||
|
|
||||||
namespace QmlDesigner {
|
namespace QmlDesigner {
|
||||||
|
|
||||||
@@ -80,11 +81,14 @@ void AssetsLibraryView::customNotification(const AbstractView * /*view*/,
|
|||||||
const QList<ModelNode> & /*nodeList*/,
|
const QList<ModelNode> & /*nodeList*/,
|
||||||
const QList<QVariant> & /*data*/)
|
const QList<QVariant> & /*data*/)
|
||||||
{
|
{
|
||||||
if (identifier == "delete_selected_assets")
|
if (identifier == "delete_selected_assets") {
|
||||||
m_widget->deleteSelectedAssets();
|
m_widget->deleteSelectedAssets();
|
||||||
else if (identifier == "asset_import_finished")
|
} else if (identifier == "asset_import_finished") {
|
||||||
|
// TODO: This custom notification should be removed once QDS-15163 is fixed and
|
||||||
|
// exportedTypeNamesChanged notification is reliable
|
||||||
m_3dImportsSyncTimer.start();
|
m_3dImportsSyncTimer.start();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void AssetsLibraryView::modelAttached(Model *model)
|
void AssetsLibraryView::modelAttached(Model *model)
|
||||||
{
|
{
|
||||||
@@ -104,6 +108,13 @@ void AssetsLibraryView::modelAboutToBeDetached(Model *model)
|
|||||||
m_3dImportsSyncTimer.stop();
|
m_3dImportsSyncTimer.stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AssetsLibraryView::exportedTypeNamesChanged(const ExportedTypeNames &added,
|
||||||
|
const ExportedTypeNames &removed)
|
||||||
|
{
|
||||||
|
if (Utils3D::hasImported3dType(this, added, removed))
|
||||||
|
m_3dImportsSyncTimer.start();
|
||||||
|
}
|
||||||
|
|
||||||
void AssetsLibraryView::setResourcePath(const QString &resourcePath)
|
void AssetsLibraryView::setResourcePath(const QString &resourcePath)
|
||||||
{
|
{
|
||||||
if (resourcePath == m_lastResourcePath)
|
if (resourcePath == m_lastResourcePath)
|
||||||
@@ -148,10 +159,6 @@ void AssetsLibraryView::sync3dImports()
|
|||||||
if (!model())
|
if (!model())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// TODO: Once project storage supports notifications for new and removed types,
|
|
||||||
// sync3dImports() should be called in that case as well.
|
|
||||||
// Also, custom notification "asset_import_finished" should not be necessary in that case.
|
|
||||||
|
|
||||||
// Sync generated 3d imports to .q3d files in project content
|
// Sync generated 3d imports to .q3d files in project content
|
||||||
const GeneratedComponentUtils &compUtils
|
const GeneratedComponentUtils &compUtils
|
||||||
= QmlDesignerPlugin::instance()->documentManager().generatedComponentUtils();
|
= QmlDesignerPlugin::instance()->documentManager().generatedComponentUtils();
|
||||||
|
@@ -33,6 +33,9 @@ public:
|
|||||||
// AbstractView
|
// AbstractView
|
||||||
void modelAttached(Model *model) override;
|
void modelAttached(Model *model) override;
|
||||||
void modelAboutToBeDetached(Model *model) override;
|
void modelAboutToBeDetached(Model *model) override;
|
||||||
|
void exportedTypeNamesChanged(const ExportedTypeNames &added,
|
||||||
|
const ExportedTypeNames &removed) override;
|
||||||
|
|
||||||
void setResourcePath(const QString &resourcePath);
|
void setResourcePath(const QString &resourcePath);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@@ -566,5 +566,24 @@ void openNodeInPropertyEditor(const ModelNode &node)
|
|||||||
node.view()->emitCustomNotification("force_editing_node", {node}); // To PropertyEditor
|
node.view()->emitCustomNotification("force_editing_node", {node}); // To PropertyEditor
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool hasImported3dType(AbstractView *view,
|
||||||
|
const AbstractView::ExportedTypeNames &added,
|
||||||
|
const AbstractView::ExportedTypeNames &removed)
|
||||||
|
{
|
||||||
|
QTC_ASSERT(view && view->model(), return false);
|
||||||
|
|
||||||
|
using Storage::Info::ExportedTypeName;
|
||||||
|
|
||||||
|
const QByteArray import3dPrefix = QmlDesignerPlugin::instance()->documentManager()
|
||||||
|
.generatedComponentUtils().import3dTypePrefix().toUtf8();
|
||||||
|
|
||||||
|
auto generatedModuleIds = view->model()->moduleIdsStartsWith(import3dPrefix,
|
||||||
|
Storage::ModuleKind::QmlLibrary);
|
||||||
|
std::ranges::sort(generatedModuleIds);
|
||||||
|
|
||||||
|
return Utils::set_has_common_element(added, generatedModuleIds, {}, &ExportedTypeName::moduleId)
|
||||||
|
|| Utils::set_has_common_element(removed, generatedModuleIds, {}, &ExportedTypeName::moduleId);
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace Utils3D
|
} // namespace Utils3D
|
||||||
} // namespace QmlDesigner
|
} // namespace QmlDesigner
|
||||||
|
@@ -52,7 +52,9 @@ void duplicateMaterial(AbstractView *view, const ModelNode &material);
|
|||||||
bool addQuick3DImportAndView3D(AbstractView *view, bool suppressWarningDialog = false);
|
bool addQuick3DImportAndView3D(AbstractView *view, bool suppressWarningDialog = false);
|
||||||
void assignMaterialTo3dModel(AbstractView *view, const ModelNode &modelNode,
|
void assignMaterialTo3dModel(AbstractView *view, const ModelNode &modelNode,
|
||||||
const ModelNode &materialNode = {});
|
const ModelNode &materialNode = {});
|
||||||
|
bool hasImported3dType(AbstractView *view,
|
||||||
|
const AbstractView::ExportedTypeNames &added,
|
||||||
|
const AbstractView::ExportedTypeNames &removed);
|
||||||
|
|
||||||
} // namespace Utils3D
|
} // namespace Utils3D
|
||||||
} // namespace QmlDesigner
|
} // namespace QmlDesigner
|
||||||
|
@@ -317,8 +317,6 @@ void Edit3DView::modelAttached(Model *model)
|
|||||||
m_isBakingLightsSupported = qtVer->qtVersion() >= QVersionNumber(6, 5, 0);
|
m_isBakingLightsSupported = qtVer->qtVersion() >= QVersionNumber(6, 5, 0);
|
||||||
}
|
}
|
||||||
#ifdef QDS_USE_PROJECTSTORAGE
|
#ifdef QDS_USE_PROJECTSTORAGE
|
||||||
// TODO: Handle actual entries changed signal/notification once it is available.
|
|
||||||
// Until then, we simply get what entries are available at model attach time.
|
|
||||||
onEntriesChanged();
|
onEntriesChanged();
|
||||||
#else
|
#else
|
||||||
connect(model->metaInfo().itemLibraryInfo(),
|
connect(model->metaInfo().itemLibraryInfo(),
|
||||||
@@ -462,7 +460,9 @@ void Edit3DView::customNotification([[maybe_unused]] const AbstractView *view,
|
|||||||
self->m_pickView3dNode = self->modelNodeForInternalId(qint32(data[1].toInt()));
|
self->m_pickView3dNode = self->modelNodeForInternalId(qint32(data[1].toInt()));
|
||||||
});
|
});
|
||||||
} else if (identifier == "asset_import_finished" || identifier == "assets_deleted") {
|
} else if (identifier == "asset_import_finished" || identifier == "assets_deleted") {
|
||||||
handleEntriesChanged();
|
// TODO: These custom notifications should be removed once QDS-15163 is fixed and
|
||||||
|
// exportedTypeNamesChanged notification is reliable
|
||||||
|
onEntriesChanged();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -571,6 +571,13 @@ void Edit3DView::variantPropertiesChanged(const QList<VariantProperty> &property
|
|||||||
maybeStoreCurrentSceneEnvironment(propertyList);
|
maybeStoreCurrentSceneEnvironment(propertyList);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Edit3DView::exportedTypeNamesChanged(const ExportedTypeNames &added,
|
||||||
|
const ExportedTypeNames &removed)
|
||||||
|
{
|
||||||
|
if (Utils3D::hasImported3dType(this, added, removed))
|
||||||
|
onEntriesChanged();
|
||||||
|
}
|
||||||
|
|
||||||
void Edit3DView::sendInputEvent(QEvent *e) const
|
void Edit3DView::sendInputEvent(QEvent *e) const
|
||||||
{
|
{
|
||||||
if (isAttached())
|
if (isAttached())
|
||||||
|
@@ -80,7 +80,8 @@ public:
|
|||||||
PropertyChangeFlags propertyChange) override;
|
PropertyChangeFlags propertyChange) override;
|
||||||
void variantPropertiesChanged(const QList<VariantProperty> &propertyList,
|
void variantPropertiesChanged(const QList<VariantProperty> &propertyList,
|
||||||
PropertyChangeFlags propertyChange) override;
|
PropertyChangeFlags propertyChange) override;
|
||||||
|
void exportedTypeNamesChanged(const ExportedTypeNames &added,
|
||||||
|
const ExportedTypeNames &removed) override;
|
||||||
void sendInputEvent(QEvent *e) const;
|
void sendInputEvent(QEvent *e) const;
|
||||||
void edit3DViewResized(const QSize &size) const;
|
void edit3DViewResized(const QSize &size) const;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user