aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMiikka Heikkinen <[email protected]>2025-10-10 13:44:12 +0300
committerTim Jenssen <[email protected]>2025-10-10 11:22:12 +0000
commitbbf8496412929f75a7e02940ba44ae498d4e4348 (patch)
tree26e3172c93a8fdc417f33dde71ffbf58272aa869
parent740d12d178d9b4662066d134a05af5f6389b9e66 (diff)
QmlDesigner: Save texture bundle versions in different directoriesqds/4.8.0
If user goes back and forth between two version of QDS that use different texture bundle versions, it becomes a nightmare to try to manage that if all texture bundle versions are stored in same location. With separate directory based on bundle version, bundle maintenance becomes trivial. Fixes: QDS-15948 Change-Id: I208b8ee279413fb42c6967c594df7a60a98c8ac5 Reviewed-by: Mahmoud Badri <[email protected]> (cherry picked from commit 81530dc1d7163d90ad8de1db24246380c6f71a91) Reviewed-by: Tim Jenssen <[email protected]>
-rw-r--r--src/plugins/qmldesigner/components/contentlibrary/contentlibrarytexturesmodel.cpp13
-rw-r--r--src/plugins/qmldesigner/components/contentlibrary/contentlibrarytexturesmodel.h5
-rw-r--r--src/plugins/qmldesigner/components/contentlibrary/contentlibrarywidget.cpp18
-rw-r--r--src/plugins/qmldesigner/components/contentlibrary/contentlibrarywidget.h2
4 files changed, 21 insertions, 17 deletions
diff --git a/src/plugins/qmldesigner/components/contentlibrary/contentlibrarytexturesmodel.cpp b/src/plugins/qmldesigner/components/contentlibrary/contentlibrarytexturesmodel.cpp
index fb86730906c..a5594c4660a 100644
--- a/src/plugins/qmldesigner/components/contentlibrary/contentlibrarytexturesmodel.cpp
+++ b/src/plugins/qmldesigner/components/contentlibrary/contentlibrarytexturesmodel.cpp
@@ -96,22 +96,23 @@ QHash<int, QByteArray> ContentLibraryTexturesModel::roleNames() const
* @brief Load the bundle categorized icons. Actual textures are downloaded on demand
*
* @param textureBundleUrl remote url to the texture bundle
- * @param bundleIconPath local path to the texture bundle icons folder
+ * @param textureBundleIconPath local path to the texture bundle icons folder
* @param jsonData bundle textures information from the bundle json
*/
void ContentLibraryTexturesModel::loadTextureBundle(const QString &textureBundleUrl,
- const QString &bundleIconPath,
+ const QString &textureBundlePath,
+ const QString &textureBundleIconPath,
const QVariantMap &jsonData)
{
if (!m_bundleCategories.isEmpty())
return;
- QDir bundleDir = QString("%1/%2").arg(bundleIconPath, textureCategory);
- QTC_ASSERT(bundleDir.exists(), return);
+ QDir bundleIconDir = QString("%1/%2").arg(textureBundleIconPath, textureCategory);
+ QTC_ASSERT(bundleIconDir.exists(), return);
const QVariantMap imageItems = jsonData.value("image_items").toMap();
- const QFileInfoList dirs = bundleDir.entryInfoList(QDir::Files | QDir::Dirs | QDir::NoDotAndDotDot);
+ const QFileInfoList dirs = bundleIconDir.entryInfoList(QDir::Files | QDir::Dirs | QDir::NoDotAndDotDot);
for (const QFileInfo &dir : dirs) {
auto category = new ContentLibraryTexturesCategory(this, dir.fileName());
const QFileInfoList texIconFiles = QDir(dir.filePath()).entryInfoList(QDir::Files);
@@ -128,7 +129,7 @@ void ContentLibraryTexturesModel::loadTextureBundle(const QString &textureBundle
texIcon.baseName());
QString texturePath = QString("%1/%2/%3")
- .arg(Paths::bundlesPathSetting(),
+ .arg(textureBundlePath,
textureCategory,
dir.fileName());
QString key = QString("%1/%2/%3").arg(textureCategory, dir.fileName(), texIcon.baseName());
diff --git a/src/plugins/qmldesigner/components/contentlibrary/contentlibrarytexturesmodel.h b/src/plugins/qmldesigner/components/contentlibrary/contentlibrarytexturesmodel.h
index dc60adcfd4c..775c3a0e6bf 100644
--- a/src/plugins/qmldesigner/components/contentlibrary/contentlibrarytexturesmodel.h
+++ b/src/plugins/qmldesigner/components/contentlibrary/contentlibrarytexturesmodel.h
@@ -37,8 +37,9 @@ public:
void setHasSceneEnv(bool b);
void resetModel();
- void loadTextureBundle(const QString &textureBundleUrl, const QString &bundlePath,
- const QVariantMap &metaData);
+ void loadTextureBundle(const QString &textureBundleUrl, const QString &textureBundlePath,
+ const QString &textureBundleIconPath, const QVariantMap &metaData);
+
signals:
void isEmptyChanged();
diff --git a/src/plugins/qmldesigner/components/contentlibrary/contentlibrarywidget.cpp b/src/plugins/qmldesigner/components/contentlibrary/contentlibrarywidget.cpp
index a50a735807d..ac68ef75452 100644
--- a/src/plugins/qmldesigner/components/contentlibrary/contentlibrarywidget.cpp
+++ b/src/plugins/qmldesigner/components/contentlibrary/contentlibrarywidget.cpp
@@ -168,7 +168,8 @@ ContentLibraryWidget::ContentLibraryWidget(const GeneratedComponentUtils &compUt
.toString()
+ "/textures/" + QByteArray::number(TextureBundleMetadataVersion);
- m_bundlePath = Paths::bundlesPathSetting();
+ m_textureBundlePath = QString("%1/Textures_v%2").arg(Paths::bundlesPathSetting())
+ .arg(TextureBundleMetadataVersion);
loadTextureBundles();
@@ -280,7 +281,7 @@ BundleImporter *ContentLibraryWidget::importer() const
QVariantMap ContentLibraryWidget::readTextureBundleJson()
{
QVariantMap jsonData;
- QFile jsonFile(m_bundlePath + "/texture_bundle.json");
+ QFile jsonFile(m_textureBundlePath + "/texture_bundle.json");
if (jsonFile.open(QIODevice::ReadOnly | QIODevice::Text))
jsonData = QJsonDocument::fromJson(jsonFile.readAll()).toVariant().toMap();
@@ -295,7 +296,7 @@ QVariantMap ContentLibraryWidget::readTextureBundleJson()
void ContentLibraryWidget::loadTextureBundles()
{
- QDir bundleDir{m_bundlePath};
+ QDir bundleDir{m_textureBundlePath};
if (fetchTextureBundleJson(bundleDir) && fetchTextureBundleIcons(bundleDir))
populateTextureBundleModels();
@@ -364,7 +365,7 @@ void ContentLibraryWidget::fetchNewTextureIcons(const QVariantMap &existingFiles
auto multidownloader = new MultiFileDownloader(this);
multidownloader->setBaseUrl(QString(m_textureBundleUrl + "/icons"));
multidownloader->setFiles(fileList);
- multidownloader->setTargetDirPath(m_bundlePath + "/TextureBundleIcons");
+ multidownloader->setTargetDirPath(m_textureBundlePath + "/TextureBundleIcons");
auto downloader = new FileDownloader(this);
downloader->setDownloadEnabled(true);
@@ -585,9 +586,10 @@ void ContentLibraryWidget::populateTextureBundleModels()
{
QVariantMap jsonData = readTextureBundleJson();
- QString bundleIconPath = m_bundlePath + "/TextureBundleIcons";
+ QString bundleIconPath = m_textureBundlePath + "/TextureBundleIcons";
- m_texturesModel->loadTextureBundle(m_textureBundleUrl, bundleIconPath, jsonData);
+ m_texturesModel->loadTextureBundle(m_textureBundleUrl, m_textureBundlePath,
+ bundleIconPath, jsonData);
}
bool ContentLibraryWidget::fetchTextureBundleIcons(const QDir &bundleDir)
@@ -639,7 +641,7 @@ void ContentLibraryWidget::markTextureUpdated(const QString &textureKey)
checksumOnServer = m_texturesModel->removeModifiedFileEntry(textureKey);
QJsonObject metaDataObj;
- QFile jsonFile(m_bundlePath + "/texture_bundle.json");
+ QFile jsonFile(m_textureBundlePath + "/texture_bundle.json");
if (jsonFile.open(QIODevice::ReadOnly | QIODevice::Text)) {
metaDataObj = QJsonDocument::fromJson(jsonFile.readAll()).object();
jsonFile.close();
@@ -656,7 +658,7 @@ void ContentLibraryWidget::markTextureUpdated(const QString &textureKey)
QJsonDocument outDoc(metaDataObj);
QByteArray data = outDoc.toJson();
- QFile outFile(m_bundlePath + "/texture_bundle.json");
+ QFile outFile(m_textureBundlePath + "/texture_bundle.json");
if (outFile.open(QIODeviceBase::WriteOnly | QIODeviceBase::Text)) {
outFile.write(data);
outFile.flush();
diff --git a/src/plugins/qmldesigner/components/contentlibrary/contentlibrarywidget.h b/src/plugins/qmldesigner/components/contentlibrary/contentlibrarywidget.h
index 596df1f4c48..7e0c76bb807 100644
--- a/src/plugins/qmldesigner/components/contentlibrary/contentlibrarywidget.h
+++ b/src/plugins/qmldesigner/components/contentlibrary/contentlibrarywidget.h
@@ -190,7 +190,7 @@ private:
bool m_importerRunning = false;
bool m_hasModelSelection = false;
QString m_textureBundleUrl;
- QString m_bundlePath;
+ QString m_textureBundlePath;
QString m_showInGraphicalShellMsg;
const GeneratedComponentUtils &m_compUtils;