code: def onFolderTreeClicked(self, proxyIndex):
          
          if not proxyIndex.isValid():
              return
  
          index = self.proxyFileModel.mapToSource(proxyIndex)
          settings = QSettings()
          folder_path = self.fileModel.filePath(index)
          settings.setValue('mainwindow/workingDirectory', folder_path)
docs: What to do when a Folder in the tree is clicked