From af4c6038b016a4ad84a626cad7e2776ba6d8cab8 Mon Sep 17 00:00:00 2001 From: Theodoros Katzalis Date: Tue, 16 Apr 2024 02:10:03 +0300 Subject: [PATCH] Update open recent project list when saving as a project (#2830) --- ilastik/shell/gui/ilastikShell.py | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/ilastik/shell/gui/ilastikShell.py b/ilastik/shell/gui/ilastikShell.py index 1c8ecb9f8..e978af596 100644 --- a/ilastik/shell/gui/ilastikShell.py +++ b/ilastik/shell/gui/ilastikShell.py @@ -158,7 +158,7 @@ def cleanUp(self): self.setMemoryBytes(0) def setMemoryBytes(self, bytes): - self.label.setText("Cached Data: %1.1f MB" % (bytes / (1024.0 ** 2.0))) + self.label.setText("Cached Data: %1.1f MB" % (bytes / (1024.0**2.0))) # ===----------------------------------------------------------------------------------------------------------------=== @@ -1680,17 +1680,10 @@ def _loadProject(self, hdf5File, projectFilePath, workflow_class, readOnly, impo stop = time.perf_counter() logger.debug("Loading the project took {:.2f} sec.".format(stop - start)) - workflowName = self.projectManager.workflow.workflowName workflowDisplayName = self.projectManager.workflow.workflowDisplayName + self._setRecentlyOpenedList(projectFilePath, workflowDisplayName) - recentlyOpenedList = [(projectFilePath, workflowDisplayName)] + [ - (path, name) - for path, name in preferences.get("shell", "recently opened list", []) - if path != projectFilePath - ] - preferences.set("shell", "recently opened list", recentlyOpenedList[:5]) - preferences.set("shell", "recently opened", projectFilePath) - + workflowName = self.projectManager.workflow.workflowName # be friendly to user: if this file has not specified a default workflow, do it now if not "workflowName" in list(hdf5File.keys()) and not readOnly: hdf5File.create_dataset("workflowName", data=workflowName.encode("utf-8")) @@ -1715,6 +1708,15 @@ def _loadProject(self, hdf5File, projectFilePath, workflow_class, readOnly, impo else: self.setSelectedAppletDrawer(self.projectManager.workflow.defaultAppletIndex) + def _setRecentlyOpenedList(self, projectFilePath, workflowDisplayName): + recentlyOpenedList = [(projectFilePath, workflowDisplayName)] + [ + (path, name) + for path, name in preferences.get("shell", "recently opened list", []) + if path != projectFilePath + ] + preferences.set("shell", "recently opened list", recentlyOpenedList[:5]) + preferences.set("shell", "recently opened", projectFilePath) + def closeCurrentProject(self): """ Undo everything that was done in loadProject() @@ -1832,6 +1834,8 @@ def saveAs(): try: self.projectManager.saveProjectAs(newPath) + workflowDisplayName = self.projectManager.workflow.workflowDisplayName + self._setRecentlyOpenedList(newPath, workflowDisplayName) except ProjectManager.SaveError as err: self.thunkEventHandler.post(partial(QMessageBox.warning, self, "Error Attempting Save", str(err))) self.updateShellProjectDisplay()