From 21f6cbe4e42116d20f52cf35150eb66d5cb29b72 Mon Sep 17 00:00:00 2001 From: Thomas Hartmann Date: Mon, 15 Apr 2024 17:06:17 +0200 Subject: [PATCH] QmlDesigner: Adjust paths for new project structure Before we used "content" but in the new project structure we will use "ProjectNameContent" to make the uri unique. First check for "content" to support older project. Keeping only the implementation in DocumentManager::currentResourcePath() Change-Id: Ib6b21f52c078fdb9a2ff31c02855754f83741538 Reviewed-by: Miikka Heikkinen --- .../components/componentcore/modelnodeoperations.cpp | 5 +---- src/plugins/qmldesigner/documentmanager.cpp | 7 +++++++ 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/plugins/qmldesigner/components/componentcore/modelnodeoperations.cpp b/src/plugins/qmldesigner/components/componentcore/modelnodeoperations.cpp index 8b41cfb6929..66c1229a76e 100644 --- a/src/plugins/qmldesigner/components/componentcore/modelnodeoperations.cpp +++ b/src/plugins/qmldesigner/components/componentcore/modelnodeoperations.cpp @@ -1138,10 +1138,7 @@ static QString getAssetDefaultDirectory(const QString &assetDir, const QString & { QString adjustedDefaultDirectory = defaultDirectory; - Utils::FilePath contentPath = QmlDesignerPlugin::instance()->documentManager().currentProjectDirPath(); - - if (contentPath.pathAppended("content").exists()) - contentPath = contentPath.pathAppended("content"); + Utils::FilePath contentPath = QmlDesignerPlugin::instance()->documentManager().currentResourcePath(); Utils::FilePath assetPath = contentPath.pathAppended(assetDir); diff --git a/src/plugins/qmldesigner/documentmanager.cpp b/src/plugins/qmldesigner/documentmanager.cpp index 6d4deb527aa..92d80680a94 100644 --- a/src/plugins/qmldesigner/documentmanager.cpp +++ b/src/plugins/qmldesigner/documentmanager.cpp @@ -544,6 +544,13 @@ Utils::FilePath DocumentManager::currentResourcePath() if (contentFilePath.exists()) return contentFilePath; + const auto project = ProjectManager::startupProject(); + const QString baseName = project->rootProjectDirectory().baseName() + "Content"; + + contentFilePath = resourcePath.pathAppended(baseName); + if (contentFilePath.exists()) + return contentFilePath; + return resourcePath; }