Skip to content

Commit

Permalink
Merge pull request #2842 from thodkatz/save-as-refresh-recent-projects
Browse files Browse the repository at this point in the history
Update open recent project list when saving as a project

fixes #2830
  • Loading branch information
k-dominik committed Apr 16, 2024
2 parents 51aaf78 + af4c603 commit 6893110
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions ilastik/shell/gui/ilastikShell.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)))


# ===----------------------------------------------------------------------------------------------------------------===
Expand Down Expand Up @@ -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"))
Expand All @@ -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()
Expand Down Expand Up @@ -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()
Expand Down

0 comments on commit 6893110

Please sign in to comment.