def onMapsDirectoryChanged(self): prefs = preferences.Preferences.instance() mapsDir = QDir(prefs.mapsDirectory()) if (not mapsDir.exists()): mapsDir.setPath(QDir.currentPath()) self.model().setRootPath(mapsDir.canonicalPath()) self.setRootIndex(self.model().index(mapsDir.absolutePath()))
def get_cwd(): """Get the current working directory (default for file open and save-as)""" settings = QSettings() cwd = QDir(settings.value(Settings.CWD, defaultValue=Settings.CWD_DFLT)) if not cwd.exists(): cwd = QDir(str(Path.home())) return cwd.canonicalPath() # resolve symlinks and relative paths
def on_btnDir_canonPath_clicked(self): self.__showBtnInfo(self.sender()) sous = self.ui.editDir.text() if sous == "": self.ui.textEdit.appendPlainText("请先选择一个目录") return dirObj = QDir(sous) text = dirObj.canonicalPath() self.ui.textEdit.appendPlainText(text + "\n")
def set_cwd(new_value): """Set the current working directory (default for file open and save-as)""" cwd = QDir(new_value) if cwd.exists(): settings = QSettings() settings.setValue(Settings.CWD, cwd.canonicalPath()) # resolve symlinks and relative paths