forked from qt-creator/qt-creator
QmlDesigner: Use only 1 content library importer for all bundles
Change-Id: I59e8efda2e5704caf72297b8dee5178eb8ecfc71 Reviewed-by: Miikka Heikkinen <miikka.heikkinen@qt.io> Reviewed-by: Qt CI Patch Build Bot <ci_patchbuild_bot@qt.io>
This commit is contained in:
@@ -23,7 +23,7 @@ Item {
|
|||||||
acceptedButtons: Qt.LeftButton | Qt.RightButton
|
acceptedButtons: Qt.LeftButton | Qt.RightButton
|
||||||
|
|
||||||
onPressed: (mouse) => {
|
onPressed: (mouse) => {
|
||||||
if (mouse.button === Qt.LeftButton && !ContentLibraryBackend.effectsModel.importerRunning)
|
if (mouse.button === Qt.LeftButton && !ContentLibraryBackend.rootView.importerRunning)
|
||||||
ContentLibraryBackend.rootView.startDragEffect(modelData, mapToGlobal(mouse.x, mouse.y))
|
ContentLibraryBackend.rootView.startDragEffect(modelData, mapToGlobal(mouse.x, mouse.y))
|
||||||
else if (mouse.button === Qt.RightButton)
|
else if (mouse.button === Qt.RightButton)
|
||||||
root.showContextMenu()
|
root.showContextMenu()
|
||||||
|
@@ -12,7 +12,7 @@ StudioControls.Menu {
|
|||||||
|
|
||||||
property var targetItem: null
|
property var targetItem: null
|
||||||
|
|
||||||
readonly property bool targetAvailable: targetItem && !ContentLibraryBackend.effectsModel.importerRunning
|
readonly property bool targetAvailable: targetItem && !ContentLibraryBackend.rootView.importerRunning
|
||||||
|
|
||||||
signal unimport(var bundleEff);
|
signal unimport(var bundleEff);
|
||||||
|
|
||||||
|
@@ -50,7 +50,7 @@ HelperWidgets.ScrollView {
|
|||||||
id: ctxMenu
|
id: ctxMenu
|
||||||
|
|
||||||
hasModelSelection: root.materialsModel.hasModelSelection
|
hasModelSelection: root.materialsModel.hasModelSelection
|
||||||
importerRunning: root.materialsModel.importerRunning
|
importerRunning: ContentLibraryBackend.rootView.importerRunning
|
||||||
|
|
||||||
onApplyToSelected: (add) => root.materialsModel.applyToSelected(ctxMenu.targetMaterial, add)
|
onApplyToSelected: (add) => root.materialsModel.applyToSelected(ctxMenu.targetMaterial, add)
|
||||||
|
|
||||||
@@ -103,7 +103,7 @@ HelperWidgets.ScrollView {
|
|||||||
width: root.cellWidth
|
width: root.cellWidth
|
||||||
height: root.cellHeight
|
height: root.cellHeight
|
||||||
|
|
||||||
importerRunning: root.materialsModel.importerRunning
|
importerRunning: ContentLibraryBackend.rootView.importerRunning
|
||||||
|
|
||||||
onShowContextMenu: ctxMenu.popupMenu(modelData)
|
onShowContextMenu: ctxMenu.popupMenu(modelData)
|
||||||
onAddToProject: root.materialsModel.addToProject(modelData)
|
onAddToProject: root.materialsModel.addToProject(modelData)
|
||||||
|
@@ -52,7 +52,7 @@ HelperWidgets.ScrollView {
|
|||||||
|
|
||||||
enableRemove: true
|
enableRemove: true
|
||||||
hasModelSelection: ContentLibraryBackend.userModel.hasModelSelection
|
hasModelSelection: ContentLibraryBackend.userModel.hasModelSelection
|
||||||
importerRunning: ContentLibraryBackend.userModel.importerRunning
|
importerRunning: ContentLibraryBackend.rootView.importerRunning
|
||||||
|
|
||||||
onApplyToSelected: (add) => ContentLibraryBackend.userModel.applyToSelected(ctxMenuMaterial.targetMaterial, add)
|
onApplyToSelected: (add) => ContentLibraryBackend.userModel.applyToSelected(ctxMenuMaterial.targetMaterial, add)
|
||||||
|
|
||||||
@@ -114,7 +114,7 @@ HelperWidgets.ScrollView {
|
|||||||
width: root.cellWidth
|
width: root.cellWidth
|
||||||
height: root.cellHeight
|
height: root.cellHeight
|
||||||
|
|
||||||
importerRunning: ContentLibraryBackend.userModel.importerRunning
|
importerRunning: ContentLibraryBackend.rootView.importerRunning
|
||||||
|
|
||||||
onShowContextMenu: ctxMenuMaterial.popupMenu(modelData)
|
onShowContextMenu: ctxMenuMaterial.popupMenu(modelData)
|
||||||
onAddToProject: ContentLibraryBackend.userModel.addToProject(modelData)
|
onAddToProject: ContentLibraryBackend.userModel.addToProject(modelData)
|
||||||
|
@@ -3,12 +3,13 @@
|
|||||||
|
|
||||||
#include "contentlibrarybundleimporter.h"
|
#include "contentlibrarybundleimporter.h"
|
||||||
|
|
||||||
#include "documentmanager.h"
|
#include <documentmanager.h>
|
||||||
#include "import.h"
|
#include <import.h>
|
||||||
#include "model.h"
|
#include <model.h>
|
||||||
#include "qmldesignerconstants.h"
|
#include <nodemetainfo.h>
|
||||||
#include "qmldesignerplugin.h"
|
#include <qmldesignerconstants.h>
|
||||||
#include "rewritingexception.h"
|
#include <qmldesignerplugin.h>
|
||||||
|
#include <rewritingexception.h>
|
||||||
|
|
||||||
#include <qmljs/qmljsmodelmanagerinterface.h>
|
#include <qmljs/qmljsmodelmanagerinterface.h>
|
||||||
|
|
||||||
@@ -37,10 +38,10 @@ QString ContentLibraryBundleImporter::importComponent(const QString &bundleDir,
|
|||||||
const QStringList &files)
|
const QStringList &files)
|
||||||
{
|
{
|
||||||
QString module = QString::fromLatin1(type.left(type.lastIndexOf('.')));
|
QString module = QString::fromLatin1(type.left(type.lastIndexOf('.')));
|
||||||
QString bundleId = module.mid(module.lastIndexOf('.') + 1);
|
m_bundleId = module.mid(module.lastIndexOf('.') + 1);
|
||||||
|
|
||||||
FilePath bundleDirPath = FilePath::fromString(bundleDir); // source dir
|
FilePath bundleDirPath = FilePath::fromString(bundleDir); // source dir
|
||||||
FilePath bundleImportPath = resolveBundleImportPath(bundleId); // target dir
|
FilePath bundleImportPath = resolveBundleImportPath(m_bundleId); // target dir
|
||||||
|
|
||||||
if (bundleImportPath.isEmpty())
|
if (bundleImportPath.isEmpty())
|
||||||
return "Failed to resolve bundle import folder";
|
return "Failed to resolve bundle import folder";
|
||||||
@@ -145,9 +146,11 @@ void ContentLibraryBundleImporter::handleImportTimer()
|
|||||||
for (const TypeName &pendingType : pendingTypes) {
|
for (const TypeName &pendingType : pendingTypes) {
|
||||||
m_pendingTypes.remove(pendingType);
|
m_pendingTypes.remove(pendingType);
|
||||||
if (m_pendingTypes.value(pendingType))
|
if (m_pendingTypes.value(pendingType))
|
||||||
emit importFinished({});
|
emit importFinished({}, m_bundleId);
|
||||||
else
|
else
|
||||||
emit unimportFinished({});
|
emit unimportFinished({}, m_bundleId);
|
||||||
|
|
||||||
|
m_bundleId.clear();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -193,12 +196,14 @@ void ContentLibraryBundleImporter::handleImportTimer()
|
|||||||
m_pendingTypes.remove(pendingType);
|
m_pendingTypes.remove(pendingType);
|
||||||
if (isImport)
|
if (isImport)
|
||||||
#ifdef QDS_USE_PROJECTSTORAGE
|
#ifdef QDS_USE_PROJECTSTORAGE
|
||||||
emit importFinished(pendingType);
|
emit importFinished(pendingType, m_bundleId);
|
||||||
#else
|
#else
|
||||||
emit importFinished(metaInfo);
|
emit importFinished(metaInfo, m_bundleId);
|
||||||
#endif
|
#endif
|
||||||
else
|
else
|
||||||
emit unimportFinished(metaInfo);
|
emit unimportFinished(metaInfo, m_bundleId);
|
||||||
|
|
||||||
|
m_bundleId.clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -208,10 +213,10 @@ void ContentLibraryBundleImporter::handleImportTimer()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QVariantHash ContentLibraryBundleImporter::loadAssetRefMap(const Utils::FilePath &bundlePath)
|
QVariantHash ContentLibraryBundleImporter::loadAssetRefMap(const FilePath &bundlePath)
|
||||||
{
|
{
|
||||||
FilePath assetRefPath = bundlePath.resolvePath(QLatin1String(Constants::COMPONENT_BUNDLES_ASSET_REF_FILE));
|
FilePath assetRefPath = bundlePath.resolvePath(QLatin1String(Constants::COMPONENT_BUNDLES_ASSET_REF_FILE));
|
||||||
const Utils::expected_str<QByteArray> content = assetRefPath.fileContents();
|
const expected_str<QByteArray> content = assetRefPath.fileContents();
|
||||||
if (content) {
|
if (content) {
|
||||||
QJsonParseError error;
|
QJsonParseError error;
|
||||||
QJsonDocument bundleDataJsonDoc = QJsonDocument::fromJson(*content, &error);
|
QJsonDocument bundleDataJsonDoc = QJsonDocument::fromJson(*content, &error);
|
||||||
@@ -225,7 +230,7 @@ QVariantHash ContentLibraryBundleImporter::loadAssetRefMap(const Utils::FilePath
|
|||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
void ContentLibraryBundleImporter::writeAssetRefMap(const Utils::FilePath &bundlePath,
|
void ContentLibraryBundleImporter::writeAssetRefMap(const FilePath &bundlePath,
|
||||||
const QVariantHash &assetRefMap)
|
const QVariantHash &assetRefMap)
|
||||||
{
|
{
|
||||||
FilePath assetRefPath = bundlePath.resolvePath(QLatin1String(Constants::COMPONENT_BUNDLES_ASSET_REF_FILE));
|
FilePath assetRefPath = bundlePath.resolvePath(QLatin1String(Constants::COMPONENT_BUNDLES_ASSET_REF_FILE));
|
||||||
@@ -239,9 +244,11 @@ void ContentLibraryBundleImporter::writeAssetRefMap(const Utils::FilePath &bundl
|
|||||||
QString ContentLibraryBundleImporter::unimportComponent(const TypeName &type, const QString &qmlFile)
|
QString ContentLibraryBundleImporter::unimportComponent(const TypeName &type, const QString &qmlFile)
|
||||||
{
|
{
|
||||||
QString module = QString::fromLatin1(type.left(type.lastIndexOf('.')));
|
QString module = QString::fromLatin1(type.left(type.lastIndexOf('.')));
|
||||||
QString bundleId = module.mid(module.lastIndexOf('.') + 1);
|
m_bundleId = module.mid(module.lastIndexOf('.') + 1);
|
||||||
|
|
||||||
FilePath bundleImportPath = resolveBundleImportPath(bundleId);
|
emit aboutToUnimport(type, m_bundleId);
|
||||||
|
|
||||||
|
FilePath bundleImportPath = resolveBundleImportPath(m_bundleId);
|
||||||
if (bundleImportPath.isEmpty())
|
if (bundleImportPath.isEmpty())
|
||||||
return QStringLiteral("Failed to resolve bundle import folder for: '%1'").arg(qmlFile);
|
return QStringLiteral("Failed to resolve bundle import folder for: '%1'").arg(qmlFile);
|
||||||
|
|
||||||
|
@@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <nodemetainfo.h>
|
#include <modelfwd.h>
|
||||||
|
|
||||||
#include <utils/filepath.h>
|
#include <utils/filepath.h>
|
||||||
|
|
||||||
@@ -12,6 +12,8 @@
|
|||||||
|
|
||||||
namespace QmlDesigner {
|
namespace QmlDesigner {
|
||||||
|
|
||||||
|
class NodeMetaInfo;
|
||||||
|
|
||||||
class ContentLibraryBundleImporter : public QObject
|
class ContentLibraryBundleImporter : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@@ -30,11 +32,12 @@ signals:
|
|||||||
// asynchronous part of the import. In this case all remaining pending imports have been
|
// asynchronous part of the import. In this case all remaining pending imports have been
|
||||||
// terminated, and will not receive separate importFinished notifications.
|
// terminated, and will not receive separate importFinished notifications.
|
||||||
#ifdef QDS_USE_PROJECTSTORAGE
|
#ifdef QDS_USE_PROJECTSTORAGE
|
||||||
void importFinished(const QmlDesigner::TypeName &typeName);
|
void importFinished(const QmlDesigner::TypeName &typeName, const QString &bundleId);
|
||||||
#else
|
#else
|
||||||
void importFinished(const QmlDesigner::NodeMetaInfo &metaInfo);
|
void importFinished(const QmlDesigner::NodeMetaInfo &metaInfo, const QString &bundleId);
|
||||||
#endif
|
#endif
|
||||||
void unimportFinished(const QmlDesigner::NodeMetaInfo &metaInfo);
|
void unimportFinished(const QmlDesigner::NodeMetaInfo &metaInfo, const QString &bundleId);
|
||||||
|
void aboutToUnimport(const TypeName &type, const QString &bundleId);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void handleImportTimer();
|
void handleImportTimer();
|
||||||
@@ -44,6 +47,7 @@ private:
|
|||||||
QTimer m_importTimer;
|
QTimer m_importTimer;
|
||||||
int m_importTimerCount = 0;
|
int m_importTimerCount = 0;
|
||||||
QString m_pendingImport;
|
QString m_pendingImport;
|
||||||
|
QString m_bundleId;
|
||||||
bool m_fullReset = false;
|
bool m_fullReset = false;
|
||||||
QHash<TypeName, bool> m_pendingTypes; // <type, isImport>
|
QHash<TypeName, bool> m_pendingTypes; // <type, isImport>
|
||||||
};
|
};
|
||||||
|
@@ -63,6 +63,11 @@ bool ContentLibraryEffectsModel::isValidIndex(int idx) const
|
|||||||
return idx > -1 && idx < rowCount();
|
return idx > -1 && idx < rowCount();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString ContentLibraryEffectsModel::bundleId() const
|
||||||
|
{
|
||||||
|
return m_bundleId;
|
||||||
|
}
|
||||||
|
|
||||||
void ContentLibraryEffectsModel::updateIsEmpty()
|
void ContentLibraryEffectsModel::updateIsEmpty()
|
||||||
{
|
{
|
||||||
bool anyCatVisible = Utils::anyOf(m_bundleCategories, [&](ContentLibraryEffectsCategory *cat) {
|
bool anyCatVisible = Utils::anyOf(m_bundleCategories, [&](ContentLibraryEffectsCategory *cat) {
|
||||||
@@ -88,48 +93,6 @@ QHash<int, QByteArray> ContentLibraryEffectsModel::roleNames() const
|
|||||||
return roles;
|
return roles;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ContentLibraryEffectsModel::createImporter()
|
|
||||||
{
|
|
||||||
m_importer = new ContentLibraryBundleImporter();
|
|
||||||
#ifdef QDS_USE_PROJECTSTORAGE
|
|
||||||
connect(m_importer,
|
|
||||||
&ContentLibraryBundleImporter::importFinished,
|
|
||||||
this,
|
|
||||||
[&](const QmlDesigner::TypeName &typeName) {
|
|
||||||
m_importerRunning = false;
|
|
||||||
emit importerRunningChanged();
|
|
||||||
if (typeName.size()) {
|
|
||||||
emit bundleItemImported(typeName);
|
|
||||||
updateImportedState();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
#else
|
|
||||||
connect(m_importer,
|
|
||||||
&ContentLibraryBundleImporter::importFinished,
|
|
||||||
this,
|
|
||||||
[&](const QmlDesigner::NodeMetaInfo &metaInfo) {
|
|
||||||
m_importerRunning = false;
|
|
||||||
emit importerRunningChanged();
|
|
||||||
if (metaInfo.isValid()) {
|
|
||||||
emit bundleItemImported(metaInfo);
|
|
||||||
updateImportedState();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
#endif
|
|
||||||
|
|
||||||
connect(m_importer, &ContentLibraryBundleImporter::unimportFinished, this,
|
|
||||||
[&](const QmlDesigner::NodeMetaInfo &metaInfo) {
|
|
||||||
Q_UNUSED(metaInfo)
|
|
||||||
m_importerRunning = false;
|
|
||||||
emit importerRunningChanged();
|
|
||||||
emit bundleItemUnimported(metaInfo);
|
|
||||||
updateImportedState();
|
|
||||||
});
|
|
||||||
|
|
||||||
resetModel();
|
|
||||||
updateIsEmpty();
|
|
||||||
}
|
|
||||||
|
|
||||||
void ContentLibraryEffectsModel::loadBundle()
|
void ContentLibraryEffectsModel::loadBundle()
|
||||||
{
|
{
|
||||||
if (m_bundleExists || m_probeBundleDir)
|
if (m_bundleExists || m_probeBundleDir)
|
||||||
@@ -172,11 +135,9 @@ void ContentLibraryEffectsModel::loadBundle()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QString bundleType = QmlDesignerPlugin::instance()->documentManager()
|
auto compUtils = QmlDesignerPlugin::instance()->documentManager().generatedComponentUtils();
|
||||||
.generatedComponentUtils().effectsBundleType();
|
QString bundleType = compUtils.effectsBundleType();
|
||||||
|
m_bundleId = compUtils.effectsBundleId();
|
||||||
// Substitute correct id to avoid issues with old bundles
|
|
||||||
m_bundleObj["id"] = bundleType.split('.').last();
|
|
||||||
|
|
||||||
const QJsonObject catsObj = m_bundleObj.value("categories").toObject();
|
const QJsonObject catsObj = m_bundleObj.value("categories").toObject();
|
||||||
const QStringList categories = catsObj.keys();
|
const QStringList categories = catsObj.keys();
|
||||||
@@ -205,12 +166,13 @@ void ContentLibraryEffectsModel::loadBundle()
|
|||||||
m_bundleCategories.append(category);
|
m_bundleCategories.append(category);
|
||||||
}
|
}
|
||||||
|
|
||||||
m_importerSharedFiles.clear();
|
m_bundleSharedFiles.clear();
|
||||||
const QJsonArray sharedFilesArr = m_bundleObj.value("sharedFiles").toArray();
|
const QJsonArray sharedFilesArr = m_bundleObj.value("sharedFiles").toArray();
|
||||||
for (const QJsonValueConstRef &file : sharedFilesArr)
|
for (const QJsonValueConstRef &file : sharedFilesArr)
|
||||||
m_importerSharedFiles.append(file.toString());
|
m_bundleSharedFiles.append(file.toString());
|
||||||
|
|
||||||
createImporter();
|
resetModel();
|
||||||
|
updateIsEmpty();
|
||||||
m_bundlePath = bundleDir.path();
|
m_bundlePath = bundleDir.path();
|
||||||
m_bundleExists = true;
|
m_bundleExists = true;
|
||||||
emit bundleExistsChanged();
|
emit bundleExistsChanged();
|
||||||
@@ -226,11 +188,6 @@ bool ContentLibraryEffectsModel::bundleExists() const
|
|||||||
return m_bundleExists;
|
return m_bundleExists;
|
||||||
}
|
}
|
||||||
|
|
||||||
ContentLibraryBundleImporter *ContentLibraryEffectsModel::bundleImporter() const
|
|
||||||
{
|
|
||||||
return m_importer;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ContentLibraryEffectsModel::setSearchText(const QString &searchText)
|
void ContentLibraryEffectsModel::setSearchText(const QString &searchText)
|
||||||
{
|
{
|
||||||
QString lowerSearchText = searchText.toLower();
|
QString lowerSearchText = searchText.toLower();
|
||||||
@@ -250,20 +207,8 @@ void ContentLibraryEffectsModel::setSearchText(const QString &searchText)
|
|||||||
updateIsEmpty();
|
updateIsEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ContentLibraryEffectsModel::updateImportedState()
|
void ContentLibraryEffectsModel::updateImportedState(const QStringList &importedItems)
|
||||||
{
|
{
|
||||||
if (!m_importer)
|
|
||||||
return;
|
|
||||||
|
|
||||||
QString bundleId = m_bundleObj.value("id").toString();
|
|
||||||
Utils::FilePath bundlePath = m_importer->resolveBundleImportPath(bundleId);
|
|
||||||
|
|
||||||
QStringList importedItems;
|
|
||||||
if (bundlePath.exists()) {
|
|
||||||
importedItems = transform(bundlePath.dirEntries({{"*.qml"}, QDir::Files}),
|
|
||||||
[](const Utils::FilePath &f) { return f.baseName(); });
|
|
||||||
}
|
|
||||||
|
|
||||||
bool changed = false;
|
bool changed = false;
|
||||||
for (ContentLibraryEffectsCategory *cat : std::as_const(m_bundleCategories))
|
for (ContentLibraryEffectsCategory *cat : std::as_const(m_bundleCategories))
|
||||||
changed |= cat->updateImportedState(importedItems);
|
changed |= cat->updateImportedState(importedItems);
|
||||||
@@ -297,29 +242,24 @@ void ContentLibraryEffectsModel::resetModel()
|
|||||||
|
|
||||||
void ContentLibraryEffectsModel::addInstance(ContentLibraryEffect *bundleItem)
|
void ContentLibraryEffectsModel::addInstance(ContentLibraryEffect *bundleItem)
|
||||||
{
|
{
|
||||||
QString err = m_importer->importComponent(m_bundlePath, bundleItem->type(), bundleItem->qml(),
|
QString err = m_widget->importer()->importComponent(m_bundlePath, bundleItem->type(),
|
||||||
bundleItem->files() + m_importerSharedFiles);
|
bundleItem->qml(),
|
||||||
|
bundleItem->files() + m_bundleSharedFiles);
|
||||||
|
|
||||||
if (err.isEmpty()) {
|
if (err.isEmpty())
|
||||||
m_importerRunning = true;
|
m_widget->setImporterRunning(true);
|
||||||
emit importerRunningChanged();
|
else
|
||||||
} else {
|
|
||||||
qWarning() << __FUNCTION__ << err;
|
qWarning() << __FUNCTION__ << err;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ContentLibraryEffectsModel::removeFromProject(ContentLibraryEffect *bundleItem)
|
void ContentLibraryEffectsModel::removeFromProject(ContentLibraryEffect *bundleItem)
|
||||||
{
|
{
|
||||||
emit bundleItemAboutToUnimport(bundleItem->type());
|
QString err = m_widget->importer()->unimportComponent(bundleItem->type(), bundleItem->qml());
|
||||||
|
|
||||||
QString err = m_importer->unimportComponent(bundleItem->type(), bundleItem->qml());
|
if (err.isEmpty())
|
||||||
|
m_widget->setImporterRunning(true);
|
||||||
if (err.isEmpty()) {
|
else
|
||||||
m_importerRunning = true;
|
|
||||||
emit importerRunningChanged();
|
|
||||||
} else {
|
|
||||||
qWarning() << __FUNCTION__ << err;
|
qWarning() << __FUNCTION__ << err;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace QmlDesigner
|
} // namespace QmlDesigner
|
||||||
|
@@ -3,15 +3,11 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "nodemetainfo.h"
|
|
||||||
|
|
||||||
#include <QAbstractListModel>
|
#include <QAbstractListModel>
|
||||||
#include <QDir>
|
|
||||||
#include <QJsonObject>
|
#include <QJsonObject>
|
||||||
|
|
||||||
namespace QmlDesigner {
|
namespace QmlDesigner {
|
||||||
|
|
||||||
class ContentLibraryBundleImporter;
|
|
||||||
class ContentLibraryEffect;
|
class ContentLibraryEffect;
|
||||||
class ContentLibraryEffectsCategory;
|
class ContentLibraryEffectsCategory;
|
||||||
class ContentLibraryWidget;
|
class ContentLibraryWidget;
|
||||||
@@ -23,7 +19,6 @@ class ContentLibraryEffectsModel : public QAbstractListModel
|
|||||||
Q_PROPERTY(bool bundleExists READ bundleExists NOTIFY bundleExistsChanged)
|
Q_PROPERTY(bool bundleExists READ bundleExists NOTIFY bundleExistsChanged)
|
||||||
Q_PROPERTY(bool isEmpty MEMBER m_isEmpty NOTIFY isEmptyChanged)
|
Q_PROPERTY(bool isEmpty MEMBER m_isEmpty NOTIFY isEmptyChanged)
|
||||||
Q_PROPERTY(bool hasRequiredQuick3DImport READ hasRequiredQuick3DImport NOTIFY hasRequiredQuick3DImportChanged)
|
Q_PROPERTY(bool hasRequiredQuick3DImport READ hasRequiredQuick3DImport NOTIFY hasRequiredQuick3DImportChanged)
|
||||||
Q_PROPERTY(bool importerRunning MEMBER m_importerRunning NOTIFY importerRunningChanged)
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ContentLibraryEffectsModel(ContentLibraryWidget *parent = nullptr);
|
ContentLibraryEffectsModel(ContentLibraryWidget *parent = nullptr);
|
||||||
@@ -35,7 +30,7 @@ public:
|
|||||||
|
|
||||||
void loadBundle();
|
void loadBundle();
|
||||||
void setSearchText(const QString &searchText);
|
void setSearchText(const QString &searchText);
|
||||||
void updateImportedState();
|
void updateImportedState(const QStringList &importedItems);
|
||||||
|
|
||||||
void setQuick3DImportVersion(int major, int minor);
|
void setQuick3DImportVersion(int major, int minor);
|
||||||
|
|
||||||
@@ -46,40 +41,30 @@ public:
|
|||||||
void resetModel();
|
void resetModel();
|
||||||
void updateIsEmpty();
|
void updateIsEmpty();
|
||||||
|
|
||||||
ContentLibraryBundleImporter *bundleImporter() const;
|
|
||||||
|
|
||||||
Q_INVOKABLE void addInstance(QmlDesigner::ContentLibraryEffect *bundleItem);
|
Q_INVOKABLE void addInstance(QmlDesigner::ContentLibraryEffect *bundleItem);
|
||||||
Q_INVOKABLE void removeFromProject(QmlDesigner::ContentLibraryEffect *bundleItem);
|
Q_INVOKABLE void removeFromProject(QmlDesigner::ContentLibraryEffect *bundleItem);
|
||||||
|
|
||||||
|
QString bundleId() const;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void isEmptyChanged();
|
void isEmptyChanged();
|
||||||
void hasRequiredQuick3DImportChanged();
|
void hasRequiredQuick3DImportChanged();
|
||||||
#ifdef QDS_USE_PROJECTSTORAGE
|
|
||||||
void bundleItemImported(const QmlDesigner::TypeName &typeName);
|
|
||||||
#else
|
|
||||||
void bundleItemImported(const QmlDesigner::NodeMetaInfo &metaInfo);
|
|
||||||
#endif
|
|
||||||
void bundleItemAboutToUnimport(const QmlDesigner::TypeName &type);
|
|
||||||
void bundleItemUnimported(const QmlDesigner::NodeMetaInfo &metaInfo);
|
|
||||||
void importerRunningChanged();
|
|
||||||
void bundleExistsChanged();
|
void bundleExistsChanged();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool isValidIndex(int idx) const;
|
bool isValidIndex(int idx) const;
|
||||||
void createImporter();
|
|
||||||
|
|
||||||
ContentLibraryWidget *m_widget = nullptr;
|
ContentLibraryWidget *m_widget = nullptr;
|
||||||
QString m_searchText;
|
QString m_searchText;
|
||||||
QString m_bundlePath;
|
QString m_bundlePath;
|
||||||
QStringList m_importerSharedFiles;
|
QString m_bundleId;
|
||||||
|
QStringList m_bundleSharedFiles;
|
||||||
QList<ContentLibraryEffectsCategory *> m_bundleCategories;
|
QList<ContentLibraryEffectsCategory *> m_bundleCategories;
|
||||||
QJsonObject m_bundleObj;
|
QJsonObject m_bundleObj;
|
||||||
ContentLibraryBundleImporter *m_importer = nullptr;
|
|
||||||
|
|
||||||
bool m_isEmpty = true;
|
bool m_isEmpty = true;
|
||||||
bool m_bundleExists = false;
|
bool m_bundleExists = false;
|
||||||
bool m_probeBundleDir = false;
|
bool m_probeBundleDir = false;
|
||||||
bool m_importerRunning = false;
|
|
||||||
|
|
||||||
int m_quick3dMajorVersion = -1;
|
int m_quick3dMajorVersion = -1;
|
||||||
int m_quick3dMinorVersion = -1;
|
int m_quick3dMinorVersion = -1;
|
||||||
|
@@ -20,6 +20,7 @@
|
|||||||
#include <utils/qtcassert.h>
|
#include <utils/qtcassert.h>
|
||||||
|
|
||||||
#include <QCoreApplication>
|
#include <QCoreApplication>
|
||||||
|
#include <QDir>
|
||||||
#include <QJsonArray>
|
#include <QJsonArray>
|
||||||
#include <QJsonDocument>
|
#include <QJsonDocument>
|
||||||
#include <QQmlEngine>
|
#include <QQmlEngine>
|
||||||
@@ -195,10 +196,9 @@ void ContentLibraryMaterialsModel::downloadSharedFiles(const QDir &targetDir, co
|
|||||||
extractor->setAlwaysCreateDir(false);
|
extractor->setAlwaysCreateDir(false);
|
||||||
extractor->setClearTargetPathContents(false);
|
extractor->setClearTargetPathContents(false);
|
||||||
|
|
||||||
QObject::connect(extractor, &FileExtractor::finishedChanged, this, [this, downloader, extractor]() {
|
QObject::connect(extractor, &FileExtractor::finishedChanged, this, [downloader, extractor]() {
|
||||||
downloader->deleteLater();
|
downloader->deleteLater();
|
||||||
extractor->deleteLater();
|
extractor->deleteLater();
|
||||||
createImporter();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
extractor->extract();
|
extractor->extract();
|
||||||
@@ -207,46 +207,9 @@ void ContentLibraryMaterialsModel::downloadSharedFiles(const QDir &targetDir, co
|
|||||||
downloader->start();
|
downloader->start();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ContentLibraryMaterialsModel::createImporter()
|
QString ContentLibraryMaterialsModel::bundleId() const
|
||||||
{
|
{
|
||||||
m_importer = new ContentLibraryBundleImporter();
|
return m_bundleId;
|
||||||
#ifdef QDS_USE_PROJECTSTORAGE
|
|
||||||
connect(m_importer,
|
|
||||||
&ContentLibraryBundleImporter::importFinished,
|
|
||||||
this,
|
|
||||||
[&](const QmlDesigner::TypeName &typeName) {
|
|
||||||
m_importerRunning = false;
|
|
||||||
emit importerRunningChanged();
|
|
||||||
if (typeName.size()) {
|
|
||||||
emit bundleMaterialImported(typeName);
|
|
||||||
updateImportedState();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
#else
|
|
||||||
connect(m_importer,
|
|
||||||
&ContentLibraryBundleImporter::importFinished,
|
|
||||||
this,
|
|
||||||
[&](const QmlDesigner::NodeMetaInfo &metaInfo) {
|
|
||||||
m_importerRunning = false;
|
|
||||||
emit importerRunningChanged();
|
|
||||||
if (metaInfo.isValid()) {
|
|
||||||
emit bundleMaterialImported(metaInfo);
|
|
||||||
updateImportedState();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
#endif
|
|
||||||
|
|
||||||
connect(m_importer, &ContentLibraryBundleImporter::unimportFinished, this,
|
|
||||||
[&](const QmlDesigner::NodeMetaInfo &metaInfo) {
|
|
||||||
Q_UNUSED(metaInfo)
|
|
||||||
m_importerRunning = false;
|
|
||||||
emit importerRunningChanged();
|
|
||||||
emit bundleMaterialUnimported(metaInfo);
|
|
||||||
updateImportedState();
|
|
||||||
});
|
|
||||||
|
|
||||||
resetModel();
|
|
||||||
updateIsEmpty();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ContentLibraryMaterialsModel::loadMaterialBundle(const QDir &matBundleDir)
|
void ContentLibraryMaterialsModel::loadMaterialBundle(const QDir &matBundleDir)
|
||||||
@@ -273,11 +236,9 @@ void ContentLibraryMaterialsModel::loadMaterialBundle(const QDir &matBundleDir)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QString bundleType = QmlDesignerPlugin::instance()->documentManager()
|
auto compUtils = QmlDesignerPlugin::instance()->documentManager().generatedComponentUtils();
|
||||||
.generatedComponentUtils().materialsBundleType();
|
QString bundleType = compUtils.materialsBundleType();
|
||||||
|
m_bundleId = compUtils.materialsBundleId();
|
||||||
// Substitute correct id to avoid issues with old bundles
|
|
||||||
m_matBundleObj["id"] = bundleType.split('.').last();
|
|
||||||
|
|
||||||
const QJsonObject catsObj = m_matBundleObj.value("categories").toObject();
|
const QJsonObject catsObj = m_matBundleObj.value("categories").toObject();
|
||||||
const QStringList categories = catsObj.keys();
|
const QStringList categories = catsObj.keys();
|
||||||
@@ -307,22 +268,22 @@ void ContentLibraryMaterialsModel::loadMaterialBundle(const QDir &matBundleDir)
|
|||||||
m_bundleCategories.append(category);
|
m_bundleCategories.append(category);
|
||||||
}
|
}
|
||||||
|
|
||||||
m_importerSharedFiles.clear();
|
m_bundleSharedFiles.clear();
|
||||||
const QJsonArray sharedFilesArr = m_matBundleObj.value("sharedFiles").toArray();
|
const QJsonArray sharedFilesArr = m_matBundleObj.value("sharedFiles").toArray();
|
||||||
for (const QJsonValueConstRef &file : sharedFilesArr)
|
for (const QJsonValueConstRef &file : sharedFilesArr)
|
||||||
m_importerSharedFiles.append(file.toString());
|
m_bundleSharedFiles.append(file.toString());
|
||||||
|
|
||||||
QStringList missingSharedFiles;
|
QStringList missingSharedFiles;
|
||||||
for (const QString &s : std::as_const(m_importerSharedFiles)) {
|
for (const QString &s : std::as_const(m_bundleSharedFiles)) {
|
||||||
if (!QFileInfo::exists(matBundleDir.filePath(s)))
|
if (!QFileInfo::exists(matBundleDir.filePath(s)))
|
||||||
missingSharedFiles.push_back(s);
|
missingSharedFiles.push_back(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (missingSharedFiles.length() > 0)
|
if (missingSharedFiles.length() > 0)
|
||||||
downloadSharedFiles(matBundleDir, missingSharedFiles);
|
downloadSharedFiles(matBundleDir, missingSharedFiles);
|
||||||
else
|
|
||||||
createImporter();
|
|
||||||
|
|
||||||
|
resetModel();
|
||||||
|
updateIsEmpty();
|
||||||
m_matBundleExists = true;
|
m_matBundleExists = true;
|
||||||
emit matBundleExistsChanged();
|
emit matBundleExistsChanged();
|
||||||
}
|
}
|
||||||
@@ -337,11 +298,6 @@ bool ContentLibraryMaterialsModel::matBundleExists() const
|
|||||||
return m_matBundleExists;
|
return m_matBundleExists;
|
||||||
}
|
}
|
||||||
|
|
||||||
ContentLibraryBundleImporter *ContentLibraryMaterialsModel::bundleImporter() const
|
|
||||||
{
|
|
||||||
return m_importer;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ContentLibraryMaterialsModel::setSearchText(const QString &searchText)
|
void ContentLibraryMaterialsModel::setSearchText(const QString &searchText)
|
||||||
{
|
{
|
||||||
QString lowerSearchText = searchText.toLower();
|
QString lowerSearchText = searchText.toLower();
|
||||||
@@ -361,20 +317,8 @@ void ContentLibraryMaterialsModel::setSearchText(const QString &searchText)
|
|||||||
updateIsEmpty();
|
updateIsEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ContentLibraryMaterialsModel::updateImportedState()
|
void ContentLibraryMaterialsModel::updateImportedState(const QStringList &importedItems)
|
||||||
{
|
{
|
||||||
if (!m_importer)
|
|
||||||
return;
|
|
||||||
|
|
||||||
QString bundleId = m_matBundleObj.value("id").toString();
|
|
||||||
Utils::FilePath bundlePath = m_importer->resolveBundleImportPath(bundleId);
|
|
||||||
|
|
||||||
QStringList importedItems;
|
|
||||||
if (bundlePath.exists()) {
|
|
||||||
importedItems = transform(bundlePath.dirEntries({{"*.qml"}, QDir::Files}),
|
|
||||||
[](const Utils::FilePath &f) { return f.baseName(); });
|
|
||||||
}
|
|
||||||
|
|
||||||
bool changed = false;
|
bool changed = false;
|
||||||
for (ContentLibraryMaterialsCategory *cat : std::as_const(m_bundleCategories))
|
for (ContentLibraryMaterialsCategory *cat : std::as_const(m_bundleCategories))
|
||||||
changed |= cat->updateImportedState(importedItems);
|
changed |= cat->updateImportedState(importedItems);
|
||||||
@@ -413,29 +357,23 @@ void ContentLibraryMaterialsModel::applyToSelected(ContentLibraryMaterial *mat,
|
|||||||
|
|
||||||
void ContentLibraryMaterialsModel::addToProject(ContentLibraryMaterial *mat)
|
void ContentLibraryMaterialsModel::addToProject(ContentLibraryMaterial *mat)
|
||||||
{
|
{
|
||||||
QString err = m_importer->importComponent(mat->dirPath(), mat->type(),
|
QString err = m_widget->importer()->importComponent(mat->dirPath(), mat->type(), mat->qml(),
|
||||||
mat->qml(), mat->files() + m_importerSharedFiles);
|
mat->files() + m_bundleSharedFiles);
|
||||||
|
|
||||||
if (err.isEmpty()) {
|
if (err.isEmpty())
|
||||||
m_importerRunning = true;
|
m_widget->setImporterRunning(true);
|
||||||
emit importerRunningChanged();
|
else
|
||||||
} else {
|
|
||||||
qWarning() << __FUNCTION__ << err;
|
qWarning() << __FUNCTION__ << err;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ContentLibraryMaterialsModel::removeFromProject(ContentLibraryMaterial *mat)
|
void ContentLibraryMaterialsModel::removeFromProject(ContentLibraryMaterial *mat)
|
||||||
{
|
{
|
||||||
emit bundleMaterialAboutToUnimport(mat->type());
|
QString err = m_widget->importer()->unimportComponent(mat->type(), mat->qml());
|
||||||
|
|
||||||
QString err = m_importer->unimportComponent(mat->type(), mat->qml());
|
if (err.isEmpty())
|
||||||
|
m_widget->setImporterRunning(true);
|
||||||
if (err.isEmpty()) {
|
else
|
||||||
m_importerRunning = true;
|
|
||||||
emit importerRunningChanged();
|
|
||||||
} else {
|
|
||||||
qWarning() << __FUNCTION__ << err;
|
qWarning() << __FUNCTION__ << err;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ContentLibraryMaterialsModel::hasModelSelection() const
|
bool ContentLibraryMaterialsModel::hasModelSelection() const
|
||||||
|
@@ -3,15 +3,13 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "nodemetainfo.h"
|
|
||||||
|
|
||||||
#include <QAbstractListModel>
|
#include <QAbstractListModel>
|
||||||
#include <QDir>
|
|
||||||
#include <QJsonObject>
|
#include <QJsonObject>
|
||||||
|
|
||||||
|
QT_FORWARD_DECLARE_CLASS(QDir)
|
||||||
|
|
||||||
namespace QmlDesigner {
|
namespace QmlDesigner {
|
||||||
|
|
||||||
class ContentLibraryBundleImporter;
|
|
||||||
class ContentLibraryMaterial;
|
class ContentLibraryMaterial;
|
||||||
class ContentLibraryMaterialsCategory;
|
class ContentLibraryMaterialsCategory;
|
||||||
class ContentLibraryWidget;
|
class ContentLibraryWidget;
|
||||||
@@ -24,7 +22,6 @@ class ContentLibraryMaterialsModel : public QAbstractListModel
|
|||||||
Q_PROPERTY(bool isEmpty MEMBER m_isEmpty NOTIFY isEmptyChanged)
|
Q_PROPERTY(bool isEmpty MEMBER m_isEmpty NOTIFY isEmptyChanged)
|
||||||
Q_PROPERTY(bool hasRequiredQuick3DImport READ hasRequiredQuick3DImport NOTIFY hasRequiredQuick3DImportChanged)
|
Q_PROPERTY(bool hasRequiredQuick3DImport READ hasRequiredQuick3DImport NOTIFY hasRequiredQuick3DImportChanged)
|
||||||
Q_PROPERTY(bool hasModelSelection READ hasModelSelection NOTIFY hasModelSelectionChanged)
|
Q_PROPERTY(bool hasModelSelection READ hasModelSelection NOTIFY hasModelSelectionChanged)
|
||||||
Q_PROPERTY(bool importerRunning MEMBER m_importerRunning NOTIFY importerRunningChanged)
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ContentLibraryMaterialsModel(ContentLibraryWidget *parent = nullptr);
|
ContentLibraryMaterialsModel(ContentLibraryWidget *parent = nullptr);
|
||||||
@@ -35,7 +32,7 @@ public:
|
|||||||
QHash<int, QByteArray> roleNames() const override;
|
QHash<int, QByteArray> roleNames() const override;
|
||||||
|
|
||||||
void setSearchText(const QString &searchText);
|
void setSearchText(const QString &searchText);
|
||||||
void updateImportedState();
|
void updateImportedState(const QStringList &importedItems);
|
||||||
|
|
||||||
void setQuick3DImportVersion(int major, int minor);
|
void setQuick3DImportVersion(int major, int minor);
|
||||||
|
|
||||||
@@ -50,26 +47,18 @@ public:
|
|||||||
void updateIsEmpty();
|
void updateIsEmpty();
|
||||||
void loadBundle();
|
void loadBundle();
|
||||||
|
|
||||||
ContentLibraryBundleImporter *bundleImporter() const;
|
|
||||||
|
|
||||||
Q_INVOKABLE void applyToSelected(QmlDesigner::ContentLibraryMaterial *mat, bool add = false);
|
Q_INVOKABLE void applyToSelected(QmlDesigner::ContentLibraryMaterial *mat, bool add = false);
|
||||||
Q_INVOKABLE void addToProject(QmlDesigner::ContentLibraryMaterial *mat);
|
Q_INVOKABLE void addToProject(QmlDesigner::ContentLibraryMaterial *mat);
|
||||||
Q_INVOKABLE void removeFromProject(QmlDesigner::ContentLibraryMaterial *mat);
|
Q_INVOKABLE void removeFromProject(QmlDesigner::ContentLibraryMaterial *mat);
|
||||||
|
|
||||||
|
QString bundleId() const;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void isEmptyChanged();
|
void isEmptyChanged();
|
||||||
void hasRequiredQuick3DImportChanged();
|
void hasRequiredQuick3DImportChanged();
|
||||||
void hasModelSelectionChanged();
|
void hasModelSelectionChanged();
|
||||||
void materialVisibleChanged();
|
void materialVisibleChanged();
|
||||||
void applyToSelectedTriggered(QmlDesigner::ContentLibraryMaterial *mat, bool add = false);
|
void applyToSelectedTriggered(QmlDesigner::ContentLibraryMaterial *mat, bool add = false);
|
||||||
#ifdef QDS_USE_PROJECTSTORAGE
|
|
||||||
void bundleMaterialImported(const QmlDesigner::TypeName &typeName);
|
|
||||||
#else
|
|
||||||
void bundleMaterialImported(const QmlDesigner::NodeMetaInfo &metaInfo);
|
|
||||||
#endif
|
|
||||||
void bundleMaterialAboutToUnimport(const QmlDesigner::TypeName &type);
|
|
||||||
void bundleMaterialUnimported(const QmlDesigner::NodeMetaInfo &metaInfo);
|
|
||||||
void importerRunningChanged();
|
|
||||||
void matBundleExistsChanged();
|
void matBundleExistsChanged();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@@ -78,26 +67,23 @@ private:
|
|||||||
bool fetchBundleMetadata(const QDir &bundleDir);
|
bool fetchBundleMetadata(const QDir &bundleDir);
|
||||||
bool isValidIndex(int idx) const;
|
bool isValidIndex(int idx) const;
|
||||||
void downloadSharedFiles(const QDir &targetDir, const QStringList &files);
|
void downloadSharedFiles(const QDir &targetDir, const QStringList &files);
|
||||||
void createImporter();
|
|
||||||
|
|
||||||
ContentLibraryWidget *m_widget = nullptr;
|
ContentLibraryWidget *m_widget = nullptr;
|
||||||
QString m_searchText;
|
QString m_searchText;
|
||||||
|
QString m_bundleId;
|
||||||
|
QStringList m_bundleSharedFiles;
|
||||||
QList<ContentLibraryMaterialsCategory *> m_bundleCategories;
|
QList<ContentLibraryMaterialsCategory *> m_bundleCategories;
|
||||||
QJsonObject m_matBundleObj;
|
QJsonObject m_matBundleObj;
|
||||||
ContentLibraryBundleImporter *m_importer = nullptr;
|
|
||||||
|
|
||||||
bool m_isEmpty = true;
|
bool m_isEmpty = true;
|
||||||
bool m_matBundleExists = false;
|
bool m_matBundleExists = false;
|
||||||
bool m_hasModelSelection = false;
|
bool m_hasModelSelection = false;
|
||||||
bool m_importerRunning = false;
|
|
||||||
|
|
||||||
int m_quick3dMajorVersion = -1;
|
int m_quick3dMajorVersion = -1;
|
||||||
int m_quick3dMinorVersion = -1;
|
int m_quick3dMinorVersion = -1;
|
||||||
|
|
||||||
QString m_downloadPath;
|
QString m_downloadPath;
|
||||||
QString m_baseUrl;
|
QString m_baseUrl;
|
||||||
|
|
||||||
QStringList m_importerSharedFiles;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace QmlDesigner
|
} // namespace QmlDesigner
|
||||||
|
@@ -14,15 +14,11 @@
|
|||||||
#include <qmldesignerplugin.h>
|
#include <qmldesignerplugin.h>
|
||||||
|
|
||||||
#include <utils/algorithm.h>
|
#include <utils/algorithm.h>
|
||||||
#include <utils/hostosinfo.h>
|
|
||||||
#include <utils/qtcassert.h>
|
#include <utils/qtcassert.h>
|
||||||
|
|
||||||
#include <QCoreApplication>
|
|
||||||
#include <QFileInfo>
|
#include <QFileInfo>
|
||||||
#include <QJsonArray>
|
#include <QJsonArray>
|
||||||
#include <QJsonDocument>
|
#include <QJsonDocument>
|
||||||
#include <QQmlEngine>
|
|
||||||
#include <QStandardPaths>
|
|
||||||
#include <QUrl>
|
#include <QUrl>
|
||||||
|
|
||||||
namespace QmlDesigner {
|
namespace QmlDesigner {
|
||||||
@@ -223,48 +219,6 @@ QHash<int, QByteArray> ContentLibraryUserModel::roleNames() const
|
|||||||
return roles;
|
return roles;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ContentLibraryUserModel::createImporter()
|
|
||||||
{
|
|
||||||
m_importer = new ContentLibraryBundleImporter();
|
|
||||||
#ifdef QDS_USE_PROJECTSTORAGE
|
|
||||||
connect(m_importer,
|
|
||||||
&ContentLibraryBundleImporter::importFinished,
|
|
||||||
this,
|
|
||||||
[&](const QmlDesigner::TypeName &typeName) {
|
|
||||||
m_importerRunning = false;
|
|
||||||
emit importerRunningChanged();
|
|
||||||
if (typeName.size()) {
|
|
||||||
emit bundleMaterialImported(typeName);
|
|
||||||
updateImportedState();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
#else
|
|
||||||
connect(m_importer,
|
|
||||||
&ContentLibraryBundleImporter::importFinished,
|
|
||||||
this,
|
|
||||||
[&](const QmlDesigner::NodeMetaInfo &metaInfo) {
|
|
||||||
m_importerRunning = false;
|
|
||||||
emit importerRunningChanged();
|
|
||||||
if (metaInfo.isValid()) {
|
|
||||||
emit bundleMaterialImported(metaInfo);
|
|
||||||
updateImportedState();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
#endif
|
|
||||||
|
|
||||||
connect(m_importer, &ContentLibraryBundleImporter::unimportFinished, this,
|
|
||||||
[&](const QmlDesigner::NodeMetaInfo &metaInfo) {
|
|
||||||
Q_UNUSED(metaInfo)
|
|
||||||
m_importerRunning = false;
|
|
||||||
emit importerRunningChanged();
|
|
||||||
emit bundleMaterialUnimported(metaInfo);
|
|
||||||
updateImportedState();
|
|
||||||
});
|
|
||||||
|
|
||||||
resetModel();
|
|
||||||
updateIsEmpty();
|
|
||||||
}
|
|
||||||
|
|
||||||
QJsonObject &ContentLibraryUserModel::bundleJsonObjectRef()
|
QJsonObject &ContentLibraryUserModel::bundleJsonObjectRef()
|
||||||
{
|
{
|
||||||
return m_bundleObj;
|
return m_bundleObj;
|
||||||
@@ -304,10 +258,8 @@ void ContentLibraryUserModel::loadMaterialBundle()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
m_bundleIdMaterial = "UserMaterials";
|
auto compUtils = QmlDesignerPlugin::instance()->documentManager().generatedComponentUtils();
|
||||||
|
m_bundleObj["id"] = compUtils.userMaterialsBundleId();
|
||||||
// Substitute correct id to avoid issues with old bundles
|
|
||||||
m_bundleObj["id"] = m_bundleIdMaterial;
|
|
||||||
|
|
||||||
// parse materials
|
// parse materials
|
||||||
const QJsonObject matsObj = m_bundleObj.value("materials").toObject();
|
const QJsonObject matsObj = m_bundleObj.value("materials").toObject();
|
||||||
@@ -331,12 +283,10 @@ void ContentLibraryUserModel::loadMaterialBundle()
|
|||||||
m_userMaterials.append(userMat);
|
m_userMaterials.append(userMat);
|
||||||
}
|
}
|
||||||
|
|
||||||
m_importerSharedFiles.clear();
|
m_bundleSharedFiles.clear();
|
||||||
const QJsonArray sharedFilesArr = m_bundleObj.value("sharedFiles").toArray();
|
const QJsonArray sharedFilesArr = m_bundleObj.value("sharedFiles").toArray();
|
||||||
for (const QJsonValueConstRef &file : sharedFilesArr)
|
for (const QJsonValueConstRef &file : sharedFilesArr)
|
||||||
m_importerSharedFiles.append(file.toString());
|
m_bundleSharedFiles.append(file.toString());
|
||||||
|
|
||||||
createImporter();
|
|
||||||
|
|
||||||
m_matBundleExists = true;
|
m_matBundleExists = true;
|
||||||
emit matBundleExistsChanged();
|
emit matBundleExistsChanged();
|
||||||
@@ -378,11 +328,6 @@ bool ContentLibraryUserModel::matBundleExists() const
|
|||||||
return m_matBundleExists;
|
return m_matBundleExists;
|
||||||
}
|
}
|
||||||
|
|
||||||
ContentLibraryBundleImporter *ContentLibraryUserModel::bundleImporter() const
|
|
||||||
{
|
|
||||||
return m_importer;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ContentLibraryUserModel::setSearchText(const QString &searchText)
|
void ContentLibraryUserModel::setSearchText(const QString &searchText)
|
||||||
{
|
{
|
||||||
QString lowerSearchText = searchText.toLower();
|
QString lowerSearchText = searchText.toLower();
|
||||||
@@ -398,20 +343,8 @@ void ContentLibraryUserModel::setSearchText(const QString &searchText)
|
|||||||
updateIsEmpty();
|
updateIsEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ContentLibraryUserModel::updateImportedState()
|
void ContentLibraryUserModel::updateImportedState(const QStringList &importedItems)
|
||||||
{
|
{
|
||||||
if (!m_importer)
|
|
||||||
return;
|
|
||||||
|
|
||||||
QString bundleId = m_bundleObj.value("id").toString();
|
|
||||||
Utils::FilePath bundlePath = m_importer->resolveBundleImportPath(bundleId);
|
|
||||||
|
|
||||||
QStringList importedItems;
|
|
||||||
if (bundlePath.exists()) {
|
|
||||||
importedItems = transform(bundlePath.dirEntries({{"*.qml"}, QDir::Files}),
|
|
||||||
[](const Utils::FilePath &f) { return f.baseName(); });
|
|
||||||
}
|
|
||||||
|
|
||||||
bool changed = false;
|
bool changed = false;
|
||||||
for (ContentLibraryMaterial *mat : std::as_const(m_userMaterials))
|
for (ContentLibraryMaterial *mat : std::as_const(m_userMaterials))
|
||||||
changed |= mat->setImported(importedItems.contains(mat->qml().chopped(4)));
|
changed |= mat->setImported(importedItems.contains(mat->qml().chopped(4)));
|
||||||
@@ -452,29 +385,23 @@ void ContentLibraryUserModel::applyToSelected(ContentLibraryMaterial *mat, bool
|
|||||||
|
|
||||||
void ContentLibraryUserModel::addToProject(ContentLibraryMaterial *mat)
|
void ContentLibraryUserModel::addToProject(ContentLibraryMaterial *mat)
|
||||||
{
|
{
|
||||||
QString err = m_importer->importComponent(mat->dirPath(), mat->type(), mat->qml(),
|
QString err = m_widget->importer()->importComponent(mat->dirPath(), mat->type(), mat->qml(),
|
||||||
mat->files() + m_importerSharedFiles);
|
mat->files() + m_bundleSharedFiles);
|
||||||
|
|
||||||
if (err.isEmpty()) {
|
if (err.isEmpty())
|
||||||
m_importerRunning = true;
|
m_widget->setImporterRunning(true);
|
||||||
emit importerRunningChanged();
|
else
|
||||||
} else {
|
|
||||||
qWarning() << __FUNCTION__ << err;
|
qWarning() << __FUNCTION__ << err;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ContentLibraryUserModel::removeFromProject(ContentLibraryMaterial *mat)
|
void ContentLibraryUserModel::removeFromProject(ContentLibraryMaterial *mat)
|
||||||
{
|
{
|
||||||
emit bundleMaterialAboutToUnimport(mat->type());
|
QString err = m_widget->importer()->unimportComponent(mat->type(), mat->qml());
|
||||||
|
|
||||||
QString err = m_importer->unimportComponent(mat->type(), mat->qml());
|
if (err.isEmpty())
|
||||||
|
m_widget->setImporterRunning(true);
|
||||||
if (err.isEmpty()) {
|
else
|
||||||
m_importerRunning = true;
|
|
||||||
emit importerRunningChanged();
|
|
||||||
} else {
|
|
||||||
qWarning() << __FUNCTION__ << err;
|
qWarning() << __FUNCTION__ << err;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ContentLibraryUserModel::hasModelSelection() const
|
bool ContentLibraryUserModel::hasModelSelection() const
|
||||||
|
@@ -12,7 +12,6 @@ QT_FORWARD_DECLARE_CLASS(QUrl)
|
|||||||
|
|
||||||
namespace QmlDesigner {
|
namespace QmlDesigner {
|
||||||
|
|
||||||
class ContentLibraryBundleImporter;
|
|
||||||
class ContentLibraryEffect;
|
class ContentLibraryEffect;
|
||||||
class ContentLibraryMaterial;
|
class ContentLibraryMaterial;
|
||||||
class ContentLibraryTexture;
|
class ContentLibraryTexture;
|
||||||
@@ -27,7 +26,6 @@ class ContentLibraryUserModel : public QAbstractListModel
|
|||||||
Q_PROPERTY(bool isEmpty MEMBER m_isEmpty NOTIFY isEmptyChanged)
|
Q_PROPERTY(bool isEmpty MEMBER m_isEmpty NOTIFY isEmptyChanged)
|
||||||
Q_PROPERTY(bool hasRequiredQuick3DImport READ hasRequiredQuick3DImport NOTIFY hasRequiredQuick3DImportChanged)
|
Q_PROPERTY(bool hasRequiredQuick3DImport READ hasRequiredQuick3DImport NOTIFY hasRequiredQuick3DImportChanged)
|
||||||
Q_PROPERTY(bool hasModelSelection READ hasModelSelection NOTIFY hasModelSelectionChanged)
|
Q_PROPERTY(bool hasModelSelection READ hasModelSelection NOTIFY hasModelSelectionChanged)
|
||||||
Q_PROPERTY(bool importerRunning MEMBER m_importerRunning NOTIFY importerRunningChanged)
|
|
||||||
Q_PROPERTY(QList<ContentLibraryMaterial *> userMaterials MEMBER m_userMaterials NOTIFY userMaterialsChanged)
|
Q_PROPERTY(QList<ContentLibraryMaterial *> userMaterials MEMBER m_userMaterials NOTIFY userMaterialsChanged)
|
||||||
Q_PROPERTY(QList<ContentLibraryTexture *> userTextures MEMBER m_userTextures NOTIFY userTexturesChanged)
|
Q_PROPERTY(QList<ContentLibraryTexture *> userTextures MEMBER m_userTextures NOTIFY userTexturesChanged)
|
||||||
Q_PROPERTY(QList<ContentLibraryEffect *> user3DItems MEMBER m_user3DItems NOTIFY user3DItemsChanged)
|
Q_PROPERTY(QList<ContentLibraryEffect *> user3DItems MEMBER m_user3DItems NOTIFY user3DItemsChanged)
|
||||||
@@ -41,7 +39,7 @@ public:
|
|||||||
QHash<int, QByteArray> roleNames() const override;
|
QHash<int, QByteArray> roleNames() const override;
|
||||||
|
|
||||||
void setSearchText(const QString &searchText);
|
void setSearchText(const QString &searchText);
|
||||||
void updateImportedState();
|
void updateImportedState(const QStringList &importedItems);
|
||||||
|
|
||||||
QPair<QString, QString> getUniqueLibMaterialNameAndQml(const QString &matName) const;
|
QPair<QString, QString> getUniqueLibMaterialNameAndQml(const QString &matName) const;
|
||||||
TypeName qmlToModule(const QString &qmlName) const;
|
TypeName qmlToModule(const QString &qmlName) const;
|
||||||
@@ -67,8 +65,6 @@ public:
|
|||||||
void loadMaterialBundle();
|
void loadMaterialBundle();
|
||||||
void loadTextureBundle();
|
void loadTextureBundle();
|
||||||
|
|
||||||
ContentLibraryBundleImporter *bundleImporter() const;
|
|
||||||
|
|
||||||
Q_INVOKABLE void applyToSelected(QmlDesigner::ContentLibraryMaterial *mat, bool add = false);
|
Q_INVOKABLE void applyToSelected(QmlDesigner::ContentLibraryMaterial *mat, bool add = false);
|
||||||
Q_INVOKABLE void addToProject(QmlDesigner::ContentLibraryMaterial *mat);
|
Q_INVOKABLE void addToProject(QmlDesigner::ContentLibraryMaterial *mat);
|
||||||
Q_INVOKABLE void removeFromProject(QmlDesigner::ContentLibraryMaterial *mat);
|
Q_INVOKABLE void removeFromProject(QmlDesigner::ContentLibraryMaterial *mat);
|
||||||
@@ -86,23 +82,16 @@ signals:
|
|||||||
|
|
||||||
void applyToSelectedTriggered(QmlDesigner::ContentLibraryMaterial *mat, bool add = false);
|
void applyToSelectedTriggered(QmlDesigner::ContentLibraryMaterial *mat, bool add = false);
|
||||||
|
|
||||||
#ifdef QDS_USE_PROJECTSTORAGE
|
|
||||||
void bundleMaterialImported(const QmlDesigner::TypeName &typeName);
|
|
||||||
#else
|
|
||||||
void bundleMaterialImported(const QmlDesigner::NodeMetaInfo &metaInfo);
|
|
||||||
#endif
|
|
||||||
void bundleMaterialAboutToUnimport(const QmlDesigner::TypeName &type);
|
|
||||||
void bundleMaterialUnimported(const QmlDesigner::NodeMetaInfo &metaInfo);
|
|
||||||
void importerRunningChanged();
|
|
||||||
void matBundleExistsChanged();
|
void matBundleExistsChanged();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool isValidIndex(int idx) const;
|
bool isValidIndex(int idx) const;
|
||||||
void createImporter();
|
|
||||||
|
|
||||||
ContentLibraryWidget *m_widget = nullptr;
|
ContentLibraryWidget *m_widget = nullptr;
|
||||||
QString m_searchText;
|
QString m_searchText;
|
||||||
QString m_bundleIdMaterial;
|
QString m_bundleIdMaterial;
|
||||||
|
QStringList m_bundleSharedFiles;
|
||||||
|
|
||||||
QList<ContentLibraryMaterial *> m_userMaterials;
|
QList<ContentLibraryMaterial *> m_userMaterials;
|
||||||
QList<ContentLibraryTexture *> m_userTextures;
|
QList<ContentLibraryTexture *> m_userTextures;
|
||||||
@@ -111,19 +100,14 @@ private:
|
|||||||
QStringList m_userCategories;
|
QStringList m_userCategories;
|
||||||
|
|
||||||
QJsonObject m_bundleObj;
|
QJsonObject m_bundleObj;
|
||||||
ContentLibraryBundleImporter *m_importer = nullptr;
|
|
||||||
|
|
||||||
bool m_isEmpty = true;
|
bool m_isEmpty = true;
|
||||||
bool m_matBundleExists = false;
|
bool m_matBundleExists = false;
|
||||||
bool m_hasModelSelection = false;
|
bool m_hasModelSelection = false;
|
||||||
bool m_importerRunning = false;
|
|
||||||
|
|
||||||
int m_quick3dMajorVersion = -1;
|
int m_quick3dMajorVersion = -1;
|
||||||
int m_quick3dMinorVersion = -1;
|
int m_quick3dMinorVersion = -1;
|
||||||
|
|
||||||
QString m_importerBundlePath;
|
|
||||||
QString m_importerBundleId;
|
|
||||||
QStringList m_importerSharedFiles;
|
|
||||||
|
|
||||||
enum Roles { NameRole = Qt::UserRole + 1, VisibleRole, ItemsRole };
|
enum Roles { NameRole = Qt::UserRole + 1, VisibleRole, ItemsRole };
|
||||||
};
|
};
|
||||||
|
@@ -3,8 +3,6 @@
|
|||||||
|
|
||||||
#include "contentlibraryview.h"
|
#include "contentlibraryview.h"
|
||||||
|
|
||||||
#include "asset.h"
|
|
||||||
#include "bindingproperty.h"
|
|
||||||
#include "contentlibrarybundleimporter.h"
|
#include "contentlibrarybundleimporter.h"
|
||||||
#include "contentlibraryeffect.h"
|
#include "contentlibraryeffect.h"
|
||||||
#include "contentlibraryeffectsmodel.h"
|
#include "contentlibraryeffectsmodel.h"
|
||||||
@@ -14,19 +12,20 @@
|
|||||||
#include "contentlibrarytexturesmodel.h"
|
#include "contentlibrarytexturesmodel.h"
|
||||||
#include "contentlibraryusermodel.h"
|
#include "contentlibraryusermodel.h"
|
||||||
#include "contentlibrarywidget.h"
|
#include "contentlibrarywidget.h"
|
||||||
#include "documentmanager.h"
|
|
||||||
#include "externaldependenciesinterface.h"
|
|
||||||
#include "nodelistproperty.h"
|
|
||||||
#include "qmldesignerconstants.h"
|
|
||||||
#include "qmlobjectnode.h"
|
|
||||||
#include "variantproperty.h"
|
|
||||||
#include "utils3d.h"
|
|
||||||
|
|
||||||
|
#include <asset.h>
|
||||||
|
#include <bindingproperty.h>
|
||||||
#include <designerpaths.h>
|
#include <designerpaths.h>
|
||||||
#include <qmldesignerplugin.h>
|
#include <documentmanager.h>
|
||||||
|
|
||||||
#include <coreplugin/messagebox.h>
|
|
||||||
#include <enumeration.h>
|
#include <enumeration.h>
|
||||||
|
#include <externaldependenciesinterface.h>
|
||||||
|
#include <nodelistproperty.h>
|
||||||
|
#include <qmldesignerconstants.h>
|
||||||
|
#include <qmldesignerplugin.h>
|
||||||
|
#include <qmlobjectnode.h>
|
||||||
|
#include <variantproperty.h>
|
||||||
|
#include <utils3d.h>
|
||||||
|
|
||||||
#include <utils/algorithm.h>
|
#include <utils/algorithm.h>
|
||||||
|
|
||||||
#ifndef QMLDESIGNER_TEST
|
#ifndef QMLDESIGNER_TEST
|
||||||
@@ -90,9 +89,7 @@ WidgetInfo ContentLibraryView::widgetInfo()
|
|||||||
m_widget->environmentsModel()->setHasSceneEnv(sceneEnvExists);
|
m_widget->environmentsModel()->setHasSceneEnv(sceneEnvExists);
|
||||||
});
|
});
|
||||||
|
|
||||||
ContentLibraryMaterialsModel *materialsModel = m_widget->materialsModel().data();
|
connect(m_widget->materialsModel(),
|
||||||
|
|
||||||
connect(materialsModel,
|
|
||||||
&ContentLibraryMaterialsModel::applyToSelectedTriggered,
|
&ContentLibraryMaterialsModel::applyToSelectedTriggered,
|
||||||
this,
|
this,
|
||||||
[&](ContentLibraryMaterial *bundleMat, bool add) {
|
[&](ContentLibraryMaterial *bundleMat, bool add) {
|
||||||
@@ -109,118 +106,7 @@ WidgetInfo ContentLibraryView::widgetInfo()
|
|||||||
m_widget->materialsModel()->addToProject(bundleMat);
|
m_widget->materialsModel()->addToProject(bundleMat);
|
||||||
});
|
});
|
||||||
|
|
||||||
#ifdef QDS_USE_PROJECTSTORAGE
|
connect(m_widget->userModel(),
|
||||||
connect(materialsModel,
|
|
||||||
&ContentLibraryMaterialsModel::bundleMaterialImported,
|
|
||||||
this,
|
|
||||||
[&](const QmlDesigner::TypeName &typeName) {
|
|
||||||
applyBundleMaterialToDropTarget({}, typeName);
|
|
||||||
});
|
|
||||||
#else
|
|
||||||
connect(materialsModel,
|
|
||||||
&ContentLibraryMaterialsModel::bundleMaterialImported,
|
|
||||||
this,
|
|
||||||
[&](const QmlDesigner::NodeMetaInfo &metaInfo) {
|
|
||||||
applyBundleMaterialToDropTarget({}, metaInfo);
|
|
||||||
});
|
|
||||||
#endif
|
|
||||||
|
|
||||||
connect(materialsModel, &ContentLibraryMaterialsModel::bundleMaterialAboutToUnimport, this,
|
|
||||||
[&] (const QmlDesigner::TypeName &type) {
|
|
||||||
// delete instances of the bundle material that is about to be unimported
|
|
||||||
executeInTransaction("ContentLibraryView::widgetInfo", [&] {
|
|
||||||
ModelNode matLib = Utils3D::materialLibraryNode(this);
|
|
||||||
if (!matLib.isValid())
|
|
||||||
return;
|
|
||||||
|
|
||||||
Utils::reverseForeach(matLib.directSubModelNodes(), [&](const ModelNode &mat) {
|
|
||||||
if (mat.isValid() && mat.type() == type)
|
|
||||||
QmlObjectNode(mat).destroy();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
ContentLibraryEffectsModel *effectsModel = m_widget->effectsModel().data();
|
|
||||||
|
|
||||||
#ifdef QDS_USE_PROJECTSTORAGE
|
|
||||||
connect(effectsModel,
|
|
||||||
&ContentLibraryEffectsModel::bundleItemImported,
|
|
||||||
this,
|
|
||||||
[&](const QmlDesigner::TypeName &typeName) {
|
|
||||||
QTC_ASSERT(typeName.size(), return);
|
|
||||||
|
|
||||||
if (!m_bundleEffectTarget)
|
|
||||||
m_bundleEffectTarget = Utils3D::active3DSceneNode(this);
|
|
||||||
|
|
||||||
QTC_ASSERT(m_bundleEffectTarget, return);
|
|
||||||
|
|
||||||
executeInTransaction("ContentLibraryView::widgetInfo", [&] {
|
|
||||||
QVector3D pos = m_bundleEffectPos.value<QVector3D>();
|
|
||||||
ModelNode newEffNode = createModelNode(
|
|
||||||
typeName, -1, -1, {{"x", pos.x()}, {"y", pos.y()}, {"z", pos.z()}});
|
|
||||||
m_bundleEffectTarget.defaultNodeListProperty().reparentHere(newEffNode);
|
|
||||||
clearSelectedModelNodes();
|
|
||||||
selectModelNode(newEffNode);
|
|
||||||
});
|
|
||||||
|
|
||||||
m_bundleEffectTarget = {};
|
|
||||||
m_bundleEffectPos = {};
|
|
||||||
});
|
|
||||||
#else
|
|
||||||
connect(effectsModel,
|
|
||||||
&ContentLibraryEffectsModel::bundleItemImported,
|
|
||||||
this,
|
|
||||||
[&](const QmlDesigner::NodeMetaInfo &metaInfo) {
|
|
||||||
QTC_ASSERT(metaInfo.isValid(), return);
|
|
||||||
|
|
||||||
if (!m_bundleEffectTarget)
|
|
||||||
m_bundleEffectTarget = Utils3D::active3DSceneNode(this);
|
|
||||||
|
|
||||||
QTC_ASSERT(m_bundleEffectTarget, return);
|
|
||||||
|
|
||||||
executeInTransaction("ContentLibraryView::widgetInfo", [&] {
|
|
||||||
QVector3D pos = m_bundleEffectPos.value<QVector3D>();
|
|
||||||
ModelNode newEffNode = createModelNode(metaInfo.typeName(),
|
|
||||||
metaInfo.majorVersion(),
|
|
||||||
metaInfo.minorVersion(),
|
|
||||||
{{"x", pos.x()},
|
|
||||||
{"y", pos.y()},
|
|
||||||
{"z", pos.z()}});
|
|
||||||
m_bundleEffectTarget.defaultNodeListProperty().reparentHere(newEffNode);
|
|
||||||
clearSelectedModelNodes();
|
|
||||||
selectModelNode(newEffNode);
|
|
||||||
});
|
|
||||||
|
|
||||||
m_bundleEffectTarget = {};
|
|
||||||
m_bundleEffectPos = {};
|
|
||||||
});
|
|
||||||
#endif
|
|
||||||
connect(effectsModel, &ContentLibraryEffectsModel::bundleItemAboutToUnimport, this,
|
|
||||||
[&] (const QmlDesigner::TypeName &type) {
|
|
||||||
// delete instances of the bundle effect that is about to be unimported
|
|
||||||
executeInTransaction("ContentLibraryView::widgetInfo", [&] {
|
|
||||||
NodeMetaInfo metaInfo = model()->metaInfo(type);
|
|
||||||
QList<ModelNode> effects = allModelNodesOfType(metaInfo);
|
|
||||||
for (ModelNode &eff : effects)
|
|
||||||
eff.destroy();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
connectUserBundle();
|
|
||||||
}
|
|
||||||
|
|
||||||
return createWidgetInfo(m_widget.data(),
|
|
||||||
"ContentLibrary",
|
|
||||||
WidgetInfo::LeftPane,
|
|
||||||
0,
|
|
||||||
tr("Content Library"));
|
|
||||||
}
|
|
||||||
|
|
||||||
void ContentLibraryView::connectUserBundle()
|
|
||||||
{
|
|
||||||
ContentLibraryUserModel *userModel = m_widget->userModel().data();
|
|
||||||
|
|
||||||
connect(userModel,
|
|
||||||
&ContentLibraryUserModel::applyToSelectedTriggered,
|
&ContentLibraryUserModel::applyToSelectedTriggered,
|
||||||
this,
|
this,
|
||||||
[&](ContentLibraryMaterial *bundleMat, bool add) {
|
[&](ContentLibraryMaterial *bundleMat, bool add) {
|
||||||
@@ -237,26 +123,83 @@ void ContentLibraryView::connectUserBundle()
|
|||||||
m_widget->userModel()->addToProject(bundleMat);
|
m_widget->userModel()->addToProject(bundleMat);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
connectImporter();
|
||||||
|
}
|
||||||
|
|
||||||
|
return createWidgetInfo(m_widget.data(),
|
||||||
|
"ContentLibrary",
|
||||||
|
WidgetInfo::LeftPane,
|
||||||
|
0,
|
||||||
|
tr("Content Library"));
|
||||||
|
}
|
||||||
|
|
||||||
|
void ContentLibraryView::connectImporter()
|
||||||
|
{
|
||||||
#ifdef QDS_USE_PROJECTSTORAGE
|
#ifdef QDS_USE_PROJECTSTORAGE
|
||||||
connect(userModel,
|
connect(m_widget->importer(),
|
||||||
&ContentLibraryUserModel::bundleMaterialImported,
|
&ContentLibraryBundleImporter::importFinished,
|
||||||
this,
|
this,
|
||||||
[&](const QmlDesigner::TypeName &typeName) {
|
[&](const QmlDesigner::TypeName &typeName, const QString &bundleId) {
|
||||||
|
QTC_ASSERT(typeName.size(), return);
|
||||||
|
if (isMaterialBundle(bundleId)) {
|
||||||
applyBundleMaterialToDropTarget({}, typeName);
|
applyBundleMaterialToDropTarget({}, typeName);
|
||||||
|
} else if (isEffectBundle(bundleId)) {
|
||||||
|
if (!m_bundleEffectTarget)
|
||||||
|
m_bundleEffectTarget = Utils3D::active3DSceneNode(this);
|
||||||
|
|
||||||
|
QTC_ASSERT(m_bundleEffectTarget, return);
|
||||||
|
|
||||||
|
executeInTransaction("ContentLibraryView::widgetInfo", [&] {
|
||||||
|
QVector3D pos = m_bundleEffectPos.value<QVector3D>();
|
||||||
|
ModelNode newEffNode = createModelNode(
|
||||||
|
typeName, -1, -1, {{"x", pos.x()}, {"y", pos.y()}, {"z", pos.z()}});
|
||||||
|
m_bundleEffectTarget.defaultNodeListProperty().reparentHere(newEffNode);
|
||||||
|
clearSelectedModelNodes();
|
||||||
|
selectModelNode(newEffNode);
|
||||||
|
});
|
||||||
|
|
||||||
|
m_bundleEffectTarget = {};
|
||||||
|
m_bundleEffectPos = {};
|
||||||
|
}
|
||||||
});
|
});
|
||||||
#else
|
#else
|
||||||
connect(userModel,
|
connect(m_widget->importer(),
|
||||||
&ContentLibraryUserModel::bundleMaterialImported,
|
&ContentLibraryBundleImporter::importFinished,
|
||||||
this,
|
this,
|
||||||
[&](const QmlDesigner::NodeMetaInfo &metaInfo) {
|
[&](const QmlDesigner::NodeMetaInfo &metaInfo, const QString &bundleId) {
|
||||||
|
QTC_ASSERT(metaInfo.isValid(), return);
|
||||||
|
if (isMaterialBundle(bundleId)) {
|
||||||
applyBundleMaterialToDropTarget({}, metaInfo);
|
applyBundleMaterialToDropTarget({}, metaInfo);
|
||||||
|
} else if (isEffectBundle(bundleId)) {
|
||||||
|
if (!m_bundleEffectTarget)
|
||||||
|
m_bundleEffectTarget = Utils3D::active3DSceneNode(this);
|
||||||
|
|
||||||
|
QTC_ASSERT(m_bundleEffectTarget, return);
|
||||||
|
|
||||||
|
executeInTransaction("ContentLibraryView::connectImporter", [&] {
|
||||||
|
QVector3D pos = m_bundleEffectPos.value<QVector3D>();
|
||||||
|
ModelNode newEffNode = createModelNode(metaInfo.typeName(),
|
||||||
|
metaInfo.majorVersion(),
|
||||||
|
metaInfo.minorVersion(),
|
||||||
|
{{"x", pos.x()},
|
||||||
|
{"y", pos.y()},
|
||||||
|
{"z", pos.z()}});
|
||||||
|
m_bundleEffectTarget.defaultNodeListProperty().reparentHere(newEffNode);
|
||||||
|
clearSelectedModelNodes();
|
||||||
|
selectModelNode(newEffNode);
|
||||||
|
});
|
||||||
|
|
||||||
|
m_bundleEffectTarget = {};
|
||||||
|
m_bundleEffectPos = {};
|
||||||
|
}
|
||||||
});
|
});
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
connect(userModel, &ContentLibraryUserModel::bundleMaterialAboutToUnimport, this,
|
connect(m_widget->importer(), &ContentLibraryBundleImporter::aboutToUnimport, this,
|
||||||
[&] (const QmlDesigner::TypeName &type) {
|
[&] (const QmlDesigner::TypeName &type, const QString &bundleId) {
|
||||||
|
if (isMaterialBundle(bundleId)) {
|
||||||
// delete instances of the bundle material that is about to be unimported
|
// delete instances of the bundle material that is about to be unimported
|
||||||
executeInTransaction("ContentLibraryView::connectUserModel", [&] {
|
executeInTransaction("ContentLibraryView::connectImporter", [&] {
|
||||||
ModelNode matLib = Utils3D::materialLibraryNode(this);
|
ModelNode matLib = Utils3D::materialLibraryNode(this);
|
||||||
if (!matLib.isValid())
|
if (!matLib.isValid())
|
||||||
return;
|
return;
|
||||||
@@ -266,7 +209,28 @@ void ContentLibraryView::connectUserBundle()
|
|||||||
QmlObjectNode(mat).destroy();
|
QmlObjectNode(mat).destroy();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
} else if (isEffectBundle(bundleId)) {
|
||||||
|
// delete instances of the bundle effect that is about to be unimported
|
||||||
|
executeInTransaction("ContentLibraryView::connectImporter", [&] {
|
||||||
|
NodeMetaInfo metaInfo = model()->metaInfo(type);
|
||||||
|
QList<ModelNode> effects = allModelNodesOfType(metaInfo);
|
||||||
|
for (ModelNode &eff : effects)
|
||||||
|
eff.destroy();
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ContentLibraryView::isMaterialBundle(const QString &bundleId) const
|
||||||
|
{
|
||||||
|
auto compUtils = QmlDesignerPlugin::instance()->documentManager().generatedComponentUtils();
|
||||||
|
return bundleId == compUtils.materialsBundleId() || bundleId == compUtils.userMaterialsBundleId();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ContentLibraryView::isEffectBundle(const QString &bundleId) const
|
||||||
|
{
|
||||||
|
auto compUtils = QmlDesignerPlugin::instance()->documentManager().generatedComponentUtils();
|
||||||
|
return bundleId == compUtils.effectsBundleId() || bundleId == compUtils.userEffectsBundleId();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ContentLibraryView::modelAttached(Model *model)
|
void ContentLibraryView::modelAttached(Model *model)
|
||||||
@@ -294,9 +258,10 @@ void ContentLibraryView::modelAttached(Model *model)
|
|||||||
m_widget->userModel()->loadMaterialBundle();
|
m_widget->userModel()->loadMaterialBundle();
|
||||||
m_widget->userModel()->loadTextureBundle();
|
m_widget->userModel()->loadTextureBundle();
|
||||||
|
|
||||||
m_widget->materialsModel()->updateImportedState();
|
auto compUtils = QmlDesignerPlugin::instance()->documentManager().generatedComponentUtils();
|
||||||
m_widget->effectsModel()->updateImportedState();
|
m_widget->updateImportedState(compUtils.materialsBundleId());
|
||||||
m_widget->userModel()->updateImportedState();
|
m_widget->updateImportedState(compUtils.effectsBundleId());
|
||||||
|
m_widget->updateImportedState(compUtils.userMaterialsBundleId());
|
||||||
}
|
}
|
||||||
|
|
||||||
void ContentLibraryView::modelAboutToBeDetached(Model *model)
|
void ContentLibraryView::modelAboutToBeDetached(Model *model)
|
||||||
|
@@ -3,9 +3,9 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "abstractview.h"
|
#include <abstractview.h>
|
||||||
#include "createtexture.h"
|
#include <createtexture.h>
|
||||||
#include "nodemetainfo.h"
|
#include <nodemetainfo.h>
|
||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QPointer>
|
#include <QPointer>
|
||||||
@@ -48,7 +48,9 @@ public:
|
|||||||
const QVariant &data) override;
|
const QVariant &data) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void connectUserBundle();
|
void connectImporter();
|
||||||
|
bool isMaterialBundle(const QString &bundleId) const;
|
||||||
|
bool isEffectBundle(const QString &bundleId) const;
|
||||||
void active3DSceneChanged(qint32 sceneId);
|
void active3DSceneChanged(qint32 sceneId);
|
||||||
void updateBundlesQuick3DVersion();
|
void updateBundlesQuick3DVersion();
|
||||||
void addLibMaterial(const ModelNode &mat, const QPixmap &icon);
|
void addLibMaterial(const ModelNode &mat, const QPixmap &icon);
|
||||||
|
@@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
#include "contentlibrarywidget.h"
|
#include "contentlibrarywidget.h"
|
||||||
|
|
||||||
|
#include "contentlibrarybundleimporter.h"
|
||||||
#include "contentlibraryeffect.h"
|
#include "contentlibraryeffect.h"
|
||||||
#include "contentlibraryeffectsmodel.h"
|
#include "contentlibraryeffectsmodel.h"
|
||||||
#include "contentlibrarymaterial.h"
|
#include "contentlibrarymaterial.h"
|
||||||
@@ -18,6 +19,7 @@
|
|||||||
|
|
||||||
#include <coreplugin/icore.h>
|
#include <coreplugin/icore.h>
|
||||||
#include <designerpaths.h>
|
#include <designerpaths.h>
|
||||||
|
#include <nodemetainfo.h>
|
||||||
#include <qmldesignerconstants.h>
|
#include <qmldesignerconstants.h>
|
||||||
#include <qmldesignerplugin.h>
|
#include <qmldesignerplugin.h>
|
||||||
|
|
||||||
@@ -40,7 +42,6 @@
|
|||||||
#include <QQuickWidget>
|
#include <QQuickWidget>
|
||||||
#include <QRegularExpression>
|
#include <QRegularExpression>
|
||||||
#include <QShortcut>
|
#include <QShortcut>
|
||||||
#include <QStandardPaths>
|
|
||||||
#include <QVBoxLayout>
|
#include <QVBoxLayout>
|
||||||
|
|
||||||
namespace QmlDesigner {
|
namespace QmlDesigner {
|
||||||
@@ -177,6 +178,65 @@ ContentLibraryWidget::ContentLibraryWidget()
|
|||||||
{"userModel", QVariant::fromValue(m_userModel.data())}});
|
{"userModel", QVariant::fromValue(m_userModel.data())}});
|
||||||
|
|
||||||
reloadQmlSource();
|
reloadQmlSource();
|
||||||
|
createImporter();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ContentLibraryWidget::createImporter()
|
||||||
|
{
|
||||||
|
m_importer = new ContentLibraryBundleImporter();
|
||||||
|
#ifdef QDS_USE_PROJECTSTORAGE
|
||||||
|
connect(m_importer,
|
||||||
|
&ContentLibraryBundleImporter::importFinished,
|
||||||
|
this,
|
||||||
|
[&](const QmlDesigner::TypeName &typeName, const QString &bundleId) {
|
||||||
|
setImporterRunning(false);
|
||||||
|
if (typeName.size())
|
||||||
|
updateImportedState(bundleId);
|
||||||
|
});
|
||||||
|
#else
|
||||||
|
connect(m_importer,
|
||||||
|
&ContentLibraryBundleImporter::importFinished,
|
||||||
|
this,
|
||||||
|
[&](const QmlDesigner::NodeMetaInfo &metaInfo, const QString &bundleId) {
|
||||||
|
setImporterRunning(false);
|
||||||
|
if (metaInfo.isValid())
|
||||||
|
updateImportedState(bundleId);
|
||||||
|
});
|
||||||
|
#endif
|
||||||
|
|
||||||
|
connect(m_importer, &ContentLibraryBundleImporter::unimportFinished, this,
|
||||||
|
[&](const QmlDesigner::NodeMetaInfo &metaInfo, const QString &bundleId) {
|
||||||
|
Q_UNUSED(metaInfo)
|
||||||
|
setImporterRunning(false);
|
||||||
|
updateImportedState(bundleId);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
void ContentLibraryWidget::updateImportedState(const QString &bundleId)
|
||||||
|
{
|
||||||
|
if (!m_importer)
|
||||||
|
return;
|
||||||
|
|
||||||
|
Utils::FilePath bundlePath = m_importer->resolveBundleImportPath(bundleId);
|
||||||
|
|
||||||
|
QStringList importedItems;
|
||||||
|
if (bundlePath.exists()) {
|
||||||
|
importedItems = transform(bundlePath.dirEntries({{"*.qml"}, QDir::Files}),
|
||||||
|
[](const Utils::FilePath &f) { return f.baseName(); });
|
||||||
|
}
|
||||||
|
|
||||||
|
auto compUtils = QmlDesignerPlugin::instance()->documentManager().generatedComponentUtils();
|
||||||
|
if (bundleId == compUtils.materialsBundleId())
|
||||||
|
m_materialsModel->updateImportedState(importedItems);
|
||||||
|
else if (bundleId == compUtils.effectsBundleId())
|
||||||
|
m_effectsModel->updateImportedState(importedItems);
|
||||||
|
else if (bundleId == compUtils.userMaterialsBundleId())
|
||||||
|
m_userModel->updateImportedState(importedItems);
|
||||||
|
}
|
||||||
|
|
||||||
|
ContentLibraryBundleImporter *ContentLibraryWidget::importer() const
|
||||||
|
{
|
||||||
|
return m_importer;
|
||||||
}
|
}
|
||||||
|
|
||||||
QVariantMap ContentLibraryWidget::readTextureBundleJson()
|
QVariantMap ContentLibraryWidget::readTextureBundleJson()
|
||||||
@@ -683,6 +743,20 @@ void ContentLibraryWidget::setIsQt6Project(bool b)
|
|||||||
emit isQt6ProjectChanged();
|
emit isQt6ProjectChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ContentLibraryWidget::importerRunning() const
|
||||||
|
{
|
||||||
|
return m_importerRunning;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ContentLibraryWidget::setImporterRunning(bool b)
|
||||||
|
{
|
||||||
|
if (m_importerRunning == b)
|
||||||
|
return;
|
||||||
|
|
||||||
|
m_importerRunning = b;
|
||||||
|
emit importerRunningChanged();
|
||||||
|
}
|
||||||
|
|
||||||
void ContentLibraryWidget::reloadQmlSource()
|
void ContentLibraryWidget::reloadQmlSource()
|
||||||
{
|
{
|
||||||
const QString materialBrowserQmlPath = qmlSourcesPath() + "/ContentLibrary.qml";
|
const QString materialBrowserQmlPath = qmlSourcesPath() + "/ContentLibrary.qml";
|
||||||
|
@@ -4,7 +4,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "createtexture.h"
|
#include "createtexture.h"
|
||||||
|
#include <modelfwd.h>
|
||||||
#include <QFrame>
|
#include <QFrame>
|
||||||
#include <QPointer>
|
#include <QPointer>
|
||||||
|
|
||||||
@@ -18,6 +18,7 @@ class StudioQuickWidget;
|
|||||||
|
|
||||||
namespace QmlDesigner {
|
namespace QmlDesigner {
|
||||||
|
|
||||||
|
class ContentLibraryBundleImporter;
|
||||||
class ContentLibraryEffect;
|
class ContentLibraryEffect;
|
||||||
class ContentLibraryEffectsModel;
|
class ContentLibraryEffectsModel;
|
||||||
class ContentLibraryMaterial;
|
class ContentLibraryMaterial;
|
||||||
@@ -25,6 +26,7 @@ class ContentLibraryMaterialsModel;
|
|||||||
class ContentLibraryTexture;
|
class ContentLibraryTexture;
|
||||||
class ContentLibraryTexturesModel;
|
class ContentLibraryTexturesModel;
|
||||||
class ContentLibraryUserModel;
|
class ContentLibraryUserModel;
|
||||||
|
class NodeMetaInfo;
|
||||||
|
|
||||||
class ContentLibraryWidget : public QFrame
|
class ContentLibraryWidget : public QFrame
|
||||||
{
|
{
|
||||||
@@ -34,6 +36,7 @@ class ContentLibraryWidget : public QFrame
|
|||||||
Q_PROPERTY(bool hasMaterialLibrary READ hasMaterialLibrary NOTIFY hasMaterialLibraryChanged)
|
Q_PROPERTY(bool hasMaterialLibrary READ hasMaterialLibrary NOTIFY hasMaterialLibraryChanged)
|
||||||
Q_PROPERTY(bool hasActive3DScene READ hasActive3DScene WRITE setHasActive3DScene NOTIFY hasActive3DSceneChanged)
|
Q_PROPERTY(bool hasActive3DScene READ hasActive3DScene WRITE setHasActive3DScene NOTIFY hasActive3DSceneChanged)
|
||||||
Q_PROPERTY(bool isQt6Project READ isQt6Project NOTIFY isQt6ProjectChanged)
|
Q_PROPERTY(bool isQt6Project READ isQt6Project NOTIFY isQt6ProjectChanged)
|
||||||
|
Q_PROPERTY(bool importerRunning READ importerRunning WRITE setImporterRunning NOTIFY importerRunningChanged)
|
||||||
|
|
||||||
// Needed for a workaround for a bug where after drag-n-dropping an item, the ScrollView scrolls to a random position
|
// Needed for a workaround for a bug where after drag-n-dropping an item, the ScrollView scrolls to a random position
|
||||||
Q_PROPERTY(bool isDragging MEMBER m_isDragging NOTIFY isDraggingChanged)
|
Q_PROPERTY(bool isDragging MEMBER m_isDragging NOTIFY isDraggingChanged)
|
||||||
@@ -58,9 +61,13 @@ public:
|
|||||||
bool isQt6Project() const;
|
bool isQt6Project() const;
|
||||||
void setIsQt6Project(bool b);
|
void setIsQt6Project(bool b);
|
||||||
|
|
||||||
|
bool importerRunning() const;
|
||||||
|
void setImporterRunning(bool b);
|
||||||
|
|
||||||
Q_INVOKABLE void handleSearchFilterChanged(const QString &filterText);
|
Q_INVOKABLE void handleSearchFilterChanged(const QString &filterText);
|
||||||
|
|
||||||
void setMaterialsModel(QPointer<ContentLibraryMaterialsModel> newMaterialsModel);
|
void setMaterialsModel(QPointer<ContentLibraryMaterialsModel> newMaterialsModel);
|
||||||
|
void updateImportedState(const QString &bundleId);
|
||||||
|
|
||||||
QPointer<ContentLibraryMaterialsModel> materialsModel() const;
|
QPointer<ContentLibraryMaterialsModel> materialsModel() const;
|
||||||
QPointer<ContentLibraryTexturesModel> texturesModel() const;
|
QPointer<ContentLibraryTexturesModel> texturesModel() const;
|
||||||
@@ -80,6 +87,8 @@ public:
|
|||||||
|
|
||||||
QSize sizeHint() const override;
|
QSize sizeHint() const override;
|
||||||
|
|
||||||
|
ContentLibraryBundleImporter *importer() const;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void bundleEffectDragStarted(QmlDesigner::ContentLibraryEffect *bundleEff);
|
void bundleEffectDragStarted(QmlDesigner::ContentLibraryEffect *bundleEff);
|
||||||
void bundleMaterialDragStarted(QmlDesigner::ContentLibraryMaterial *bundleMat);
|
void bundleMaterialDragStarted(QmlDesigner::ContentLibraryMaterial *bundleMat);
|
||||||
@@ -91,6 +100,7 @@ signals:
|
|||||||
void hasActive3DSceneChanged();
|
void hasActive3DSceneChanged();
|
||||||
void isDraggingChanged();
|
void isDraggingChanged();
|
||||||
void isQt6ProjectChanged();
|
void isQt6ProjectChanged();
|
||||||
|
void importerRunningChanged();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool eventFilter(QObject *obj, QEvent *event) override;
|
bool eventFilter(QObject *obj, QEvent *event) override;
|
||||||
@@ -110,6 +120,7 @@ private:
|
|||||||
const QString &existingMetaFile, const QString downloadedMetaFile);
|
const QString &existingMetaFile, const QString downloadedMetaFile);
|
||||||
QStringList saveNewTextures(const QDir &bundleDir, const QStringList &newFiles);
|
QStringList saveNewTextures(const QDir &bundleDir, const QStringList &newFiles);
|
||||||
void populateTextureBundleModels();
|
void populateTextureBundleModels();
|
||||||
|
void createImporter();
|
||||||
|
|
||||||
QScopedPointer<StudioQuickWidget> m_quickWidget;
|
QScopedPointer<StudioQuickWidget> m_quickWidget;
|
||||||
QPointer<ContentLibraryMaterialsModel> m_materialsModel;
|
QPointer<ContentLibraryMaterialsModel> m_materialsModel;
|
||||||
@@ -118,6 +129,8 @@ private:
|
|||||||
QPointer<ContentLibraryEffectsModel> m_effectsModel;
|
QPointer<ContentLibraryEffectsModel> m_effectsModel;
|
||||||
QPointer<ContentLibraryUserModel> m_userModel;
|
QPointer<ContentLibraryUserModel> m_userModel;
|
||||||
|
|
||||||
|
ContentLibraryBundleImporter *m_importer = nullptr;
|
||||||
|
|
||||||
QShortcut *m_qmlSourceUpdateShortcut = nullptr;
|
QShortcut *m_qmlSourceUpdateShortcut = nullptr;
|
||||||
|
|
||||||
QString m_filterText;
|
QString m_filterText;
|
||||||
@@ -132,6 +145,7 @@ private:
|
|||||||
bool m_hasQuick3DImport = false;
|
bool m_hasQuick3DImport = false;
|
||||||
bool m_isDragging = false;
|
bool m_isDragging = false;
|
||||||
bool m_isQt6Project = false;
|
bool m_isQt6Project = false;
|
||||||
|
bool m_importerRunning = false;
|
||||||
QString m_textureBundleUrl;
|
QString m_textureBundleUrl;
|
||||||
QString m_bundlePath;
|
QString m_bundlePath;
|
||||||
};
|
};
|
||||||
|
@@ -186,4 +186,35 @@ QString GeneratedComponentUtils::effectsBundleType() const
|
|||||||
return basePrefix + '.' + QLatin1String(Constants::COMPONENT_BUNDLES_EFFECT_BUNDLE_TYPE);
|
return basePrefix + '.' + QLatin1String(Constants::COMPONENT_BUNDLES_EFFECT_BUNDLE_TYPE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString GeneratedComponentUtils::materialsBundleId() const
|
||||||
|
{
|
||||||
|
bool isNewImportDir = generatedComponentTypePrefix().endsWith(Constants::GENERATED_COMPONENTS_FOLDER);
|
||||||
|
|
||||||
|
return QLatin1String(isNewImportDir ? Constants::COMPONENT_BUNDLES_MATERIAL_BUNDLE_TYPE
|
||||||
|
: Constants::OLD_COMPONENT_BUNDLES_MATERIAL_BUNDLE_TYPE);
|
||||||
|
}
|
||||||
|
|
||||||
|
QString GeneratedComponentUtils::effectsBundleId() const
|
||||||
|
{
|
||||||
|
bool isNewImportDir = generatedComponentTypePrefix().endsWith(Constants::GENERATED_COMPONENTS_FOLDER);
|
||||||
|
|
||||||
|
return QLatin1String(isNewImportDir ? Constants::COMPONENT_BUNDLES_EFFECT_BUNDLE_TYPE
|
||||||
|
: Constants::OLD_COMPONENT_BUNDLES_EFFECT_BUNDLE_TYPE);
|
||||||
|
}
|
||||||
|
|
||||||
|
QString GeneratedComponentUtils::userMaterialsBundleId() const
|
||||||
|
{
|
||||||
|
return QLatin1String(Constants::COMPONENT_BUNDLES_USER_MATERIAL_BUNDLE_TYPE);
|
||||||
|
}
|
||||||
|
|
||||||
|
QString GeneratedComponentUtils::userEffectsBundleId() const
|
||||||
|
{
|
||||||
|
return QLatin1String(Constants::COMPONENT_BUNDLES_USER_EFFECT_BUNDLE_TYPE);
|
||||||
|
}
|
||||||
|
|
||||||
|
QString GeneratedComponentUtils::user3DBundleId() const
|
||||||
|
{
|
||||||
|
return QLatin1String(Constants::COMPONENT_BUNDLES_USER_3D_BUNDLE_TYPE);
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace QmlDesigner
|
} // namespace QmlDesigner
|
||||||
|
@@ -35,6 +35,12 @@ public:
|
|||||||
QString materialsBundleType() const;
|
QString materialsBundleType() const;
|
||||||
QString effectsBundleType() const;
|
QString effectsBundleType() const;
|
||||||
|
|
||||||
|
QString materialsBundleId() const;
|
||||||
|
QString effectsBundleId() const;
|
||||||
|
QString userMaterialsBundleId() const;
|
||||||
|
QString userEffectsBundleId() const;
|
||||||
|
QString user3DBundleId() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
ExternalDependenciesInterface &m_externalDependencies;
|
ExternalDependenciesInterface &m_externalDependencies;
|
||||||
};
|
};
|
||||||
|
@@ -81,6 +81,9 @@ inline constexpr char QML_DESIGNER_SUBFOLDER[] = "/designer/";
|
|||||||
inline constexpr char COMPONENT_BUNDLES_TYPE[] = "Bundles";
|
inline constexpr char COMPONENT_BUNDLES_TYPE[] = "Bundles";
|
||||||
inline constexpr char COMPONENT_BUNDLES_MATERIAL_BUNDLE_TYPE[] = "Materials";
|
inline constexpr char COMPONENT_BUNDLES_MATERIAL_BUNDLE_TYPE[] = "Materials";
|
||||||
inline constexpr char COMPONENT_BUNDLES_EFFECT_BUNDLE_TYPE[] = "Effects";
|
inline constexpr char COMPONENT_BUNDLES_EFFECT_BUNDLE_TYPE[] = "Effects";
|
||||||
|
inline constexpr char COMPONENT_BUNDLES_USER_MATERIAL_BUNDLE_TYPE[] = "UserMaterials";
|
||||||
|
inline constexpr char COMPONENT_BUNDLES_USER_EFFECT_BUNDLE_TYPE[] = "UserEffects";
|
||||||
|
inline constexpr char COMPONENT_BUNDLES_USER_3D_BUNDLE_TYPE[] = "User3D";
|
||||||
inline constexpr char GENERATED_COMPONENTS_FOLDER[] = "Generated";
|
inline constexpr char GENERATED_COMPONENTS_FOLDER[] = "Generated";
|
||||||
inline constexpr char COMPONENT_BUNDLES_ASSET_REF_FILE[] = "_asset_ref.json";
|
inline constexpr char COMPONENT_BUNDLES_ASSET_REF_FILE[] = "_asset_ref.json";
|
||||||
inline constexpr char OLD_QUICK_3D_ASSETS_FOLDER[] = "Quick3DAssets";
|
inline constexpr char OLD_QUICK_3D_ASSETS_FOLDER[] = "Quick3DAssets";
|
||||||
|
Reference in New Issue
Block a user