forked from qt-creator/qt-creator
QmlDesigner: Don't override existing content lib user textures
Better solution to ask for overriding or not is for the future. Fixes: QDS-12626 Change-Id: Ib147121d3b9cb783f45a79a96fa432d371750a0e Reviewed-by: Qt CI Patch Build Bot <ci_patchbuild_bot@qt.io> Reviewed-by: Miikka Heikkinen <miikka.heikkinen@qt.io>
This commit is contained in:
@@ -631,19 +631,28 @@ void ContentLibraryView::addLibAssets(const QStringList &paths)
|
||||
auto bundlePath = Utils::FilePath::fromString(Paths::bundlesPathSetting() + "/User/textures");
|
||||
QStringList pathsInBundle;
|
||||
|
||||
const QStringList existingTextures = Utils::transform(bundlePath.dirEntries(QDir::Files),
|
||||
[](const Utils::FilePath &path) {
|
||||
return path.fileName();
|
||||
});
|
||||
|
||||
for (const QString &path : paths) {
|
||||
auto assetFilePath = Utils::FilePath::fromString(path);
|
||||
if (existingTextures.contains(assetFilePath.fileName()))
|
||||
continue;
|
||||
|
||||
Asset asset(path);
|
||||
auto assetPath = Utils::FilePath::fromString(path);
|
||||
|
||||
// save icon
|
||||
QString iconSavePath = bundlePath.pathAppended("icons/" + assetPath.baseName() + ".png").toString();
|
||||
QString iconSavePath = bundlePath.pathAppended("icons/" + assetFilePath.baseName() + ".png")
|
||||
.toString();
|
||||
QPixmap icon = asset.pixmap({120, 120});
|
||||
bool iconSaved = icon.save(iconSavePath);
|
||||
if (!iconSaved)
|
||||
qWarning() << __FUNCTION__ << "icon save failed";
|
||||
|
||||
// save asset
|
||||
auto result = assetPath.copyFile(bundlePath.pathAppended(asset.fileName()));
|
||||
auto result = assetFilePath.copyFile(bundlePath.pathAppended(asset.fileName()));
|
||||
if (!result)
|
||||
qWarning() << __FUNCTION__ << result.error();
|
||||
|
||||
|
Reference in New Issue
Block a user