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 <miikka.heikkinen@qt.io>
This commit is contained in:
Thomas Hartmann
2024-04-15 17:06:17 +02:00
parent 3c13cf9493
commit 21f6cbe4e4
2 changed files with 8 additions and 4 deletions

View File

@@ -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);

View File

@@ -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;
}