Commits

Aleš Erjavec committed c12e64d

Limit the number of recent schemes shown.

Comments (0)

Files changed (2)

Orange/OrangeCanvas/application/canvasmain.py

         )
 
         self.recent_schemes = config.recent_schemes()
+        self.num_recent_schemes = 15
 
         self.open_in_external_browser = False
         self.help = HelpManager(self)
             # No associated persistent path so we can't do anything.
             return
 
-        if title is None:
+        if not title:
             title = os.path.basename(path)
-            title, _ = os.path.splitext(title)
 
         filename = os.path.abspath(os.path.realpath(path))
         filename = os.path.normpath(filename)
 
             action = actions_by_filename[filename]
             self.recent_menu.removeAction(action)
+            self.recent_scheme_action_group.removeAction(action)
             action.setText(title or self.tr("untitled"))
         else:
             action = QAction(title or self.tr("untitled"), self,
         self.recent_scheme_action_group.addAction(action)
         self.recent_schemes.insert(0, (title, filename))
 
+        if len(self.recent_schemes) > max(self.num_recent_schemes, 1):
+            title, filename = self.recent_schemes.pop(-1)
+            action = actions_by_filename[filename]
+            self.recent_menu.removeAction(action)
+            self.recent_scheme_action_group.removeAction(action)
+
         config.save_recent_scheme_list(self.recent_schemes)
 
     def clear_recent_schemes(self):
 
         for action in actions_to_remove:
             self.recent_menu.removeAction(action)
+            self.recent_scheme_action_group.removeAction(action)
 
         self.recent_schemes = []
         config.save_recent_scheme_list([])
                                            type=bool)
         self.widgets_tool_box.setExclusive(toolbox_exclusive)
 
+        self.num_recent_schemes = settings.value("num-recent-schemes",
+                                                 defaultValue=15,
+                                                 type=int)
+
         settings.endGroup()
         settings.beginGroup("quickmenu")
 

Orange/OrangeCanvas/config.py

       "Use a popover menu to select a widget when clicking on a category "
       "button"),
 
-     ("mainwindow/number-of-recent-schemes", int, 7,
+     ("mainwindow/number-of-recent-schemes", int, 15,
       "Number of recent schemes to keep in history"),
 
      ("schemeedit/show-channel-names", bool, True,