summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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;
}