WebBrowser/TabManager/TabManagerWidget.py

changeset 6121
d3d64f3128b3
parent 6048
82ad8ec9548c
child 6645
ad476851d7e0
--- a/WebBrowser/TabManager/TabManagerWidget.py	Wed Feb 07 18:57:46 2018 +0100
+++ b/WebBrowser/TabManager/TabManagerWidget.py	Wed Feb 07 20:14:09 2018 +0100
@@ -403,18 +403,18 @@
         self.__waitForRefresh = False
     
     @pyqtSlot()
-    def __processActions(self):
+    def __processActions(self, act):
         """
         Private slot to process the actions.
+        
+        @param act reference to the action that triggered
+        @type QAction
         """
-        if self.sender() is None:
-            return
-        
         self.__refreshBlocked = True
         
         selectedBrowsers = collections.defaultdict(list)
         
-        command = self.sender().objectName()
+        command = act.objectName()
         
         for index in range(self.__tree.topLevelItemCount()):
             winItem = self.__tree.topLevelItem(index)
@@ -522,14 +522,16 @@
         menu.addSeparator()
         
         if self.__isBrowserSelected():
-            menu.addAction(
+            act = menu.addAction(
                 UI.PixmapCache.getIcon("bookmark22.png"),
-                self.tr("&Bookmark checked tabs"),
-                self.__processActions).setObjectName("bookmarkSelection")
-            menu.addAction(
+                self.tr("&Bookmark checked tabs"))
+            act.setObjectName("bookmarkSelection")
+            act.triggered.connect(lambda: self.__processActions(act))
+            act = menu.addAction(
                 UI.PixmapCache.getIcon("tabClose.png"),
-                self.tr("&Close checked tabs"),
-                self.__processActions).setObjectName("closeSelection")
+                self.tr("&Close checked tabs"))
+            act.setObjectName("closeSelection")
+            act.triggered.connect(lambda: self.__processActions(act))
         
         menu.exec_(self.__tree.viewport().mapToGlobal(pos))
     
@@ -560,21 +562,22 @@
         icon.setPixmap(
             UI.PixmapCache.getPixmap("tabManager.png").scaled(16, 16))
         icon.setToolTip(self.tr("Show Tab Manager"))
-        icon.clicked.connect(self.raiseTabManager)
+        icon.clicked.connect(lambda: self.raiseTabManager(icon))
         
         return icon
     
-    def raiseTabManager(self):
+    def raiseTabManager(self, icon):
         """
         Public slot to show the tab manager.
+        
+        @param icon reference to the clicked icon
+        @type E5ClickableLabel or QAction
         """
         window = None
-        icon = self.sender()
-        if icon:
-            if isinstance(icon, E5ClickableLabel):
-                window = icon.window()
-            elif isinstance(icon, QAction):
-                window = icon.parentWidget()
+        if isinstance(icon, E5ClickableLabel):
+            window = icon.window()
+        elif isinstance(icon, QAction):
+            window = icon.parentWidget()
         
         if window is not None:
             titleBarHeight = self.style().pixelMetric(QStyle.PM_TitleBarHeight)

eric ide

mercurial