QmlDesigner: Tweak generated components folders

Old type names were too long, shortened various names:
"GeneratedComponents" -> "Generated"
"ComponentBundles" -> "Bundles"
"MaterialBundle" -> "Materials"
"EffectBundle" -> "Effects"
"UserMaterialBundle" -> "UserMaterials"

Fixes: QDS-12629
Change-Id: I3a49e57bbc8d401cadd8c5de6648c7229579d2b2
Reviewed-by: Qt CI Patch Build Bot <ci_patchbuild_bot@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Mahmoud Badri <mahmoud.badri@qt.io>
This commit is contained in:
Miikka Heikkinen
2024-04-30 13:39:05 +03:00
parent 8ed54cb3a8
commit 6cc8c13c7c
17 changed files with 98 additions and 32 deletions

View File

@@ -451,7 +451,7 @@ Row {
// Prefer hiding generated component files rather than other project files
let listIndex = nameMap.get(item.fileName)
let absPath = comboBox.listModel.get(listIndex).absoluteFilePath
if (absPath.includes("/GeneratedComponents/") || absPath.includes("/asset_imports/")) {
if (absPath.includes("/Generated/") || absPath.includes("/asset_imports/")) {
comboBox.listModel.set(listIndex, {
absoluteFilePath: item.absoluteFilePath,
relativeFilePath: item.relativeFilePath,

View File

@@ -18,7 +18,7 @@
{ "key": "ProjectPluginClassName", "value": "%{ProjectName}Plugin" },
{ "key": "QmlProjectFileName", "value": "%{JS: Util.fileName('%{ProjectName}', 'qmlproject')}" },
{ "key": "IsQt6Project", "value": "%{JS: value('QtQuickVersion') !== '2.15' }" },
{ "key": "AssetDir", "value": "GeneratedComponents" },
{ "key": "AssetDir", "value": "Generated" },
{ "key": "ContentDir", "value": "%{ProjectName}Content" },
{ "key": "ImportModuleName", "value": "%{ProjectName}" },
{ "key": "UIClassName", "value": "Screen01" },

View File

@@ -18,7 +18,7 @@
{ "key": "ProjectPluginClassName", "value": "%{ProjectName}Plugin" },
{ "key": "QmlProjectFileName", "value": "%{JS: Util.fileName('%{ProjectName}', 'qmlproject')}" },
{ "key": "IsQt6Project", "value": "%{JS: value('QtQuickVersion') !== '2.15' }" },
{ "key": "AssetDir", "value": "GeneratedComponents" },
{ "key": "AssetDir", "value": "Generated" },
{ "key": "ContentDir", "value": "%{ProjectName}Content" },
{ "key": "ImportModuleName", "value": "%{ProjectName}" },
{ "key": "UIClassName", "value": "Screen01" },

View File

@@ -17,7 +17,7 @@
{ "key": "ProjectPluginName", "value": "%{ProjectName}plugin" },
{ "key": "ProjectPluginClassName", "value": "%{ProjectName}Plugin" },
{ "key": "QmlProjectFileName", "value": "%{JS: Util.fileName('%{ProjectName}', 'qmlproject')}" },
{ "key": "AssetDir", "value": "GeneratedComponents" },
{ "key": "AssetDir", "value": "Generated" },
{ "key": "ContentDir", "value": "%{ProjectName}Content" },
{ "key": "ImportModuleName", "value": "%{ProjectName}" },
{ "key": "UIClassName", "value": "Screen01" },

View File

@@ -17,7 +17,7 @@
{ "key": "ProjectPluginName", "value": "%{ProjectName}plugin" },
{ "key": "ProjectPluginClassName", "value": "%{ProjectName}Plugin" },
{ "key": "QmlProjectFileName", "value": "%{JS: Util.fileName('%{ProjectName}', 'qmlproject')}" },
{ "key": "AssetDir", "value": "GeneratedComponents" },
{ "key": "AssetDir", "value": "Generated" },
{ "key": "ContentDir", "value": "%{ProjectName}Content" },
{ "key": "ImportModuleName", "value": "%{ProjectName}" },
{ "key": "UIClassName", "value": "Screen01" },

View File

@@ -17,7 +17,7 @@
{ "key": "ProjectPluginName", "value": "%{ProjectName}plugin" },
{ "key": "ProjectPluginClassName", "value": "%{ProjectName}Plugin" },
{ "key": "QmlProjectFileName", "value": "%{JS: Util.fileName('%{ProjectName}', 'qmlproject')}" },
{ "key": "AssetDir", "value": "GeneratedComponents" },
{ "key": "AssetDir", "value": "Generated" },
{ "key": "ContentDir", "value": "%{ProjectName}Content" },
{ "key": "ImportModuleName", "value": "%{ProjectName}" },
{ "key": "UIClassName", "value": "Screen01" },

View File

@@ -17,7 +17,7 @@
{ "key": "ProjectPluginName", "value": "%{ProjectName}plugin" },
{ "key": "ProjectPluginClassName", "value": "%{ProjectName}Plugin" },
{ "key": "QmlProjectFileName", "value": "%{JS: Util.fileName('%{ProjectName}', 'qmlproject')}" },
{ "key": "AssetDir", "value": "GeneratedComponents" },
{ "key": "AssetDir", "value": "Generated" },
{ "key": "ContentDir", "value": "%{ProjectName}Content" },
{ "key": "ImportModuleName", "value": "%{ProjectName}" },
{ "key": "IsQt6Project", "value": "%{JS: value('QtQuickVersion') !== '2.15' }" },

View File

@@ -17,7 +17,7 @@
{ "key": "ProjectPluginName", "value": "%{ProjectName}plugin" },
{ "key": "ProjectPluginClassName", "value": "%{ProjectName}Plugin" },
{ "key": "QmlProjectFileName", "value": "%{JS: Util.fileName('%{ProjectName}', 'qmlproject')}" },
{ "key": "AssetDir", "value": "GeneratedComponents" },
{ "key": "AssetDir", "value": "Generated" },
{ "key": "ContentDir", "value": "%{ProjectName}Content" },
{ "key": "ImportModuleName", "value": "%{ProjectName}" },
{ "key": "IsQt6Project", "value": "%{JS: value('QtQuickVersion') !== '2.15' }" },

View File

@@ -172,7 +172,11 @@ void ContentLibraryEffectsModel::loadBundle()
}
}
QString bundleId = m_bundleObj.value("id").toString();
QString bundleType = QmlDesignerPlugin::instance()->documentManager()
.generatedComponentUtils().effectsBundleType();
// Substitute correct id to avoid issues with old bundles
m_bundleObj["id"] = bundleType.split('.').last();
const QJsonObject catsObj = m_bundleObj.value("categories").toObject();
const QStringList categories = catsObj.keys();
@@ -191,11 +195,8 @@ void ContentLibraryEffectsModel::loadBundle()
QUrl icon = QUrl::fromLocalFile(bundleDir.filePath(itemObj.value("icon").toString()));
QString qml = itemObj.value("qml").toString();
TypeName type = QLatin1String("%1.%2.%3")
.arg(QmlDesignerPlugin::instance()->documentManager()
.generatedComponentUtils().componentBundlesTypePrefix(),
bundleId,
qml.chopped(4)).toLatin1(); // chopped(4): remove .qml
TypeName type = QLatin1String("%1.%2")
.arg(bundleType, qml.chopped(4)).toLatin1(); // chopped(4): remove .qml
auto bundleItem = new ContentLibraryEffect(category, item, qml, type, icon, files);

View File

@@ -273,7 +273,11 @@ void ContentLibraryMaterialsModel::loadMaterialBundle(const QDir &matBundleDir)
}
}
QString bundleId = m_matBundleObj.value("id").toString();
QString bundleType = QmlDesignerPlugin::instance()->documentManager()
.generatedComponentUtils().materialsBundleType();
// Substitute correct id to avoid issues with old bundles
m_matBundleObj["id"] = bundleType.split('.').last();
const QJsonObject catsObj = m_matBundleObj.value("categories").toObject();
const QStringList categories = catsObj.keys();
@@ -292,11 +296,8 @@ void ContentLibraryMaterialsModel::loadMaterialBundle(const QDir &matBundleDir)
QUrl icon = QUrl::fromLocalFile(matBundleDir.filePath(matObj.value("icon").toString()));
QString qml = matObj.value("qml").toString();
TypeName type = QLatin1String("%1.%2.%3")
.arg(QmlDesignerPlugin::instance()->documentManager()
.generatedComponentUtils().componentBundlesTypePrefix(),
bundleId,
qml.chopped(4)).toLatin1(); // chopped(4): remove .qml
TypeName type = QLatin1String("%1.%2")
.arg(bundleType, qml.chopped(4)).toLatin1(); // chopped(4): remove .qml
auto bundleMat = new ContentLibraryMaterial(category, matName, qml, type, icon, files,
m_downloadPath, m_baseUrl);

View File

@@ -282,7 +282,7 @@ void ContentLibraryUserModel::loadMaterialBundle()
auto jsonFilePath = Utils::FilePath::fromString(bundleDir.filePath("user_materials_bundle.json"));
if (!jsonFilePath.exists()) {
QString jsonContent = "{\n";
jsonContent += " \"id\": \"UserMaterialBundle\",\n";
jsonContent += " \"id\": \"UserMaterials\",\n";
jsonContent += " \"materials\": {\n";
jsonContent += " }\n";
jsonContent += "}";
@@ -304,7 +304,10 @@ void ContentLibraryUserModel::loadMaterialBundle()
}
}
m_bundleIdMaterial = m_bundleObj.value("id").toString();
m_bundleIdMaterial = "UserMaterials";
// Substitute correct id to avoid issues with old bundles
m_bundleObj["id"] = m_bundleIdMaterial;
// parse materials
const QJsonObject matsObj = m_bundleObj.value("materials").toObject();

