Remember new project folder last used path (#1930)
This commit is contained in:
@@ -919,15 +919,15 @@ class RecentPaths:
|
|||||||
def loadCache(self) -> bool:
|
def loadCache(self) -> bool:
|
||||||
"""Load the cache file for recent projects."""
|
"""Load the cache file for recent projects."""
|
||||||
self._data = {}
|
self._data = {}
|
||||||
|
|
||||||
cacheFile = self._conf.dataPath(nwFiles.RECENT_PATH)
|
cacheFile = self._conf.dataPath(nwFiles.RECENT_PATH)
|
||||||
if cacheFile.is_file():
|
if cacheFile.is_file():
|
||||||
try:
|
try:
|
||||||
with open(cacheFile, mode="r", encoding="utf-8") as inFile:
|
with open(cacheFile, mode="r", encoding="utf-8") as inFile:
|
||||||
data = json.load(inFile)
|
data = json.load(inFile)
|
||||||
for key, path in data.items():
|
if isinstance(data, dict):
|
||||||
if isinstance(path, str) and key in self.KEYS:
|
for key, path in data.items():
|
||||||
data[key] = path
|
if key in self.KEYS and isinstance(path, str):
|
||||||
|
self._data[key] = path
|
||||||
except Exception:
|
except Exception:
|
||||||
logger.error("Could not load recent paths cache")
|
logger.error("Could not load recent paths cache")
|
||||||
logException()
|
logException()
|
||||||
|
|||||||
@@ -221,7 +221,6 @@ class GuiWelcome(NDialog):
|
|||||||
def _browseForProject(self) -> None:
|
def _browseForProject(self) -> None:
|
||||||
"""Browse for a project to open."""
|
"""Browse for a project to open."""
|
||||||
if path := SHARED.getProjectPath(self, path=CONFIG.lastPath("project"), allowZip=False):
|
if path := SHARED.getProjectPath(self, path=CONFIG.lastPath("project"), allowZip=False):
|
||||||
CONFIG.setLastPath("project", path)
|
|
||||||
self._openProjectPath(path)
|
self._openProjectPath(path)
|
||||||
return
|
return
|
||||||
|
|
||||||
@@ -550,7 +549,7 @@ class _NewProjectForm(QWidget):
|
|||||||
def __init__(self, parent: QWidget) -> None:
|
def __init__(self, parent: QWidget) -> None:
|
||||||
super().__init__(parent=parent)
|
super().__init__(parent=parent)
|
||||||
|
|
||||||
self._basePath = CONFIG.homePath()
|
self._basePath = CONFIG.lastPath("project")
|
||||||
self._fillMode = self.FILL_BLANK
|
self._fillMode = self.FILL_BLANK
|
||||||
self._copyPath = None
|
self._copyPath = None
|
||||||
|
|
||||||
@@ -726,12 +725,13 @@ class _NewProjectForm(QWidget):
|
|||||||
@pyqtSlot()
|
@pyqtSlot()
|
||||||
def _doBrowse(self) -> None:
|
def _doBrowse(self) -> None:
|
||||||
"""Select a project folder."""
|
"""Select a project folder."""
|
||||||
if projDir := QFileDialog.getExistingDirectory(
|
if path := QFileDialog.getExistingDirectory(
|
||||||
self, self.tr("Select Project Folder"),
|
self, self.tr("Select Project Folder"),
|
||||||
str(self._basePath), options=QFileDialog.Option.ShowDirsOnly
|
str(self._basePath), options=QFileDialog.Option.ShowDirsOnly
|
||||||
):
|
):
|
||||||
self._basePath = Path(projDir)
|
self._basePath = Path(path)
|
||||||
self._updateProjPath()
|
self._updateProjPath()
|
||||||
|
CONFIG.setLastPath("project", path)
|
||||||
return
|
return
|
||||||
|
|
||||||
@pyqtSlot()
|
@pyqtSlot()
|
||||||
|
|||||||
Reference in New Issue
Block a user