forked from qt-creator/qt-creator
QmlDesigner: Fix project path inside imported subcomponent
When user goes inside a Qml that is part of an imported component, project path is not accessible. This commit fixes it. Fixes: QDS-6201 Change-Id: I4efff48399e487b586b10383f19c2d6877714dc9 Reviewed-by: Miikka Heikkinen <miikka.heikkinen@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
This commit is contained in:
@@ -989,15 +989,6 @@ void addTabBarToStackedContainer(const SelectionContext &selectionContext)
|
||||
|
||||
}
|
||||
|
||||
Utils::FilePath projectFilePath()
|
||||
{
|
||||
if (auto *doc = QmlDesignerPlugin::instance()->documentManager().currentDesignDocument()) {
|
||||
if (auto *proj = ProjectExplorer::SessionManager::projectForFile(doc->fileName()))
|
||||
return proj->projectDirectory();
|
||||
}
|
||||
return Utils::FilePath();
|
||||
}
|
||||
|
||||
static AddFilesResult addFilesToProject(const QStringList &fileNames, const QString &defaultDirectory)
|
||||
{
|
||||
QString directory = AddImagesDialog::getDirectory(fileNames, defaultDirectory);
|
||||
@@ -1050,10 +1041,10 @@ static QString getAssetDefaultDirectory(const QString &assetDir, const QString &
|
||||
{
|
||||
QString adjustedDefaultDirectory = defaultDirectory;
|
||||
|
||||
Utils::FilePath contentPath = projectFilePath();
|
||||
Utils::FilePath contentPath = QmlDesignerPlugin::instance()->documentManager().currentProjectDirPath();
|
||||
|
||||
if (contentPath.pathAppended("content").exists())
|
||||
contentPath = contentPath.pathAppended("content");
|
||||
contentPath = contentPath.pathAppended("content");
|
||||
|
||||
Utils::FilePath assetPath = contentPath.pathAppended(assetDir);
|
||||
|
||||
|
@@ -344,7 +344,7 @@ Utils::FilePath DesignDocument::projectFolder() const
|
||||
|
||||
bool DesignDocument::hasProject() const
|
||||
{
|
||||
return ProjectExplorer::SessionManager::projectForFile(fileName());
|
||||
return !DocumentManager::currentProjectDirPath().isEmpty();
|
||||
}
|
||||
|
||||
void DesignDocument::changeToInFileComponentModel(ComponentTextModifier *textModifer)
|
||||
|
@@ -358,11 +358,18 @@ Utils::FilePath DocumentManager::currentProjectDirPath()
|
||||
return {};
|
||||
|
||||
Utils::FilePath qmlFileName = QmlDesignerPlugin::instance()->currentDesignDocument()->fileName();
|
||||
ProjectExplorer::Project *project = ProjectExplorer::SessionManager::projectForFile(qmlFileName);
|
||||
if (!project)
|
||||
return {};
|
||||
|
||||
return project->projectDirectory();
|
||||
ProjectExplorer::Project *project = ProjectExplorer::SessionManager::projectForFile(qmlFileName);
|
||||
if (project)
|
||||
return project->projectDirectory();
|
||||
|
||||
const QList projects = ProjectExplorer::SessionManager::projects();
|
||||
for (auto p : projects) {
|
||||
if (qmlFileName.startsWith(p->projectDirectory().toString()))
|
||||
return p->projectDirectory();
|
||||
}
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
QStringList DocumentManager::isoIconsQmakeVariableValue(const QString &proPath)
|
||||
|
Reference in New Issue
Block a user