summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJere Tuliniemi <jere.tuliniemi@qt.io>2020-05-12 00:37:30 +0300
committerJere Tuliniemi <jere.tuliniemi@qt.io>2020-05-14 08:15:53 +0300
commit93157f5693d0b94c20e5e8b9bfdb1048491aa292 (patch)
treec77e86c7ba6c3d4d348b19e8c3f894fbd8f75f68
parentf2023aa4b95bf4fd954b0b8ec00bc5fd395602ac (diff)
Save relative instead of absolute paths to materialdefsv2.7.0-rc2
Task-number: QT3DS-4089 Change-Id: Ib880bc2da4a5b7e77efa96114ca283410240afb5 Reviewed-by: Antti Määttä <antti.maatta@qt.io> Reviewed-by: Miikka Heikkinen <miikka.heikkinen@qt.io>
-rw-r--r--src/Authoring/Client/Code/Core/Doc/DocumentEditor.cpp3
-rw-r--r--src/Authoring/Qt3DStudio/Palettes/Inspector/InspectorControlModel.cpp20
2 files changed, 16 insertions, 7 deletions
diff --git a/src/Authoring/Client/Code/Core/Doc/DocumentEditor.cpp b/src/Authoring/Client/Code/Core/Doc/DocumentEditor.cpp
index 8f053a47..202736d8 100644
--- a/src/Authoring/Client/Code/Core/Doc/DocumentEditor.cpp
+++ b/src/Authoring/Client/Code/Core/Doc/DocumentEditor.cpp
@@ -2156,7 +2156,8 @@ public:
}
const QFileInfo fileInfo(file);
- writeProperty(file, QStringLiteral("path"), fileInfo.absoluteFilePath());
+ writeProperty(file, QStringLiteral("path"),
+ projDir.relativeFilePath(fileInfo.absoluteFilePath()));
QMapIterator<QString, Qt3DSDMInstanceHandle> i(textureHandles);
while (i.hasNext()) {
diff --git a/src/Authoring/Qt3DStudio/Palettes/Inspector/InspectorControlModel.cpp b/src/Authoring/Qt3DStudio/Palettes/Inspector/InspectorControlModel.cpp
index aaeb7a89..5f72bdf0 100644
--- a/src/Authoring/Qt3DStudio/Palettes/Inspector/InspectorControlModel.cpp
+++ b/src/Authoring/Qt3DStudio/Palettes/Inspector/InspectorControlModel.cpp
@@ -447,6 +447,7 @@ void InspectorControlModel::setMatDatas(const std::vector<Q3DStudio::CFilePath>
m_matDatas.clear();
const auto doc = g_StudioApp.GetCore()->GetDoc();
+ bool forceModified = false;
bool isDocModified = doc->isModified();
const auto sceneEditor = doc->getSceneEditor();
if (!sceneEditor)
@@ -465,6 +466,8 @@ void InspectorControlModel::setMatDatas(const std::vector<Q3DStudio::CFilePath>
const QString relativePath = path.toQString();
const Q3DStudio::CFilePath absolutePath
= Q3DStudio::CFilePath::CombineBaseAndRelative(doc->GetDocumentDirectory(), path);
+ const QDir projDir = QDir(g_StudioApp.GetCore()->getProjectFile().getProjectPath());
+ const QString projRelativePath = projDir.relativeFilePath(absolutePath.toQString());
QString name;
QMap<QString, QString> values;
@@ -477,19 +480,21 @@ void InspectorControlModel::setMatDatas(const std::vector<Q3DStudio::CFilePath>
bool needRewrite = false;
if (values.contains(QStringLiteral("path"))) {
const QString oldPath = values[QStringLiteral("path")];
- needRewrite = oldPath != absolutePath.toQString();
- if (!QFileInfo(oldPath).exists()) {
+ needRewrite = oldPath != projRelativePath;
+ const QString oldAbsolutePath = projDir.absoluteFilePath(oldPath);
+ if (!QFileInfo(oldAbsolutePath).exists()) {
const auto instance = sceneEditor->getMaterial(oldPath);
if (instance.Valid()) {
const QString oldName = sceneEditor->GetName(instance).toQString();
const QString newName = sceneEditor
- ->getMaterialNameFromFilePath(relativePath);
+ ->getMaterialNameFromFilePath(projRelativePath);
const QString actualPath = sceneEditor
->getFilePathFromMaterialName(oldName);
- if (actualPath == oldPath) {
+ if (projDir.relativeFilePath(actualPath) == oldPath) {
doc->queueMaterialRename(oldName, newName);
Q3DStudio::SCOPED_DOCUMENT_EDITOR(*doc, tr("Set Name"))
- ->setMaterialNameByPath(instance, relativePath);
+ ->setMaterialNameByPath(instance, projRelativePath);
+ forceModified = true;
}
}
}
@@ -526,7 +531,10 @@ void InspectorControlModel::setMatDatas(const std::vector<Q3DStudio::CFilePath>
sceneEditor->removeDeletedFromMaterialContainer();
// Modified flag has to be restored because of the hidden transaction
- doc->SetModifiedFlag(isDocModified);
+ if (!forceModified)
+ doc->SetModifiedFlag(isDocModified);
+ else
+ doc->SetModifiedFlag(true);
m_cachedMatDatas = matDatas;
}