forked from qt-creator/qt-creator
QmlDesigner: Add a Text component when dropping a font to Form Editor
When dragging a font from the file system and dropping it on the Form Editor, create a Text component. Fixes: QDS-5272 Change-Id: I3ec9420f870732afac7d09688f1e459881d4aad3 Reviewed-by: Miikka Heikkinen <miikka.heikkinen@qt.io>
This commit is contained in:
@@ -599,12 +599,20 @@ void FormEditorWidget::dropEvent(QDropEvent *dropEvent)
|
||||
->viewManager().designerActionManager();
|
||||
QHash<QString, QStringList> addedAssets = actionManager.handleExternalAssetsDrop(dropEvent->mimeData());
|
||||
|
||||
// add image assets to Form Editor
|
||||
// Create Image components for added image assets
|
||||
const QStringList addedImages = addedAssets.value(ComponentCoreConstants::addImagesDisplayString);
|
||||
for (const QString &imgPath : addedImages) {
|
||||
QmlItemNode::createQmlItemNodeFromImage(m_formEditorView, imgPath, {},
|
||||
m_formEditorView->scene()->rootFormEditorItem()->qmlItemNode());
|
||||
}
|
||||
|
||||
// Create Text components for added font assets
|
||||
const QStringList addedFonts = addedAssets.value(ComponentCoreConstants::addFontsDisplayString);
|
||||
for (const QString &fontPath : addedFonts) {
|
||||
QString fontFamily = QFileInfo(fontPath).baseName();
|
||||
QmlItemNode::createQmlItemNodeFromFont(m_formEditorView, fontFamily, rootItemRect().center(),
|
||||
m_formEditorView->scene()->rootFormEditorItem()->qmlItemNode());
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace QmlDesigner
|
||||
|
||||
Reference in New Issue
Block a user