The recent projects menu now properly repopulates after the order of recent items have changed

This commit is contained in:
Veronica K. B. Olsen
2019-05-03 22:44:41 +02:00
parent 574a4bd63c
commit 7092e20e9c
2 changed files with 14 additions and 7 deletions
+12 -7
View File
@@ -60,6 +60,16 @@ class GuiMainMenu(QMenuBar):
) )
return return
def updateRecentProjects(self):
self.recentMenu.clear()
for n in range(len(self.mainConf.recentList)):
recentProject = self.mainConf.recentList[n]
if recentProject == "": continue
menuItem = QAction(QIcon.fromTheme("folder-open"), "%d: %s" % (n,recentProject), self.projMenu)
menuItem.triggered.connect(lambda menuItem, n=n : self.openRecentProject(menuItem, n))
self.recentMenu.addAction(menuItem)
return
## ##
# Menu Action # Menu Action
## ##
@@ -103,13 +113,8 @@ class GuiMainMenu(QMenuBar):
self.projMenu.addAction(menuItem) self.projMenu.addAction(menuItem)
# Project > Recent Projects # Project > Recent Projects
recentMenu = self.projMenu.addMenu(QIcon.fromTheme("document-open-recent"),"Recent Projects") self.recentMenu = self.projMenu.addMenu(QIcon.fromTheme("document-open-recent"),"Recent Projects")
for n in range(len(self.mainConf.recentList)): self.updateRecentProjects()
recentProject = self.mainConf.recentList[n]
if recentProject == "": continue
menuItem = QAction(QIcon.fromTheme("folder-open"), "%d: %s" % (n,recentProject), self.projMenu)
menuItem.triggered.connect(lambda menuItem, n=n : self.openRecentProject(menuItem, n))
recentMenu.addAction(menuItem)
# Project > Project Settings # Project > Project Settings
menuItem = QAction(QIcon.fromTheme("document-properties"), "Project Settings", self) menuItem = QAction(QIcon.fromTheme("document-properties"), "Project Settings", self)
+2
View File
@@ -116,6 +116,7 @@ class GuiMain(QMainWindow):
self.treeView.clearTree() self.treeView.clearTree()
self.theProject.openProject(projFile) self.theProject.openProject(projFile)
self.treeView.buildTree() self.treeView.buildTree()
self.mainMenu.updateRecentProjects()
self._setWindowTitle(self.theProject.projName) self._setWindowTitle(self.theProject.projName)
return True return True
@@ -125,6 +126,7 @@ class GuiMain(QMainWindow):
self.theProject.setProjectPath(projPath) self.theProject.setProjectPath(projPath)
self.treeView.saveTreeOrder() self.treeView.saveTreeOrder()
self.theProject.saveProject() self.theProject.saveProject()
self.mainMenu.updateRecentProjects()
return True return True
## ##