22 |
22 |
23 class AdBlockDialog(QDialog, Ui_AdBlockDialog): |
23 class AdBlockDialog(QDialog, Ui_AdBlockDialog): |
24 """ |
24 """ |
25 Class implementing the AdBlock configuration dialog. |
25 Class implementing the AdBlock configuration dialog. |
26 """ |
26 """ |
27 def __init__(self, parent=None): |
27 def __init__(self, manager, parent=None): |
28 """ |
28 """ |
29 Constructor |
29 Constructor |
30 |
30 |
|
31 @param manager reference to the AdBlock manager (AdBlockManager) |
31 @param parent reference to the parent object (QWidget) |
32 @param parent reference to the parent object (QWidget) |
32 """ |
33 """ |
33 super(AdBlockDialog, self).__init__(parent) |
34 super(AdBlockDialog, self).__init__(parent) |
34 self.setupUi(self) |
35 self.setupUi(self) |
35 self.setWindowFlags(Qt.Window) |
36 self.setWindowFlags(Qt.Window) |
36 |
37 |
|
38 self.__manager = manager |
|
39 |
37 self.iconLabel.setPixmap(UI.PixmapCache.getPixmap("adBlockPlus48.png")) |
40 self.iconLabel.setPixmap(UI.PixmapCache.getPixmap("adBlockPlus48.png")) |
38 |
41 |
39 self.updateSpinBox.setValue(Preferences.getHelp("AdBlockUpdatePeriod")) |
42 self.updateSpinBox.setValue( |
|
43 Preferences.getWebBrowser("AdBlockUpdatePeriod")) |
|
44 |
|
45 self.__useLimited = Preferences.getWebBrowser( |
|
46 "AdBlockUseLimitedEasyList") |
|
47 self.useLimitedEasyListCheckBox.setChecked(self.__useLimited) |
40 |
48 |
41 self.searchEdit.setInactiveText(self.tr("Search...")) |
49 self.searchEdit.setInactiveText(self.tr("Search...")) |
42 |
50 |
43 from WebBrowser.WebBrowserWindow import WebBrowserWindow |
|
44 self.__manager = WebBrowserWindow.adBlockManager() |
|
45 self.adBlockGroup.setChecked(self.__manager.isEnabled()) |
51 self.adBlockGroup.setChecked(self.__manager.isEnabled()) |
46 self.__manager.requiredSubscriptionLoaded.connect(self.addSubscription) |
52 self.__manager.requiredSubscriptionLoaded.connect(self.addSubscription) |
47 |
53 |
48 self.__currentTreeWidget = None |
54 self.__currentTreeWidget = None |
49 self.__currentSubscription = None |
55 self.__currentSubscription = None |
299 if index != -1: |
305 if index != -1: |
300 self.__currentTreeWidget = \ |
306 self.__currentTreeWidget = \ |
301 self.subscriptionsTabWidget.widget(index) |
307 self.subscriptionsTabWidget.widget(index) |
302 self.__currentSubscription = \ |
308 self.__currentSubscription = \ |
303 self.__currentTreeWidget.subscription() |
309 self.__currentTreeWidget.subscription() |
|
310 |
|
311 isEasyList = \ |
|
312 self.__currentSubscription.url().toString().startswith( |
|
313 self.__manager.getDefaultSubscriptionUrl()) |
|
314 self.useLimitedEasyListCheckBox.setVisible(isEasyList) |
304 |
315 |
305 @pyqtSlot(str) |
316 @pyqtSlot(str) |
306 def on_searchEdit_textChanged(self, filter): |
317 def on_searchEdit_textChanged(self, filter): |
307 """ |
318 """ |
308 Private slot to set a new filter on the current widget. |
319 Private slot to set a new filter on the current widget. |
321 """ |
332 """ |
322 self.__manager.setEnabled(state) |
333 self.__manager.setEnabled(state) |
323 |
334 |
324 if state: |
335 if state: |
325 self.__load() |
336 self.__load() |
|
337 |
|
338 def closeEvent(self, evt): |
|
339 """ |
|
340 Public method handling a close event. |
|
341 |
|
342 @param evt reference to the close event |
|
343 @type QCloseEvent |
|
344 """ |
|
345 if self.useLimitedEasyListCheckBox.isChecked() != \ |
|
346 self.__useLimited: |
|
347 self.__manager.setUseLimitedEasyList( |
|
348 self.useLimitedEasyListCheckBox.isChecked()) |
|
349 |
|
350 super(AdBlockDialog, self).closeEvent(evt) |