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. |