Changed code to not use 'act.menu()' anymore. eric7

Thu, 10 Jun 2021 17:10:57 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Thu, 10 Jun 2021 17:10:57 +0200
branch
eric7
changeset 8420
ff89f8bac0a5
parent 8419
32506bc52886
child 8421
cd4eee7f1d28

Changed code to not use 'act.menu()' anymore.

eric7/EricWidgets/EricModelMenu.py file | annotate | diff | comparison | revisions
eric7/WebBrowser/Bookmarks/BookmarksMenu.py file | annotate | diff | comparison | revisions
eric7/WebBrowser/Bookmarks/BookmarksToolBar.py file | annotate | diff | comparison | revisions
--- a/eric7/EricWidgets/EricModelMenu.py	Thu Jun 10 17:08:51 2021 +0200
+++ b/eric7/EricWidgets/EricModelMenu.py	Thu Jun 10 17:10:57 2021 +0200
@@ -46,12 +46,21 @@
         self.__dropRow = -1
         self.__dropIndex = None
         
+        self.menuActions = []
+        
         # This is to ensure it will be shown on Mac OS X
         self.addAction("--not populated--")
         
         self.aboutToShow.connect(self.__aboutToShow)
         self.triggered.connect(self.__actionTriggered)
     
+    def clear(self):
+        """
+        Public method to clear the menu.
+        """
+        super().clear()
+        self.menuActions.clear()
+    
     def prePopulated(self):
         """
         Public method to add any actions before the tree.
@@ -208,7 +217,8 @@
                 icon = UI.PixmapCache.getIcon("defaultIcon")
             modelMenu.setIcon(icon)
             if parentMenu is not None:
-                parentMenu.addMenu(modelMenu).setData(v)
+                self.menuActions.append(
+                    parentMenu.addMenu(modelMenu).setData(v))
             modelMenu.setRootIndex(parent)
             modelMenu.setModel(self.__model)
             return
--- a/eric7/WebBrowser/Bookmarks/BookmarksMenu.py	Thu Jun 10 17:08:51 2021 +0200
+++ b/eric7/WebBrowser/Bookmarks/BookmarksMenu.py	Thu Jun 10 17:10:57 2021 +0200
@@ -155,10 +155,9 @@
         """
         act = self.actionAt(pos)
         
-        # TODO: change this to not use act.menu()
         if (
             act is not None and
-            act.menu() is None and
+            act not in self.menuActions and
             self.index(act).isValid()
         ):
             menu = QMenu()
--- a/eric7/WebBrowser/Bookmarks/BookmarksToolBar.py	Thu Jun 10 17:08:51 2021 +0200
+++ b/eric7/WebBrowser/Bookmarks/BookmarksToolBar.py	Thu Jun 10 17:10:57 2021 +0200
@@ -82,8 +82,8 @@
         if act is not None:
             v = act.data()
             
-            # TODO: change this to not use act.menu()
-            if act.menu() is None:
+            button = self.widgetForAction(act)
+            if button.menu() is None:
                 act2 = menu.addAction(self.tr("Open"))
                 act2.setData(v)
                 act2.triggered.connect(

eric ide

mercurial