fixed the function for different kinds of paths

master
Jaka Perovšek 2024-09-28 00:59:19 +02:00
parent a40fd85822
commit cc94838ad3
1 changed files with 9 additions and 2 deletions

View File

@ -169,8 +169,15 @@ class DirWidget(QWidget):
def set_dir(self):
directory = QFileDialog.getExistingDirectory(self, "Select a directory.", dir=self.directory)
if directory:
directory = Path(directory).relative_to(Path.cwd()).as_posix()
self.directory = "./" + directory
directory = Path(directory)
if Path.cwd() in directory.parents:
self.directory = "./" + directory.relative_to(Path.cwd()).as_posix()
elif Path.cwd() == directory:
self.directory = "."
else:
self.directory = directory.as_posix()
self.dir_lineedit.setText(self.directory)