diff options
Diffstat (limited to 'src/plugins/qmldesigner/components/itemlibrary/itemlibrarywidget.cpp')
-rw-r--r-- | src/plugins/qmldesigner/components/itemlibrary/itemlibrarywidget.cpp | 32 |
1 files changed, 20 insertions, 12 deletions
diff --git a/src/plugins/qmldesigner/components/itemlibrary/itemlibrarywidget.cpp b/src/plugins/qmldesigner/components/itemlibrary/itemlibrarywidget.cpp index da056aaf6b..8010ed6107 100644 --- a/src/plugins/qmldesigner/components/itemlibrary/itemlibrarywidget.cpp +++ b/src/plugins/qmldesigner/components/itemlibrary/itemlibrarywidget.cpp @@ -209,19 +209,27 @@ ItemLibraryWidget::ItemLibraryWidget(QWidget *parent) : QSSGAssetImportManager importManager; QHash<QString, QStringList> supportedExtensions = importManager.getSupportedExtensions(); - // Skip if 3D model handlers have already been added + // All things importable by QSSGAssetImportManager are considered to be in the same category + // so we don't get multiple separate import dialogs when different file types are imported. + const QString category = tr("3D Assets"); + + // Skip if 3D asset handlers have already been added const QList<AddResourceHandler> handlers = actionManager->addResourceHandler(); - QSet<QString> handlerCats; - for (const auto &h : handlers) - handlerCats.insert(h.category); - - const auto categories = supportedExtensions.keys(); - for (const auto &category : categories) { - if (handlerCats.contains(category)) - continue; - const auto extensions = supportedExtensions[category]; - for (const auto &ext : extensions) - add3DHandler(category, ext); + bool categoryAlreadyAdded = false; + for (const auto &handler : handlers) { + if (handler.category == category) { + categoryAlreadyAdded = true; + break; + } + } + + if (!categoryAlreadyAdded) { + const auto groups = supportedExtensions.keys(); + for (const auto &group : groups) { + const auto extensions = supportedExtensions[group]; + for (const auto &ext : extensions) + add3DHandler(category, ext); + } } #endif |