@@ -571,10 +571,7 @@ QString ProjectFileDialog::getExistingDirectory(const QString &caption, bool tra
571571
572572 // Check if the path is relative to project file's path and if so
573573 // make it a relative path instead of absolute path.
574- const QDir dir (projectPath);
575- const QString relpath (dir.relativeFilePath (selectedDir));
576- if (!relpath.startsWith (" ../.." ))
577- selectedDir = relpath;
574+ selectedDir = mProjectFile ->getRelativePath (selectedDir);
578575
579576 // Trailing slash..
580577 if (trailingSlash && !selectedDir.endsWith (' /' ))
@@ -631,7 +628,7 @@ void ProjectFileDialog::browseImportProject()
631628 dir.canonicalPath (),
632629 toFilterString (filters));
633630 if (!fileName.isEmpty ()) {
634- mUI ->mEditImportProject ->setText (dir. relativeFilePath (fileName));
631+ mUI ->mEditImportProject ->setText (mProjectFile -> getRelativePath (fileName));
635632 updatePathsAndDefines ();
636633 setProjectConfigurations (getProjectConfigs (fileName));
637634 for (int row = 0 ; row < mUI ->mListVsConfigs ->count (); ++row) {
@@ -652,7 +649,7 @@ void ProjectFileDialog::browseUserInclude()
652649 dir.canonicalPath (),
653650 toFilterString (filters));
654651 if (!fileName.isEmpty ()) {
655- mUI ->mEditUserInclude ->setText (dir. relativeFilePath (fileName));
652+ mUI ->mEditUserInclude ->setText (mProjectFile -> getRelativePath (fileName));
656653 }
657654}
658655
@@ -891,7 +888,9 @@ void ProjectFileDialog::addExcludeFile()
891888 QMap<QString,QString> filters;
892889 filters[tr (" Source files" )] = " *.c *.cpp" ;
893890 filters[tr (" All files" )] = " *.*" ;
894- addExcludePath (QFileDialog::getOpenFileName (this , tr (" Exclude file" ), dir.canonicalPath (), toFilterString (filters)));
891+ QString fileName = QFileDialog::getOpenFileName (this , tr (" Exclude file" ), dir.canonicalPath (), toFilterString (filters));
892+ if (!fileName.isEmpty ())
893+ addExcludePath (mProjectFile ->getRelativePath (fileName));
895894}
896895
897896void ProjectFileDialog::editExcludePath ()
0 commit comments