QML Designer: reload QML puppet when adding fonts

Automatically reload QML when importing fonts,
so that the newly added font can be viewed in 2D preview right away.

Note, this causes a visible flicker in the 2D preview.
If anyone has ideas how to make it smoother, I'm open to suggestions.

Fixes: QDS-14900
Change-Id: Ib7a354d0e25a087aabe690ebdafbf131b579dd40
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
This commit is contained in:
Andrii Semkiv
2025-03-11 13:56:02 +01:00
parent 4146d1bd01
commit 8996c4a9d8
3 changed files with 11 additions and 1 deletions

View File

@@ -1129,7 +1129,11 @@ static QString getAssetDefaultDirectory(const QString &assetDir, const QString &
AddFilesResult addFontToProject(const QStringList &fileNames, const QString &defaultDir, bool showDialog)
{
return addFilesToProject(fileNames, getAssetDefaultDirectory("fonts", defaultDir), showDialog);
const AddFilesResult result = addFilesToProject(fileNames,
getAssetDefaultDirectory("fonts", defaultDir),
showDialog);
QmlDesignerPlugin::viewManager().view()->resetPuppet();
return result;
}
AddFilesResult addSoundToProject(const QStringList &fileNames, const QString &defaultDir, bool showDialog)

View File

@@ -512,6 +512,11 @@ const AbstractView *ViewManager::view() const
return &d->nodeInstanceView;
}
AbstractView *ViewManager::view()
{
return &d->nodeInstanceView;
}
TextEditorView *ViewManager::textEditorView()
{
return &d->textEditorView;

View File

@@ -72,6 +72,7 @@ public:
void nextFileIsCalledInternally();
const AbstractView *view() const;
AbstractView *view();
TextEditorView *textEditorView();
void emitCustomNotification(const QString &identifier, const QList<ModelNode> &nodeList,