forked from qt-creator/qt-creator
QmlDesigner: Add dropped 3D models to the 3D Editor
When dragging 3D model file(s) from the file system and dropping them on the 3D Editor, add the models the the 3D Editor after importing them. Change-Id: I51ec945097a19e8895eb599b898d49e879100b6d Reviewed-by: Miikka Heikkinen <miikka.heikkinen@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
This commit is contained in:
@@ -23,14 +23,15 @@
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "edit3dwidget.h"
|
||||
#include "edit3dview.h"
|
||||
#include "edit3dcanvas.h"
|
||||
#include "edit3dactions.h"
|
||||
|
||||
#include "qmldesignerplugin.h"
|
||||
#include "designersettings.h"
|
||||
#include "edit3dactions.h"
|
||||
#include "edit3dcanvas.h"
|
||||
#include "edit3dview.h"
|
||||
#include "edit3dwidget.h"
|
||||
#include "metainfo.h"
|
||||
#include "qmldesignerconstants.h"
|
||||
#include "qmldesignerplugin.h"
|
||||
#include "qmlvisualnode.h"
|
||||
#include "viewmanager.h"
|
||||
|
||||
#include <coreplugin/actionmanager/actionmanager.h>
|
||||
@@ -174,7 +175,20 @@ void Edit3DWidget::dropEvent(QDropEvent *dropEvent)
|
||||
{
|
||||
const DesignerActionManager &actionManager = QmlDesignerPlugin::instance()
|
||||
->viewManager().designerActionManager();
|
||||
actionManager.handleExternalAssetsDrop(dropEvent->mimeData());
|
||||
QHash<QString, QStringList> addedAssets = actionManager.handleExternalAssetsDrop(dropEvent->mimeData());
|
||||
|
||||
// add 3D assets to 3d editor (QtQuick3D import will be added if missing)
|
||||
ItemLibraryInfo *itemLibInfo = m_view->model()->metaInfo().itemLibraryInfo();
|
||||
|
||||
const QStringList added3DAssets = addedAssets.value(ComponentCoreConstants::add3DAssetsDisplayString);
|
||||
for (const QString &assetPath : added3DAssets) {
|
||||
QString fileName = QFileInfo(assetPath).baseName();
|
||||
fileName = fileName.at(0).toUpper() + fileName.mid(1); // capitalize first letter
|
||||
QString type = QString("Quick3DAssets.%1.%1").arg(fileName);
|
||||
QList<ItemLibraryEntry> entriesForType = itemLibInfo->entriesForType(type.toLatin1());
|
||||
if (!entriesForType.isEmpty()) // should always be true, but just in case
|
||||
QmlVisualNode::createQml3DNode(view(), entriesForType.at(0), m_canvas->activeScene()).modelNode();
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace QmlDesigner
|
||||
|
||||
Reference in New Issue
Block a user