From 14bd0f4598f1dfb4f4ac0db9f4bef106c45c484b Mon Sep 17 00:00:00 2001 From: "Veronica K. B. Olsen" <1619840+vkbo@users.noreply.github.com> Date: Wed, 30 Oct 2019 15:55:17 +0100 Subject: [PATCH] Added the option to clear the recent projects menu entry --- nw/config.py | 4 ++++ nw/gui/mainmenu.py | 13 +++++++++++++ 2 files changed, 17 insertions(+) diff --git a/nw/config.py b/nw/config.py index c7f4ab52..18f2bc8e 100644 --- a/nw/config.py +++ b/nw/config.py @@ -340,6 +340,10 @@ class Config: self.recentList.insert(0,recentPath) return + def clearRecent(self): + self.recentList = [""]*10 + return + def setConfPath(self, newPath): if newPath is None: return True diff --git a/nw/gui/mainmenu.py b/nw/gui/mainmenu.py index e2f5775d..7a42f6cf 100644 --- a/nw/gui/mainmenu.py +++ b/nw/gui/mainmenu.py @@ -72,6 +72,7 @@ class GuiMainMenu(QMenuBar): return def updateRecentProjects(self): + self.recentMenu.clear() for n in range(len(self.mainConf.recentList)): recentProject = self.mainConf.recentList[n] @@ -79,6 +80,13 @@ class GuiMainMenu(QMenuBar): menuItem = QAction("%s" % recentProject, self.projMenu) menuItem.triggered.connect(lambda menuItem, n=n : self.openRecentProject(menuItem, n)) self.recentMenu.addAction(menuItem) + + self.recentMenu.addSeparator() + menuItem = QAction("Clear Recent Projects", self) + menuItem.setStatusTip("Clear the list of recent projects") + menuItem.triggered.connect(self._clearRecentProjects) + self.recentMenu.addAction(menuItem) + return def updateSpellCheck(self): @@ -150,6 +158,11 @@ class GuiMainMenu(QMenuBar): QDesktopServices.openUrl(QUrl(nw.__docurl__)) return True + def _clearRecentProjects(self): + self.mainConf.clearRecent() + self.updateRecentProjects() + return True + ## # Menu Builders ##