8 """ |
8 """ |
9 |
9 |
10 from PyQt6.QtCore import pyqtSlot, Qt, QTimer, QCoreApplication |
10 from PyQt6.QtCore import pyqtSlot, Qt, QTimer, QCoreApplication |
11 from PyQt6.QtWidgets import QDialog, QMenu, QToolButton |
11 from PyQt6.QtWidgets import QDialog, QMenu, QToolButton |
12 |
12 |
13 from EricWidgets import EricMessageBox |
13 from eric7.EricWidgets import EricMessageBox |
14 |
14 |
15 from .Ui_AdBlockDialog import Ui_AdBlockDialog |
15 from .Ui_AdBlockDialog import Ui_AdBlockDialog |
16 |
16 |
17 import UI.PixmapCache |
17 from eric7.EricGui import EricPixmapCache |
18 import Preferences |
18 from eric7 import Preferences |
19 |
19 |
20 |
20 |
21 class AdBlockDialog(QDialog, Ui_AdBlockDialog): |
21 class AdBlockDialog(QDialog, Ui_AdBlockDialog): |
22 """ |
22 """ |
23 Class implementing the AdBlock configuration dialog. |
23 Class implementing the AdBlock configuration dialog. |
36 self.setupUi(self) |
36 self.setupUi(self) |
37 self.setWindowFlags(Qt.WindowType.Window) |
37 self.setWindowFlags(Qt.WindowType.Window) |
38 |
38 |
39 self.__manager = manager |
39 self.__manager = manager |
40 |
40 |
41 self.iconLabel.setPixmap(UI.PixmapCache.getPixmap("adBlockPlus48")) |
41 self.iconLabel.setPixmap(EricPixmapCache.getPixmap("adBlockPlus48")) |
42 |
42 |
43 self.updateSpinBox.setValue(Preferences.getWebBrowser("AdBlockUpdatePeriod")) |
43 self.updateSpinBox.setValue(Preferences.getWebBrowser("AdBlockUpdatePeriod")) |
44 |
44 |
45 self.useLimitedEasyListCheckBox.setChecked( |
45 self.useLimitedEasyListCheckBox.setChecked( |
46 Preferences.getWebBrowser("AdBlockUseLimitedEasyList") |
46 Preferences.getWebBrowser("AdBlockUseLimitedEasyList") |
55 self.__loaded = False |
55 self.__loaded = False |
56 |
56 |
57 menu = QMenu(self) |
57 menu = QMenu(self) |
58 menu.aboutToShow.connect(self.__aboutToShowActionMenu) |
58 menu.aboutToShow.connect(self.__aboutToShowActionMenu) |
59 self.actionButton.setMenu(menu) |
59 self.actionButton.setMenu(menu) |
60 self.actionButton.setIcon(UI.PixmapCache.getIcon("adBlockAction")) |
60 self.actionButton.setIcon(EricPixmapCache.getIcon("adBlockAction")) |
61 self.actionButton.setPopupMode(QToolButton.ToolButtonPopupMode.InstantPopup) |
61 self.actionButton.setPopupMode(QToolButton.ToolButtonPopupMode.InstantPopup) |
62 |
62 |
63 self.__load() |
63 self.__load() |
64 |
64 |
65 self.buttonBox.setFocus() |
65 self.buttonBox.setFocus() |
82 from .AdBlockTreeWidget import AdBlockTreeWidget |
82 from .AdBlockTreeWidget import AdBlockTreeWidget |
83 |
83 |
84 for subscription in self.__manager.subscriptions(): |
84 for subscription in self.__manager.subscriptions(): |
85 tree = AdBlockTreeWidget(subscription, self.subscriptionsTabWidget) |
85 tree = AdBlockTreeWidget(subscription, self.subscriptionsTabWidget) |
86 icon = ( |
86 icon = ( |
87 UI.PixmapCache.getIcon("adBlockPlus") |
87 EricPixmapCache.getIcon("adBlockPlus") |
88 if subscription.isEnabled() |
88 if subscription.isEnabled() |
89 else UI.PixmapCache.getIcon("adBlockPlusDisabled") |
89 else EricPixmapCache.getIcon("adBlockPlusDisabled") |
90 ) |
90 ) |
91 self.subscriptionsTabWidget.addTab(tree, icon, subscription.title()) |
91 self.subscriptionsTabWidget.addTab(tree, icon, subscription.title()) |
92 |
92 |
93 self.__loaded = True |
93 self.__loaded = True |
94 QCoreApplication.processEvents() |
94 QCoreApplication.processEvents() |
203 |
203 |
204 def __browseSubscriptions(self): |
204 def __browseSubscriptions(self): |
205 """ |
205 """ |
206 Private slot to browse the list of available AdBlock subscriptions. |
206 Private slot to browse the list of available AdBlock subscriptions. |
207 """ |
207 """ |
208 from WebBrowser.WebBrowserWindow import WebBrowserWindow |
208 from eric7.WebBrowser.WebBrowserWindow import WebBrowserWindow |
209 |
209 |
210 mw = WebBrowserWindow.mainWindow() |
210 mw = WebBrowserWindow.mainWindow() |
211 mw.newTab("http://adblockplus.org/en/subscriptions") |
211 mw.newTab("http://adblockplus.org/en/subscriptions") |
212 mw.raise_() |
212 mw.raise_() |
213 |
213 |
214 def __learnAboutWritingFilters(self): |
214 def __learnAboutWritingFilters(self): |
215 """ |
215 """ |
216 Private slot to show the web page about how to write filters. |
216 Private slot to show the web page about how to write filters. |
217 """ |
217 """ |
218 from WebBrowser.WebBrowserWindow import WebBrowserWindow |
218 from eric7.WebBrowser.WebBrowserWindow import WebBrowserWindow |
219 |
219 |
220 mw = WebBrowserWindow.mainWindow() |
220 mw = WebBrowserWindow.mainWindow() |
221 mw.newTab("http://adblockplus.org/en/filters") |
221 mw.newTab("http://adblockplus.org/en/filters") |
222 mw.raise_() |
222 mw.raise_() |
223 |
223 |
277 """ |
277 """ |
278 if enable: |
278 if enable: |
279 # enable required one as well |
279 # enable required one as well |
280 sub = self.__manager.subscription(subscription.requiresLocation()) |
280 sub = self.__manager.subscription(subscription.requiresLocation()) |
281 requiresSubscriptions = [] if sub is None else [sub] |
281 requiresSubscriptions = [] if sub is None else [sub] |
282 icon = UI.PixmapCache.getIcon("adBlockPlus") |
282 icon = EricPixmapCache.getIcon("adBlockPlus") |
283 else: |
283 else: |
284 # disable dependent ones as well |
284 # disable dependent ones as well |
285 requiresSubscriptions = self.__manager.getRequiresSubscriptions( |
285 requiresSubscriptions = self.__manager.getRequiresSubscriptions( |
286 subscription |
286 subscription |
287 ) |
287 ) |
288 icon = UI.PixmapCache.getIcon("adBlockPlusDisabled") |
288 icon = EricPixmapCache.getIcon("adBlockPlusDisabled") |
289 requiresSubscriptions.append(subscription) |
289 requiresSubscriptions.append(subscription) |
290 for sub in requiresSubscriptions: |
290 for sub in requiresSubscriptions: |
291 sub.setEnabled(enable) |
291 sub.setEnabled(enable) |
292 |
292 |
293 for index in range(self.subscriptionsTabWidget.count()): |
293 for index in range(self.subscriptionsTabWidget.count()): |
306 @type int |
306 @type int |
307 """ |
307 """ |
308 if value != Preferences.getWebBrowser("AdBlockUpdatePeriod"): |
308 if value != Preferences.getWebBrowser("AdBlockUpdatePeriod"): |
309 Preferences.setWebBrowser("AdBlockUpdatePeriod", value) |
309 Preferences.setWebBrowser("AdBlockUpdatePeriod", value) |
310 |
310 |
311 from WebBrowser.WebBrowserWindow import WebBrowserWindow |
311 from eric7.WebBrowser.WebBrowserWindow import WebBrowserWindow |
312 |
312 |
313 manager = WebBrowserWindow.adBlockManager() |
313 manager = WebBrowserWindow.adBlockManager() |
314 for subscription in manager.subscriptions(): |
314 for subscription in manager.subscriptions(): |
315 subscription.checkForUpdate() |
315 subscription.checkForUpdate() |
316 |
316 |