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");
|
auto bundlePath = Utils::FilePath::fromString(Paths::bundlesPathSetting() + "/User/textures");
|
||||||
QStringList pathsInBundle;
|
QStringList pathsInBundle;
|
||||||
|
|
||||||
|
const QStringList existingTextures = Utils::transform(bundlePath.dirEntries(QDir::Files),
|
||||||
|
[](const Utils::FilePath &path) {
|
||||||
|
return path.fileName();
|
||||||
|
});
|
||||||
|
|
||||||
for (const QString &path : paths) {
|
for (const QString &path : paths) {
|
||||||
|
auto assetFilePath = Utils::FilePath::fromString(path);
|
||||||
|
if (existingTextures.contains(assetFilePath.fileName()))
|
||||||
|
continue;
|
||||||
|
|
||||||
Asset asset(path);
|
Asset asset(path);
|
||||||
auto assetPath = Utils::FilePath::fromString(path);
|
|
||||||
|
|
||||||
// save icon
|
// 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});
|
QPixmap icon = asset.pixmap({120, 120});
|
||||||
bool iconSaved = icon.save(iconSavePath);
|
bool iconSaved = icon.save(iconSavePath);
|
||||||
if (!iconSaved)
|
if (!iconSaved)
|
||||||
qWarning() << __FUNCTION__ << "icon save failed";
|
qWarning() << __FUNCTION__ << "icon save failed";
|
||||||
|
|
||||||
// save asset
|
// save asset
|
||||||
auto result = assetPath.copyFile(bundlePath.pathAppended(asset.fileName()));
|
auto result = assetFilePath.copyFile(bundlePath.pathAppended(asset.fileName()));
|
||||||
if (!result)
|
if (!result)
|
||||||
qWarning() << __FUNCTION__ << result.error();
|
qWarning() << __FUNCTION__ << result.error();
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user