WebBrowser/AdBlock/AdBlockDialog.py

changeset 6028
859f6894eed9
parent 5605
1950fe1a32c4
child 6048
82ad8ec9548c
equal deleted inserted replaced
6027:d056a536670e 6028:859f6894eed9
26 """ 26 """
27 def __init__(self, manager, 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 manager reference to the AdBlock manager
32 @param parent reference to the parent object (QWidget) 32 @type AdBlockManager
33 @param parent reference to the parent object
34 @type QWidget
33 """ 35 """
34 super(AdBlockDialog, self).__init__(parent) 36 super(AdBlockDialog, self).__init__(parent)
35 self.setupUi(self) 37 self.setupUi(self)
36 self.setWindowFlags(Qt.Window) 38 self.setWindowFlags(Qt.Window)
37 39
47 49
48 self.searchEdit.setInactiveText(self.tr("Search...")) 50 self.searchEdit.setInactiveText(self.tr("Search..."))
49 51
50 self.adBlockGroup.setChecked(self.__manager.isEnabled()) 52 self.adBlockGroup.setChecked(self.__manager.isEnabled())
51 self.__manager.requiredSubscriptionLoaded.connect(self.addSubscription) 53 self.__manager.requiredSubscriptionLoaded.connect(self.addSubscription)
54 self.__manager.enabledChanged.connect(self.__managerEnabledChanged)
52 55
53 self.__currentTreeWidget = None 56 self.__currentTreeWidget = None
54 self.__currentSubscription = None 57 self.__currentSubscription = None
55 self.__loaded = False 58 self.__loaded = False
56 59
97 def addSubscription(self, subscription, refresh=True): 100 def addSubscription(self, subscription, refresh=True):
98 """ 101 """
99 Public slot adding a subscription to the list. 102 Public slot adding a subscription to the list.
100 103
101 @param subscription reference to the subscription to be 104 @param subscription reference to the subscription to be
102 added (AdBlockSubscription) 105 added
103 @param refresh flag indicating to refresh the tree (boolean) 106 @type AdBlockSubscription
107 @param refresh flag indicating to refresh the tree
108 @type bool
104 """ 109 """
105 from .AdBlockTreeWidget import AdBlockTreeWidget 110 from .AdBlockTreeWidget import AdBlockTreeWidget
106 tree = AdBlockTreeWidget(subscription, self.subscriptionsTabWidget) 111 tree = AdBlockTreeWidget(subscription, self.subscriptionsTabWidget)
107 index = self.subscriptionsTabWidget.insertTab( 112 index = self.subscriptionsTabWidget.insertTab(
108 self.subscriptionsTabWidget.count() - 1, tree, 113 self.subscriptionsTabWidget.count() - 1, tree,
157 162
158 def addCustomRule(self, filterRule): 163 def addCustomRule(self, filterRule):
159 """ 164 """
160 Public slot to add a custom AdBlock rule. 165 Public slot to add a custom AdBlock rule.
161 166
162 @param filterRule filter to be added (string) 167 @param filterRule filter to be added
168 @type string
163 """ 169 """
164 self.subscriptionsTabWidget.setCurrentIndex( 170 self.subscriptionsTabWidget.setCurrentIndex(
165 self.subscriptionsTabWidget.count() - 1) 171 self.subscriptionsTabWidget.count() - 1)
166 self.__currentTreeWidget.addRule(filterRule) 172 self.__currentTreeWidget.addRule(filterRule)
167 173
254 def __setSubscriptionEnabled(self, subscription, enable): 260 def __setSubscriptionEnabled(self, subscription, enable):
255 """ 261 """
256 Private slot to set the enabled state of a subscription. 262 Private slot to set the enabled state of a subscription.
257 263
258 @param subscription subscription to set the state for 264 @param subscription subscription to set the state for
259 (AdBlockSubscription) 265 @type AdBlockSubscription
260 @param enable state to set to (boolean) 266 @param enable state to set to
267 @type bool
261 """ 268 """
262 if enable: 269 if enable:
263 # enable required one as well 270 # enable required one as well
264 sub = self.__manager.subscription(subscription.requiresLocation()) 271 sub = self.__manager.subscription(subscription.requiresLocation())
265 requiresSubscriptions = [] if sub is None else [sub] 272 requiresSubscriptions = [] if sub is None else [sub]
282 @pyqtSlot(int) 289 @pyqtSlot(int)
283 def on_updateSpinBox_valueChanged(self, value): 290 def on_updateSpinBox_valueChanged(self, value):
284 """ 291 """
285 Private slot to handle changes of the update period. 292 Private slot to handle changes of the update period.
286 293
287 @param value update period (integer) 294 @param value update period
295 @type int
288 """ 296 """
289 if value != Preferences.getWebBrowser("AdBlockUpdatePeriod"): 297 if value != Preferences.getWebBrowser("AdBlockUpdatePeriod"):
290 Preferences.setWebBrowser("AdBlockUpdatePeriod", value) 298 Preferences.setWebBrowser("AdBlockUpdatePeriod", value)
291 299
292 from WebBrowser.WebBrowserWindow import WebBrowserWindow 300 from WebBrowser.WebBrowserWindow import WebBrowserWindow
297 @pyqtSlot(int) 305 @pyqtSlot(int)
298 def on_subscriptionsTabWidget_currentChanged(self, index): 306 def on_subscriptionsTabWidget_currentChanged(self, index):
299 """ 307 """
300 Private slot handling the selection of another tab. 308 Private slot handling the selection of another tab.
301 309
302 @param index index of the new current tab (integer) 310 @param index index of the new current tab
311 @type int
303 """ 312 """
304 if index != -1: 313 if index != -1:
305 self.__currentTreeWidget = \ 314 self.__currentTreeWidget = \
306 self.subscriptionsTabWidget.widget(index) 315 self.subscriptionsTabWidget.widget(index)
307 self.__currentSubscription = \ 316 self.__currentSubscription = \
315 @pyqtSlot(str) 324 @pyqtSlot(str)
316 def on_searchEdit_textChanged(self, filterRule): 325 def on_searchEdit_textChanged(self, filterRule):
317 """ 326 """
318 Private slot to set a new filter on the current widget. 327 Private slot to set a new filter on the current widget.
319 328
320 @param filterRule filter to be set (string) 329 @param filterRule filter to be set
330 @type str
321 """ 331 """
322 if self.__currentTreeWidget and self.adBlockGroup.isChecked(): 332 if self.__currentTreeWidget and self.adBlockGroup.isChecked():
323 self.__currentTreeWidget.filterString(filterRule) 333 self.__currentTreeWidget.filterString(filterRule)
324 334
325 @pyqtSlot(bool) 335 @pyqtSlot(bool)
326 def on_adBlockGroup_toggled(self, state): 336 def on_adBlockGroup_toggled(self, state):
327 """ 337 """
328 Private slot handling the enabling/disabling of AdBlock. 338 Private slot handling the enabling/disabling of AdBlock.
329 339
330 @param state state of the toggle (boolean) 340 @param state state of the toggle
341 @type bool
331 """ 342 """
332 self.__manager.setEnabled(state) 343 self.__manager.setEnabled(state)
333 344
334 if state: 345 if state:
335 self.__load() 346 self.__load()
342 @param checked flag indicating the state of the check box 353 @param checked flag indicating the state of the check box
343 @type bool 354 @type bool
344 """ 355 """
345 self.__manager.setUseLimitedEasyList( 356 self.__manager.setUseLimitedEasyList(
346 self.useLimitedEasyListCheckBox.isChecked()) 357 self.useLimitedEasyListCheckBox.isChecked())
358
359 @pyqtSlot(bool)
360 def __managerEnabledChanged(self, enabled):
361 """
362 Private slot handling a change of the AdBlock manager enabled state.
363
364 @param enabled flag indicating the enabled state
365 @type bool
366 """
367 self.adBlockGroup.setChecked(enabled)

eric ide

mercurial