forked from qt-creator/qt-creator
QmlDesigner: Update UI when an asset is reimported
Item library thumbnail and navigator icon are refreshed if asset is reimported, and the puppet is restarted in case the asset is in use. Change-Id: Ic5577eff3a24bcce87b504e9c059c29f6cb887a5 Fixes: QDS-1957 Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
This commit is contained in:
@@ -47,6 +47,8 @@ Item {
|
|||||||
width: itemLibraryIconWidth // to be set in Qml context
|
width: itemLibraryIconWidth // to be set in Qml context
|
||||||
height: itemLibraryIconHeight // to be set in Qml context
|
height: itemLibraryIconHeight // to be set in Qml context
|
||||||
source: itemLibraryIconPath // to be set by model
|
source: itemLibraryIconPath // to be set by model
|
||||||
|
|
||||||
|
cache: false // Allow thumbnail to be dynamically updated
|
||||||
}
|
}
|
||||||
|
|
||||||
Text {
|
Text {
|
||||||
|
@@ -179,6 +179,17 @@ void Edit3DView::importsChanged(const QList<Import> &addedImports,
|
|||||||
checkImports();
|
checkImports();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Edit3DView::customNotification(const AbstractView *view, const QString &identifier,
|
||||||
|
const QList<ModelNode> &nodeList, const QList<QVariant> &data)
|
||||||
|
{
|
||||||
|
Q_UNUSED(view)
|
||||||
|
Q_UNUSED(nodeList)
|
||||||
|
Q_UNUSED(data)
|
||||||
|
|
||||||
|
if (identifier == "asset_import_update")
|
||||||
|
resetPuppet();
|
||||||
|
}
|
||||||
|
|
||||||
void Edit3DView::sendInputEvent(QInputEvent *e) const
|
void Edit3DView::sendInputEvent(QInputEvent *e) const
|
||||||
{
|
{
|
||||||
if (nodeInstanceView())
|
if (nodeInstanceView())
|
||||||
|
@@ -58,6 +58,7 @@ public:
|
|||||||
void modelAttached(Model *model) override;
|
void modelAttached(Model *model) override;
|
||||||
void modelAboutToBeDetached(Model *model) override;
|
void modelAboutToBeDetached(Model *model) override;
|
||||||
void importsChanged(const QList<Import> &addedImports, const QList<Import> &removedImports) override;
|
void importsChanged(const QList<Import> &addedImports, const QList<Import> &removedImports) override;
|
||||||
|
void customNotification(const AbstractView *view, const QString &identifier, const QList<ModelNode> &nodeList, const QList<QVariant> &data) override;
|
||||||
|
|
||||||
void sendInputEvent(QInputEvent *e) const;
|
void sendInputEvent(QInputEvent *e) const;
|
||||||
void edit3DViewResized(const QSize &size) const;
|
void edit3DViewResized(const QSize &size) const;
|
||||||
|
@@ -87,8 +87,6 @@ void ImportManagerView::importsChanged(const QList<Import> &/*addedImports*/, co
|
|||||||
|
|
||||||
void ImportManagerView::possibleImportsChanged(const QList<Import> &/*possibleImports*/)
|
void ImportManagerView::possibleImportsChanged(const QList<Import> &/*possibleImports*/)
|
||||||
{
|
{
|
||||||
QmlDesignerPlugin::instance()->currentDesignDocument()->updateSubcomponentManager();
|
|
||||||
|
|
||||||
if (m_importsWidget)
|
if (m_importsWidget)
|
||||||
m_importsWidget->setPossibleImports(model()->possibleImports());
|
m_importsWidget->setPossibleImports(model()->possibleImports());
|
||||||
}
|
}
|
||||||
|
@@ -512,18 +512,24 @@ void ItemLibraryAssetImporter::finalizeQuick3DImport()
|
|||||||
addInfo(progressTitle);
|
addInfo(progressTitle);
|
||||||
notifyProgress(0, progressTitle);
|
notifyProgress(0, progressTitle);
|
||||||
|
|
||||||
// There is an inbuilt delay before rewriter change actually updates the data model,
|
// First we have to wait a while to ensure qmljs detects new files and updates its
|
||||||
// so we need to wait for a moment to allow the change to take effect.
|
// internal model. Then we make a non-change to the document to trigger qmljs snapshot
|
||||||
|
// update. There is an inbuilt delay before rewriter change actually updates the data
|
||||||
|
// model, so we need to wait for another moment to allow the change to take effect.
|
||||||
// Otherwise subsequent subcomponent manager update won't detect new imports properly.
|
// Otherwise subsequent subcomponent manager update won't detect new imports properly.
|
||||||
QTimer *timer = new QTimer(parent());
|
QTimer *timer = new QTimer(parent());
|
||||||
static int counter;
|
static int counter;
|
||||||
counter = 0;
|
counter = 0;
|
||||||
timer->callOnTimeout([this, timer, progressTitle, model]() {
|
timer->callOnTimeout([this, timer, progressTitle, model, doc]() {
|
||||||
if (!isCancelled()) {
|
if (!isCancelled()) {
|
||||||
notifyProgress(++counter * 10, progressTitle);
|
notifyProgress(++counter * 5, progressTitle);
|
||||||
if (counter >= 10) {
|
if (counter == 10) {
|
||||||
// Trigger underlying qmljs snapshot update by making a non-change to the doc
|
|
||||||
model->rewriterView()->textModifier()->replace(0, 0, {});
|
model->rewriterView()->textModifier()->replace(0, 0, {});
|
||||||
|
} else if (counter == 19) {
|
||||||
|
doc->updateSubcomponentManager();
|
||||||
|
} else if (counter >= 20) {
|
||||||
|
if (!m_overwrittenImports.isEmpty())
|
||||||
|
model->rewriterView()->emitCustomNotification("asset_import_update");
|
||||||
timer->stop();
|
timer->stop();
|
||||||
notifyFinished();
|
notifyFinished();
|
||||||
}
|
}
|
||||||
|
@@ -43,6 +43,7 @@ public:
|
|||||||
virtual void notifyModelNodesRemoved(const QList<ModelNode> &modelNodes) = 0;
|
virtual void notifyModelNodesRemoved(const QList<ModelNode> &modelNodes) = 0;
|
||||||
virtual void notifyModelNodesInserted(const QList<ModelNode> &modelNodes) = 0;
|
virtual void notifyModelNodesInserted(const QList<ModelNode> &modelNodes) = 0;
|
||||||
virtual void notifyModelNodesMoved(const QList<ModelNode> &modelNodes) = 0;
|
virtual void notifyModelNodesMoved(const QList<ModelNode> &modelNodes) = 0;
|
||||||
|
virtual void notifyIconsChanged() = 0;
|
||||||
virtual void setFilter(bool showObjects) = 0;
|
virtual void setFilter(bool showObjects) = 0;
|
||||||
virtual void resetModel() = 0;
|
virtual void resetModel() = 0;
|
||||||
};
|
};
|
||||||
|
@@ -695,6 +695,11 @@ void NavigatorTreeModel::notifyModelNodesMoved(const QList<ModelNode> &modelNode
|
|||||||
emit layoutChanged(indexes);
|
emit layoutChanged(indexes);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void NavigatorTreeModel::notifyIconsChanged()
|
||||||
|
{
|
||||||
|
emit dataChanged(index(0, 0), index(rowCount(), 0), {Qt::DecorationRole});
|
||||||
|
}
|
||||||
|
|
||||||
void NavigatorTreeModel::setFilter(bool showOnlyVisibleItems)
|
void NavigatorTreeModel::setFilter(bool showOnlyVisibleItems)
|
||||||
{
|
{
|
||||||
m_showOnlyVisibleItems = showOnlyVisibleItems;
|
m_showOnlyVisibleItems = showOnlyVisibleItems;
|
||||||
|
@@ -87,6 +87,7 @@ public:
|
|||||||
void notifyModelNodesRemoved(const QList<ModelNode> &modelNodes) override;
|
void notifyModelNodesRemoved(const QList<ModelNode> &modelNodes) override;
|
||||||
void notifyModelNodesInserted(const QList<ModelNode> &modelNodes) override;
|
void notifyModelNodesInserted(const QList<ModelNode> &modelNodes) override;
|
||||||
void notifyModelNodesMoved(const QList<ModelNode> &modelNodes) override;
|
void notifyModelNodesMoved(const QList<ModelNode> &modelNodes) override;
|
||||||
|
void notifyIconsChanged() override;
|
||||||
void setFilter(bool showOnlyVisibleItems) override;
|
void setFilter(bool showOnlyVisibleItems) override;
|
||||||
void resetModel() override;
|
void resetModel() override;
|
||||||
|
|
||||||
|
@@ -147,6 +147,17 @@ void NavigatorView::bindingPropertiesChanged(const QList<BindingProperty> & prop
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void NavigatorView::customNotification(const AbstractView *view, const QString &identifier,
|
||||||
|
const QList<ModelNode> &nodeList, const QList<QVariant> &data)
|
||||||
|
{
|
||||||
|
Q_UNUSED(view)
|
||||||
|
Q_UNUSED(nodeList)
|
||||||
|
Q_UNUSED(data)
|
||||||
|
|
||||||
|
if (identifier == "asset_import_update")
|
||||||
|
m_currentModelInterface->notifyIconsChanged();
|
||||||
|
}
|
||||||
|
|
||||||
void NavigatorView::handleChangedExport(const ModelNode &modelNode, bool exported)
|
void NavigatorView::handleChangedExport(const ModelNode &modelNode, bool exported)
|
||||||
{
|
{
|
||||||
const ModelNode rootNode = rootModelNode();
|
const ModelNode rootNode = rootModelNode();
|
||||||
|
@@ -84,6 +84,8 @@ public:
|
|||||||
|
|
||||||
void bindingPropertiesChanged(const QList<BindingProperty> &propertyList, PropertyChangeFlags) override;
|
void bindingPropertiesChanged(const QList<BindingProperty> &propertyList, PropertyChangeFlags) override;
|
||||||
|
|
||||||
|
void customNotification(const AbstractView *view, const QString &identifier, const QList<ModelNode> &nodeList, const QList<QVariant> &data) override;
|
||||||
|
|
||||||
void handleChangedExport(const ModelNode &modelNode, bool exported);
|
void handleChangedExport(const ModelNode &modelNode, bool exported);
|
||||||
bool isNodeInvisible(const ModelNode &modelNode) const;
|
bool isNodeInvisible(const ModelNode &modelNode) const;
|
||||||
|
|
||||||
|
@@ -420,8 +420,7 @@ void SubComponentManager::parseQuick3DAssetDir(const QString &assetPath)
|
|||||||
itemLibraryEntry.addHints(hints);
|
itemLibraryEntry.addHints(hints);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!model()->metaInfo().itemLibraryInfo()->containsEntry(itemLibraryEntry))
|
model()->metaInfo().itemLibraryInfo()->addEntries({itemLibraryEntry}, true);
|
||||||
model()->metaInfo().itemLibraryInfo()->addEntries({itemLibraryEntry});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user