QmlDesigner: Rename user bundles json files to just bundle.json

Change-Id: I23440591083146d9630d0beec8a22efbc5339d35
Reviewed-by: Miikka Heikkinen <miikka.heikkinen@qt.io>
This commit is contained in:
Mahmoud Badri
2024-05-28 12:27:56 +03:00
parent b01e039cec
commit fa3a6a39d6
3 changed files with 11 additions and 9 deletions

View File

@@ -12,6 +12,7 @@
#include <designerpaths.h> #include <designerpaths.h>
#include <imageutils.h> #include <imageutils.h>
#include <qmldesignerconstants.h>
#include <qmldesignerplugin.h> #include <qmldesignerplugin.h>
#include <uniquename.h> #include <uniquename.h>
@@ -213,7 +214,7 @@ void ContentLibraryUserModel::removeMaterialFromContentLib(ContentLibraryMateria
} }
m_bundleObjMaterial.insert("items", itemsArr); m_bundleObjMaterial.insert("items", itemsArr);
auto result = bundlePath.pathAppended("user_material_bundle.json") auto result = bundlePath.pathAppended(Constants::BUNDLE_JSON_FILENAME)
.writeFileContents(QJsonDocument(m_bundleObjMaterial).toJson()); .writeFileContents(QJsonDocument(m_bundleObjMaterial).toJson());
if (!result) if (!result)
qWarning() << __FUNCTION__ << result.error(); qWarning() << __FUNCTION__ << result.error();
@@ -265,7 +266,7 @@ void ContentLibraryUserModel::remove3DFromContentLib(ContentLibraryItem *item)
} }
m_bundleObj3D.insert("items", itemsArr); m_bundleObj3D.insert("items", itemsArr);
auto result = m_bundlePath3D.pathAppended("user_3d_bundle.json") auto result = m_bundlePath3D.pathAppended(Constants::BUNDLE_JSON_FILENAME)
.writeFileContents(QJsonDocument(m_bundleObj3D).toJson()); .writeFileContents(QJsonDocument(m_bundleObj3D).toJson());
if (!result) if (!result)
qWarning() << __FUNCTION__ << result.error(); qWarning() << __FUNCTION__ << result.error();
@@ -384,7 +385,7 @@ void ContentLibraryUserModel::loadMaterialBundle()
m_bundlePathMaterial.ensureWritableDir(); m_bundlePathMaterial.ensureWritableDir();
m_bundlePathMaterial.pathAppended("icons").ensureWritableDir(); m_bundlePathMaterial.pathAppended("icons").ensureWritableDir();
auto jsonFilePath = m_bundlePathMaterial.pathAppended("user_materials_bundle.json"); auto jsonFilePath = m_bundlePathMaterial.pathAppended(Constants::BUNDLE_JSON_FILENAME);
if (!jsonFilePath.exists()) { if (!jsonFilePath.exists()) {
QString jsonContent = "{\n"; QString jsonContent = "{\n";
jsonContent += " \"id\": \"UserMaterials\",\n"; jsonContent += " \"id\": \"UserMaterials\",\n";
@@ -407,7 +408,7 @@ void ContentLibraryUserModel::loadMaterialBundle()
QJsonDocument bundleJsonDoc = QJsonDocument::fromJson(jsonContents.value()); QJsonDocument bundleJsonDoc = QJsonDocument::fromJson(jsonContents.value());
if (bundleJsonDoc.isNull()) { if (bundleJsonDoc.isNull()) {
qWarning() << __FUNCTION__ << "Invalid user_materials_bundle.json file"; qWarning() << __FUNCTION__ << "Invalid json file" << jsonFilePath;
emit dataChanged(index(MaterialsSectionIdx), index(MaterialsSectionIdx)); emit dataChanged(index(MaterialsSectionIdx), index(MaterialsSectionIdx));
return; return;
} }
@@ -464,7 +465,7 @@ void ContentLibraryUserModel::load3DBundle()
m_bundlePath3D.ensureWritableDir(); m_bundlePath3D.ensureWritableDir();
m_bundlePath3D.pathAppended("icons").ensureWritableDir(); m_bundlePath3D.pathAppended("icons").ensureWritableDir();
auto jsonFilePath = m_bundlePath3D.pathAppended("user_3d_bundle.json"); auto jsonFilePath = m_bundlePath3D.pathAppended(Constants::BUNDLE_JSON_FILENAME);
if (!jsonFilePath.exists()) { if (!jsonFilePath.exists()) {
QByteArray jsonContent = "{\n"; QByteArray jsonContent = "{\n";
jsonContent += " \"id\": \"User3D\",\n"; jsonContent += " \"id\": \"User3D\",\n";
@@ -487,7 +488,7 @@ void ContentLibraryUserModel::load3DBundle()
QJsonDocument bundleJsonDoc = QJsonDocument::fromJson(jsonContents.value()); QJsonDocument bundleJsonDoc = QJsonDocument::fromJson(jsonContents.value());
if (bundleJsonDoc.isNull()) { if (bundleJsonDoc.isNull()) {
qWarning() << __FUNCTION__ << "Invalid user_3d_bundle.json file"; qWarning() << __FUNCTION__ << "Invalid json file" << jsonFilePath;
emit dataChanged(index(Items3DSectionIdx), index(Items3DSectionIdx)); emit dataChanged(index(Items3DSectionIdx), index(Items3DSectionIdx));
return; return;
} }

View File

@@ -535,7 +535,7 @@ void ContentLibraryView::addLibMaterial(const ModelNode &node, const QPixmap &ic
itemsArr.append(itemObj); itemsArr.append(itemObj);
jsonRef["items"] = itemsArr; jsonRef["items"] = itemsArr;
auto result = bundlePath.pathAppended("user_materials_bundle.json") auto result = bundlePath.pathAppended(Constants::BUNDLE_JSON_FILENAME)
.writeFileContents(QJsonDocument(jsonRef).toJson()); .writeFileContents(QJsonDocument(jsonRef).toJson());
if (!result) if (!result)
qWarning() << __FUNCTION__ << result.error(); qWarning() << __FUNCTION__ << result.error();
@@ -731,7 +731,7 @@ void ContentLibraryView::addLib3DComponent(const ModelNode &node)
jsonRef["items"] = itemsArr; jsonRef["items"] = itemsArr;
auto result = bundlePath.pathAppended("user_3d_bundle.json") auto result = bundlePath.pathAppended(Constants::BUNDLE_JSON_FILENAME)
.writeFileContents(QJsonDocument(jsonRef).toJson()); .writeFileContents(QJsonDocument(jsonRef).toJson());
if (!result) if (!result)
qWarning() << __FUNCTION__ << result.error(); qWarning() << __FUNCTION__ << result.error();
@@ -771,7 +771,7 @@ void ContentLibraryView::addLib3DItem(const ModelNode &node)
jsonRef["items"] = itemsArr; jsonRef["items"] = itemsArr;
auto result = bundlePath.pathAppended("user_3d_bundle.json") auto result = bundlePath.pathAppended(Constants::BUNDLE_JSON_FILENAME)
.writeFileContents(QJsonDocument(jsonRef).toJson()); .writeFileContents(QJsonDocument(jsonRef).toJson());
if (!result) if (!result)
qWarning() << __FUNCTION__ << result.error(); qWarning() << __FUNCTION__ << result.error();

View File

@@ -78,6 +78,7 @@ inline constexpr char EDIT3D_SNAP_CONFIG[] = "QmlDesigner.Editor3D.SnapConfig";
inline constexpr char EDIT3D_CAMERA_SPEED_CONFIG[] = "QmlDesigner.Editor3D.CameraSpeedConfig"; inline constexpr char EDIT3D_CAMERA_SPEED_CONFIG[] = "QmlDesigner.Editor3D.CameraSpeedConfig";
inline constexpr char QML_DESIGNER_SUBFOLDER[] = "/designer/"; inline constexpr char QML_DESIGNER_SUBFOLDER[] = "/designer/";
inline constexpr char BUNDLE_JSON_FILENAME[] = "bundle.json";
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";