View File

@@ -23,6 +23,7 @@
#include "utils3d.h"
#include <designerpaths.h>
#include <qmldesignerplugin.h>
#include <coreplugin/messagebox.h>
#include <enumeration.h>

View File

@@ -316,9 +316,12 @@ void ItemLibraryModel::update(Model *model)
GeneratedComponentUtils compUtils = QmlDesignerPlugin::instance()->documentManager()
.generatedComponentUtils();
const QString compBundlePrefix = compUtils.componentBundlesTypePrefix();
QStringList excludedImports {
compUtils.componentBundlesTypePrefix() + ".MaterialBundle",
compUtils.componentBundlesTypePrefix() + ".EffectBundle"
compBundlePrefix + '.' + QLatin1String(Constants::COMPONENT_BUNDLES_MATERIAL_BUNDLE_TYPE),
compBundlePrefix + '.' + QLatin1String(Constants::COMPONENT_BUNDLES_EFFECT_BUNDLE_TYPE),
compBundlePrefix + '.' + QLatin1String(Constants::OLD_COMPONENT_BUNDLES_MATERIAL_BUNDLE_TYPE),
compBundlePrefix + '.' + QLatin1String(Constants::OLD_COMPONENT_BUNDLES_EFFECT_BUNDLE_TYPE)
};
// create import sections

