eric6/WebBrowser/AdBlock/AdBlockIcon.py

changeset 7533
88261c96484b
parent 7360
9190402e4505
child 7759
51aa6c6b66f7
equal deleted inserted replaced
7532:1358e9d67a1c 7533:88261c96484b
50 self.__enabled = enabled 50 self.__enabled = enabled
51 if enabled: 51 if enabled:
52 self.currentChanged() 52 self.currentChanged()
53 else: 53 else:
54 self.setPixmap( 54 self.setPixmap(
55 UI.PixmapCache.getPixmap("adBlockPlusDisabled16.png")) 55 UI.PixmapCache.getPixmap("adBlockPlusDisabled16"))
56 56
57 def __createMenu(self, menu): 57 def __createMenu(self, menu):
58 """ 58 """
59 Private slot to create the context menu. 59 Private slot to create the context menu.
60 60
65 65
66 manager = self.__mw.adBlockManager() 66 manager = self.__mw.adBlockManager()
67 67
68 if manager.isEnabled(): 68 if manager.isEnabled():
69 act = menu.addAction( 69 act = menu.addAction(
70 UI.PixmapCache.getIcon("adBlockPlusDisabled.png"), 70 UI.PixmapCache.getIcon("adBlockPlusDisabled"),
71 self.tr("Disable AdBlock")) 71 self.tr("Disable AdBlock"))
72 act.setData(False) 72 act.setData(False)
73 act.triggered.connect(lambda: self.__enableAdBlock(act)) 73 act.triggered.connect(lambda: self.__enableAdBlock(act))
74 else: 74 else:
75 act = menu.addAction( 75 act = menu.addAction(
76 UI.PixmapCache.getIcon("adBlockPlus.png"), 76 UI.PixmapCache.getIcon("adBlockPlus"),
77 self.tr("Enable AdBlock")) 77 self.tr("Enable AdBlock"))
78 act.setData(True) 78 act.setData(True)
79 act.triggered.connect(lambda: self.__enableAdBlock(act)) 79 act.triggered.connect(lambda: self.__enableAdBlock(act))
80 menu.addSeparator() 80 menu.addSeparator()
81 if manager.isEnabled() and self.__mw.currentBrowser().url().host(): 81 if manager.isEnabled() and self.__mw.currentBrowser().url().host():
82 if self.__isCurrentHostExcepted(): 82 if self.__isCurrentHostExcepted():
83 act = menu.addAction( 83 act = menu.addAction(
84 UI.PixmapCache.getIcon("adBlockPlus.png"), 84 UI.PixmapCache.getIcon("adBlockPlus"),
85 self.tr("Remove AdBlock Exception")) 85 self.tr("Remove AdBlock Exception"))
86 act.setData(False) 86 act.setData(False)
87 act.triggered.connect(lambda: self.__setException(act)) 87 act.triggered.connect(lambda: self.__setException(act))
88 else: 88 else:
89 act = menu.addAction( 89 act = menu.addAction(
90 UI.PixmapCache.getIcon("adBlockPlusGreen.png"), 90 UI.PixmapCache.getIcon("adBlockPlusGreen"),
91 self.tr("Add AdBlock Exception")) 91 self.tr("Add AdBlock Exception"))
92 act.setData(True) 92 act.setData(True)
93 act.triggered.connect(lambda: self.__setException(act)) 93 act.triggered.connect(lambda: self.__setException(act))
94 menu.addAction( 94 menu.addAction(
95 UI.PixmapCache.getIcon("adBlockPlusGreen.png"), 95 UI.PixmapCache.getIcon("adBlockPlusGreen"),
96 self.tr("AdBlock Exceptions..."), manager.showExceptionsDialog) 96 self.tr("AdBlock Exceptions..."), manager.showExceptionsDialog)
97 menu.addSeparator() 97 menu.addSeparator()
98 menu.addAction( 98 menu.addAction(
99 UI.PixmapCache.getIcon("adBlockPlus.png"), 99 UI.PixmapCache.getIcon("adBlockPlus"),
100 self.tr("AdBlock Configuration..."), manager.showDialog) 100 self.tr("AdBlock Configuration..."), manager.showDialog)
101 101
102 def menuAction(self): 102 def menuAction(self):
103 """ 103 """
104 Public method to get a reference to the menu action. 104 Public method to get a reference to the menu action.
112 self.__menuAction.menu().aboutToShow.connect( 112 self.__menuAction.menu().aboutToShow.connect(
113 lambda: self.__createMenu(self.__menuAction.menu())) 113 lambda: self.__createMenu(self.__menuAction.menu()))
114 114
115 if self.__enabled: 115 if self.__enabled:
116 self.__menuAction.setIcon( 116 self.__menuAction.setIcon(
117 UI.PixmapCache.getIcon("adBlockPlus.png")) 117 UI.PixmapCache.getIcon("adBlockPlus"))
118 else: 118 else:
119 self.__menuAction.setIcon( 119 self.__menuAction.setIcon(
120 UI.PixmapCache.getIcon("adBlockPlusDisabled.png")) 120 UI.PixmapCache.getIcon("adBlockPlusDisabled"))
121 121
122 return self.__menuAction 122 return self.__menuAction
123 123
124 def __showMenu(self, pos): 124 def __showMenu(self, pos):
125 """ 125 """
165 Public slot to handle a change of the current browser tab. 165 Public slot to handle a change of the current browser tab.
166 """ 166 """
167 if self.__enabled: 167 if self.__enabled:
168 if self.__isCurrentHostExcepted(): 168 if self.__isCurrentHostExcepted():
169 self.setPixmap( 169 self.setPixmap(
170 UI.PixmapCache.getPixmap("adBlockPlusGreen16.png")) 170 UI.PixmapCache.getPixmap("adBlockPlusGreen16"))
171 else: 171 else:
172 self.setPixmap(UI.PixmapCache.getPixmap("adBlockPlus16.png")) 172 self.setPixmap(UI.PixmapCache.getPixmap("adBlockPlus16"))
173 173
174 def __setException(self, act): 174 def __setException(self, act):
175 """ 175 """
176 Private slot to add or remove the current host from the list of 176 Private slot to add or remove the current host from the list of
177 exceptions. 177 exceptions.

eric ide

mercurial