src/eric7/WebBrowser/AdBlock/AdBlockExceptionsDialog.py

branch
eric7
changeset 9221
bf71ee032bb4
parent 9209
b99e7fd55fd3
child 9413
80c06d472826
equal deleted inserted replaced
9220:e9e7eca7efee 9221:bf71ee032bb4
17 17
18 class AdBlockExceptionsDialog(QDialog, Ui_AdBlockExceptionsDialog): 18 class AdBlockExceptionsDialog(QDialog, Ui_AdBlockExceptionsDialog):
19 """ 19 """
20 Class implementing a dialog to configure the AdBlock exceptions. 20 Class implementing a dialog to configure the AdBlock exceptions.
21 """ 21 """
22
22 def __init__(self, parent=None): 23 def __init__(self, parent=None):
23 """ 24 """
24 Constructor 25 Constructor
25 26
26 @param parent reference to the parent widget 27 @param parent reference to the parent widget
27 @type QWidget 28 @type QWidget
28 """ 29 """
29 super().__init__(parent) 30 super().__init__(parent)
30 self.setupUi(self) 31 self.setupUi(self)
31 self.setWindowFlags(Qt.WindowType.Window) 32 self.setWindowFlags(Qt.WindowType.Window)
32 33
33 self.iconLabel.setPixmap( 34 self.iconLabel.setPixmap(UI.PixmapCache.getPixmap("adBlockPlusGreen48"))
34 UI.PixmapCache.getPixmap("adBlockPlusGreen48")) 35
35
36 self.buttonBox.setFocus() 36 self.buttonBox.setFocus()
37 37
38 def load(self, hosts): 38 def load(self, hosts):
39 """ 39 """
40 Public slot to load the list of excepted hosts. 40 Public slot to load the list of excepted hosts.
41 41
42 @param hosts list of excepted hosts 42 @param hosts list of excepted hosts
43 @type list of str 43 @type list of str
44 """ 44 """
45 self.hostList.clear() 45 self.hostList.clear()
46 self.hostList.addItems(hosts) 46 self.hostList.addItems(hosts)
47 47
48 @pyqtSlot(str) 48 @pyqtSlot(str)
49 def on_hostEdit_textChanged(self, txt): 49 def on_hostEdit_textChanged(self, txt):
50 """ 50 """
51 Private slot to handle changes of the host edit. 51 Private slot to handle changes of the host edit.
52 52
53 @param txt text of the edit 53 @param txt text of the edit
54 @type str 54 @type str
55 """ 55 """
56 self.addButton.setEnabled(bool(txt)) 56 self.addButton.setEnabled(bool(txt))
57 57
58 @pyqtSlot() 58 @pyqtSlot()
59 def on_addButton_clicked(self): 59 def on_addButton_clicked(self):
60 """ 60 """
61 Private slot to handle a click of the add button. 61 Private slot to handle a click of the add button.
62 """ 62 """
63 self.hostList.addItem(self.hostEdit.text()) 63 self.hostList.addItem(self.hostEdit.text())
64 self.hostEdit.clear() 64 self.hostEdit.clear()
65 65
66 @pyqtSlot() 66 @pyqtSlot()
67 def on_hostList_itemSelectionChanged(self): 67 def on_hostList_itemSelectionChanged(self):
68 """ 68 """
69 Private slot handling a change of the number of selected items. 69 Private slot handling a change of the number of selected items.
70 """ 70 """
71 self.deleteButton.setEnabled(len(self.hostList.selectedItems()) > 0) 71 self.deleteButton.setEnabled(len(self.hostList.selectedItems()) > 0)
72 72
73 @pyqtSlot() 73 @pyqtSlot()
74 def on_deleteButton_clicked(self): 74 def on_deleteButton_clicked(self):
75 """ 75 """
76 Private slot handling a click of the delete button. 76 Private slot handling a click of the delete button.
77 """ 77 """
78 for itm in self.hostList.selectedItems(): 78 for itm in self.hostList.selectedItems():
79 row = self.hostList.row(itm) 79 row = self.hostList.row(itm)
80 removedItem = self.hostList.takeItem(row) 80 removedItem = self.hostList.takeItem(row)
81 del removedItem 81 del removedItem
82 82
83 def accept(self): 83 def accept(self):
84 """ 84 """
85 Public slot handling the acceptance of the dialog. 85 Public slot handling the acceptance of the dialog.
86 """ 86 """
87 hosts = [] 87 hosts = []
88 for row in range(self.hostList.count()): 88 for row in range(self.hostList.count()):
89 hosts.append(self.hostList.item(row).text()) 89 hosts.append(self.hostList.item(row).text())
90 90
91 from WebBrowser.WebBrowserWindow import WebBrowserWindow 91 from WebBrowser.WebBrowserWindow import WebBrowserWindow
92
92 WebBrowserWindow.adBlockManager().setExceptions(hosts) 93 WebBrowserWindow.adBlockManager().setExceptions(hosts)
93 94
94 super().accept() 95 super().accept()

eric ide

mercurial