View File

@@ -103,9 +103,8 @@ ChooseFromPropertyListFilter::ChooseFromPropertyListFilter(const NodeMetaInfo &i
// TODO add the types here or use the module
#else
} else if (insertInfo.typeName().startsWith(
QString("%1.MaterialBundle").arg(QmlDesignerPlugin::instance()->documentManager()
.generatedComponentUtils().componentBundlesTypePrefix())
.toUtf8())) {
QmlDesignerPlugin::instance()->documentManager()
.generatedComponentUtils().materialsBundleType().toUtf8())) {
if (parentInfo.isQtQuick3DModel())
propertyList.append("materials");
#endif

View File

@@ -60,7 +60,10 @@ Utils::FilePath GeneratedComponentUtils::componentBundlesBasePath() const
if (basePath.isEmpty())
return {};
if (basePath.endsWith(Constants::GENERATED_COMPONENTS_FOLDER))
return basePath.resolvePath(QLatin1String(Constants::COMPONENT_BUNDLES_TYPE));
return basePath.resolvePath(QLatin1String(Constants::OLD_COMPONENT_BUNDLES_TYPE));
}
Utils::FilePath GeneratedComponentUtils::import3dBasePath() const
@@ -77,6 +80,32 @@ Utils::FilePath GeneratedComponentUtils::import3dBasePath() const
return basePath.resolvePath(QLatin1String(Constants::QUICK_3D_COMPONENTS_FOLDER));
}
Utils::FilePath GeneratedComponentUtils::materialBundlePath() const
{
Utils::FilePath basePath = componentBundlesBasePath();
if (basePath.isEmpty())
return {};
if (basePath.endsWith(Constants::OLD_COMPONENT_BUNDLES_TYPE))
return basePath.resolvePath(QLatin1String(Constants::OLD_COMPONENT_BUNDLES_MATERIAL_BUNDLE_TYPE));
return basePath.resolvePath(QLatin1String(Constants::COMPONENT_BUNDLES_MATERIAL_BUNDLE_TYPE));
}
Utils::FilePath GeneratedComponentUtils::effectBundlePath() const
{
Utils::FilePath basePath = componentBundlesBasePath();
if (basePath.isEmpty())
return {};
if (basePath.endsWith(Constants::OLD_COMPONENT_BUNDLES_TYPE))
return basePath.resolvePath(QLatin1String(Constants::OLD_COMPONENT_BUNDLES_EFFECT_BUNDLE_TYPE));
return basePath.resolvePath(QLatin1String(Constants::COMPONENT_BUNDLES_EFFECT_BUNDLE_TYPE));
}
bool GeneratedComponentUtils::isImport3dPath(const QString &path) const
{
return path.contains('/' + QLatin1String(Constants::OLD_QUICK_3D_ASSETS_FOLDER))
@@ -123,7 +152,7 @@ QString GeneratedComponentUtils::componentBundlesTypePrefix() const
if (basePrefix.endsWith(Constants::GENERATED_COMPONENTS_FOLDER))
return basePrefix + '.' + QLatin1String(Constants::COMPONENT_BUNDLES_TYPE);
return Constants::COMPONENT_BUNDLES_TYPE;
return Constants::OLD_COMPONENT_BUNDLES_TYPE;
}
QString GeneratedComponentUtils::composedEffectsTypePrefix() const
@@ -136,4 +165,24 @@ QString GeneratedComponentUtils::composedEffectsTypePrefix() const
return Constants::OLD_EFFECTS_FOLDER;
}
QString GeneratedComponentUtils::materialsBundleType() const
{
QString basePrefix = componentBundlesTypePrefix();
if (basePrefix.endsWith(Constants::OLD_COMPONENT_BUNDLES_TYPE))
return basePrefix + '.' + QLatin1String(Constants::OLD_COMPONENT_BUNDLES_MATERIAL_BUNDLE_TYPE);
return basePrefix + '.' + QLatin1String(Constants::COMPONENT_BUNDLES_MATERIAL_BUNDLE_TYPE);
}
QString GeneratedComponentUtils::effectsBundleType() const
{
QString basePrefix = componentBundlesTypePrefix();
if (basePrefix.endsWith(Constants::OLD_COMPONENT_BUNDLES_TYPE))
return basePrefix + '.' + QLatin1String(Constants::OLD_COMPONENT_BUNDLES_EFFECT_BUNDLE_TYPE);
return basePrefix + '.' + QLatin1String(Constants::COMPONENT_BUNDLES_EFFECT_BUNDLE_TYPE);
}
} // namespace QmlDesigner

