eric6/WebBrowser/AdBlock/AdBlockIcon.py

changeset 7772
1958fe8d3f2c
parent 7759
51aa6c6b66f7
child 7781
607a6098cb44
diff -r 787a6b3f8c9f -r 1958fe8d3f2c eric6/WebBrowser/AdBlock/AdBlockIcon.py
--- a/eric6/WebBrowser/AdBlock/AdBlockIcon.py	Sat Oct 10 12:20:51 2020 +0200
+++ b/eric6/WebBrowser/AdBlock/AdBlockIcon.py	Sat Oct 10 15:16:17 2020 +0200
@@ -69,28 +69,24 @@
             act = menu.addAction(
                 UI.PixmapCache.getIcon("adBlockPlusDisabled"),
                 self.tr("Disable AdBlock"))
-            act.setData(False)
-            act.triggered.connect(lambda: self.__enableAdBlock(act))
+            act.triggered.connect(lambda: self.__enableAdBlock(False))
         else:
             act = menu.addAction(
                 UI.PixmapCache.getIcon("adBlockPlus"),
                 self.tr("Enable AdBlock"))
-            act.setData(True)
-            act.triggered.connect(lambda: self.__enableAdBlock(act))
+            act.triggered.connect(lambda: self.__enableAdBlock(True))
         menu.addSeparator()
         if manager.isEnabled() and self.__mw.currentBrowser().url().host():
             if self.__isCurrentHostExcepted():
                 act = menu.addAction(
                     UI.PixmapCache.getIcon("adBlockPlus"),
                     self.tr("Remove AdBlock Exception"))
-                act.setData(False)
-                act.triggered.connect(lambda: self.__setException(act))
+                act.triggered.connect(lambda: self.__setException(False))
             else:
                 act = menu.addAction(
                     UI.PixmapCache.getIcon("adBlockPlusGreen"),
                     self.tr("Add AdBlock Exception"))
-                act.setData(True)
-                act.triggered.connect(lambda: self.__setException(act))
+                act.triggered.connect(lambda: self.__setException(True))
         menu.addAction(
             UI.PixmapCache.getIcon("adBlockPlusGreen"),
             self.tr("AdBlock Exceptions..."), manager.showExceptionsDialog)
@@ -132,14 +128,14 @@
         self.__createMenu(menu)
         menu.exec(pos)
     
-    def __enableAdBlock(self, act):
+    def __enableAdBlock(self, enable):
         """
         Private slot to enable or disable AdBlock.
         
-        @param act reference to the action
-        @type QAction
+        @param enable flag indicating the desired enable state
+        @type bool
         """
-        self.__mw.adBlockManager().setEnabled(act.data())
+        self.__mw.adBlockManager().setEnabled(enable)
     
     def __isCurrentHostExcepted(self):
         """
@@ -171,16 +167,16 @@
             else:
                 self.setPixmap(UI.PixmapCache.getPixmap("adBlockPlus16"))
     
-    def __setException(self, act):
+    def __setException(self, enable):
         """
         Private slot to add or remove the current host from the list of
         exceptions.
         
-        @param act referenced to the action
-        @type QAction
+        @param enable flag indicating to set or remove an exception
+        @type bool
         """
         urlHost = self.__mw.currentBrowser().url().host()
-        if act.data():
+        if enable:
             self.__mw.adBlockManager().addException(urlHost)
         else:
             self.__mw.adBlockManager().removeException(urlHost)

eric ide

mercurial