diff --git a/src/plugins/qmldesigner/components/contentlibrary/contentlibraryusermodel.cpp b/src/plugins/qmldesigner/components/contentlibrary/contentlibraryusermodel.cpp index 2af636da6d6..8dcf4575f78 100644 --- a/src/plugins/qmldesigner/components/contentlibrary/contentlibraryusermodel.cpp +++ b/src/plugins/qmldesigner/components/contentlibrary/contentlibraryusermodel.cpp @@ -12,6 +12,7 @@ #include #include +#include #include #include @@ -213,7 +214,7 @@ void ContentLibraryUserModel::removeMaterialFromContentLib(ContentLibraryMateria } 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()); if (!result) qWarning() << __FUNCTION__ << result.error(); @@ -265,7 +266,7 @@ void ContentLibraryUserModel::remove3DFromContentLib(ContentLibraryItem *item) } 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()); if (!result) qWarning() << __FUNCTION__ << result.error(); @@ -384,7 +385,7 @@ void ContentLibraryUserModel::loadMaterialBundle() m_bundlePathMaterial.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()) { QString jsonContent = "{\n"; jsonContent += " \"id\": \"UserMaterials\",\n"; @@ -407,7 +408,7 @@ void ContentLibraryUserModel::loadMaterialBundle() QJsonDocument bundleJsonDoc = QJsonDocument::fromJson(jsonContents.value()); if (bundleJsonDoc.isNull()) { - qWarning() << __FUNCTION__ << "Invalid user_materials_bundle.json file"; + qWarning() << __FUNCTION__ << "Invalid json file" << jsonFilePath; emit dataChanged(index(MaterialsSectionIdx), index(MaterialsSectionIdx)); return; } @@ -464,7 +465,7 @@ void ContentLibraryUserModel::load3DBundle() m_bundlePath3D.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()) { QByteArray jsonContent = "{\n"; jsonContent += " \"id\": \"User3D\",\n"; @@ -487,7 +488,7 @@ void ContentLibraryUserModel::load3DBundle() QJsonDocument bundleJsonDoc = QJsonDocument::fromJson(jsonContents.value()); if (bundleJsonDoc.isNull()) { - qWarning() << __FUNCTION__ << "Invalid user_3d_bundle.json file"; + qWarning() << __FUNCTION__ << "Invalid json file" << jsonFilePath; emit dataChanged(index(Items3DSectionIdx), index(Items3DSectionIdx)); return; } diff --git a/src/plugins/qmldesigner/components/contentlibrary/contentlibraryview.cpp b/src/plugins/qmldesigner/components/contentlibrary/contentlibraryview.cpp index 1287e246d13..9258faaf33c 100644 --- a/src/plugins/qmldesigner/components/contentlibrary/contentlibraryview.cpp +++ b/src/plugins/qmldesigner/components/contentlibrary/contentlibraryview.cpp @@ -535,7 +535,7 @@ void ContentLibraryView::addLibMaterial(const ModelNode &node, const QPixmap &ic itemsArr.append(itemObj); jsonRef["items"] = itemsArr; - auto result = bundlePath.pathAppended("user_materials_bundle.json") + auto result = bundlePath.pathAppended(Constants::BUNDLE_JSON_FILENAME) .writeFileContents(QJsonDocument(jsonRef).toJson()); if (!result) qWarning() << __FUNCTION__ << result.error(); @@ -731,7 +731,7 @@ void ContentLibraryView::addLib3DComponent(const ModelNode &node) jsonRef["items"] = itemsArr; - auto result = bundlePath.pathAppended("user_3d_bundle.json") + auto result = bundlePath.pathAppended(Constants::BUNDLE_JSON_FILENAME) .writeFileContents(QJsonDocument(jsonRef).toJson()); if (!result) qWarning() << __FUNCTION__ << result.error(); @@ -771,7 +771,7 @@ void ContentLibraryView::addLib3DItem(const ModelNode &node) jsonRef["items"] = itemsArr; - auto result = bundlePath.pathAppended("user_3d_bundle.json") + auto result = bundlePath.pathAppended(Constants::BUNDLE_JSON_FILENAME) .writeFileContents(QJsonDocument(jsonRef).toJson()); if (!result) qWarning() << __FUNCTION__ << result.error(); diff --git a/src/plugins/qmldesigner/qmldesignerconstants.h b/src/plugins/qmldesigner/qmldesignerconstants.h index c0d69bef656..28f3ed6097b 100644 --- a/src/plugins/qmldesigner/qmldesignerconstants.h +++ b/src/plugins/qmldesigner/qmldesignerconstants.h @@ -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 QML_DESIGNER_SUBFOLDER[] = "/designer/"; +inline constexpr char BUNDLE_JSON_FILENAME[] = "bundle.json"; 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";