View File

@@ -21,6 +21,8 @@ public:
Utils::FilePath composedEffectPath(const QString &effectPath) const;
Utils::FilePath componentBundlesBasePath() const;
Utils::FilePath import3dBasePath() const;
Utils::FilePath materialBundlePath() const;
Utils::FilePath effectBundlePath() const;
bool isImport3dPath(const QString &path) const;
bool isComposedEffectPath(const QString &path) const;
@@ -30,6 +32,8 @@ public:
QString import3dTypePath() const;
QString componentBundlesTypePrefix() const;
QString composedEffectsTypePrefix() const;
QString materialsBundleType() const;
QString effectsBundleType() const;
private:
ExternalDependenciesInterface &m_externalDependencies;

View File

@@ -78,8 +78,10 @@ inline constexpr char EDIT3D_SNAP_CONFIG[] = "QmlDesigner.Editor3D.SnapConfig";
inline constexpr char EDIT3D_CAMERA_SPEED_CONFIG[] = "QmlDesigner.Editor3D.CameraSpeedConfig";
inline constexpr char QML_DESIGNER_SUBFOLDER[] = "/designer/";
inline constexpr char COMPONENT_BUNDLES_TYPE[] = "ComponentBundles";
inline constexpr char GENERATED_COMPONENTS_FOLDER[] = "GeneratedComponents";
inline constexpr char COMPONENT_BUNDLES_TYPE[] = "Bundles";
inline constexpr char COMPONENT_BUNDLES_MATERIAL_BUNDLE_TYPE[] = "Materials";
inline constexpr char COMPONENT_BUNDLES_EFFECT_BUNDLE_TYPE[] = "Effects";
inline constexpr char GENERATED_COMPONENTS_FOLDER[] = "Generated";
inline constexpr char COMPONENT_BUNDLES_ASSET_REF_FILE[] = "_asset_ref.json";
inline constexpr char OLD_QUICK_3D_ASSETS_FOLDER[] = "Quick3DAssets";
inline constexpr char QUICK_3D_COMPONENTS_FOLDER[] = "QtQuick3D";
@@ -90,6 +92,9 @@ inline constexpr char QUICK_3D_ASSET_IMPORT_DATA_SOURCE_KEY[] = "source_scene";
inline constexpr char OLD_ASSET_IMPORT_FOLDER[] = "asset_imports";
inline constexpr char OLD_EFFECTS_IMPORT_FOLDER[] = "/asset_imports/Effects";
inline constexpr char OLD_EFFECTS_FOLDER[] = "Effects";
inline constexpr char OLD_COMPONENT_BUNDLES_TYPE[] = "ComponentBundles";
inline constexpr char OLD_COMPONENT_BUNDLES_MATERIAL_BUNDLE_TYPE[] = "MaterialBundle";
inline constexpr char OLD_COMPONENT_BUNDLES_EFFECT_BUNDLE_TYPE[] = "EffectBundle";
inline constexpr char COMPOSED_EFFECTS_TYPE[] = "ComposedEffects";
inline constexpr char MATERIAL_LIB_ID[] = "__materialLibrary__";