6027:d056a536670e | 6028:859f6894eed9 |
---|---|
23 """ | 23 """ |
24 def __init__(self, parent): | 24 def __init__(self, parent): |
25 """ | 25 """ |
26 Constructor | 26 Constructor |
27 | 27 |
28 @param parent reference to the parent widget (HelpWindow) | 28 @param parent reference to the parent widget |
29 @type WebBrowserWindow | |
29 """ | 30 """ |
30 super(AdBlockIcon, self).__init__(parent) | 31 super(AdBlockIcon, self).__init__(parent) |
31 | 32 |
32 self.__mw = parent | 33 self.__mw = parent |
33 self.__menuAction = None | 34 self.__menuAction = None |
42 | 43 |
43 def setEnabled(self, enabled): | 44 def setEnabled(self, enabled): |
44 """ | 45 """ |
45 Public slot to set the enabled state. | 46 Public slot to set the enabled state. |
46 | 47 |
47 @param enabled enabled state (boolean) | 48 @param enabled enabled state |
49 @type bool | |
48 """ | 50 """ |
49 self.__enabled = enabled | 51 self.__enabled = enabled |
50 if enabled: | 52 if enabled: |
51 self.currentChanged() | 53 self.currentChanged() |
52 else: | 54 else: |
55 | 57 |
56 def __createMenu(self, menu=None): | 58 def __createMenu(self, menu=None): |
57 """ | 59 """ |
58 Private slot to create the context menu. | 60 Private slot to create the context menu. |
59 | 61 |
60 @param menu parent menu (QMenu) | 62 @param menu parent menu |
63 @type QMenu | |
61 """ | 64 """ |
62 if menu is None: | 65 if menu is None: |
63 menu = self.sender() | 66 menu = self.sender() |
64 if menu is None: | 67 if menu is None: |
65 return | 68 return |
100 | 103 |
101 def menuAction(self): | 104 def menuAction(self): |
102 """ | 105 """ |
103 Public method to get a reference to the menu action. | 106 Public method to get a reference to the menu action. |
104 | 107 |
105 @return reference to the menu action (QAction) | 108 @return reference to the menu action |
109 @rtype QAction | |
106 """ | 110 """ |
107 if not self.__menuAction: | 111 if not self.__menuAction: |
108 self.__menuAction = QAction(self.tr("AdBlock"), self) | 112 self.__menuAction = QAction(self.tr("AdBlock"), self) |
109 self.__menuAction.setMenu(QMenu()) | 113 self.__menuAction.setMenu(QMenu()) |
110 self.__menuAction.menu().aboutToShow.connect(self.__createMenu) | 114 self.__menuAction.menu().aboutToShow.connect(self.__createMenu) |
120 | 124 |
121 def __showMenu(self, pos): | 125 def __showMenu(self, pos): |
122 """ | 126 """ |
123 Private slot to show the context menu. | 127 Private slot to show the context menu. |
124 | 128 |
125 @param pos position the context menu should be shown (QPoint) | 129 @param pos position the context menu should be shown |
130 @type QPoint | |
126 """ | 131 """ |
127 menu = QMenu() | 132 menu = QMenu() |
128 self.__createMenu(menu) | 133 self.__createMenu(menu) |
129 menu.exec_(pos) | 134 menu.exec_(pos) |
130 | 135 |
139 def __isCurrentHostExcepted(self): | 144 def __isCurrentHostExcepted(self): |
140 """ | 145 """ |
141 Private method to check, if the host of the current browser is | 146 Private method to check, if the host of the current browser is |
142 excepted. | 147 excepted. |
143 | 148 |
144 @return flag indicating an exception (boolean) | 149 @return flag indicating an exception |
150 @rtype bool | |
145 """ | 151 """ |
146 browser = self.__mw.currentBrowser() | 152 browser = self.__mw.currentBrowser() |
147 if browser is None: | 153 if browser is None: |
148 return False | 154 return False |
149 | 155 |
179 | 185 |
180 def sourceChanged(self, browser, url): | 186 def sourceChanged(self, browser, url): |
181 """ | 187 """ |
182 Public slot to handle URL changes. | 188 Public slot to handle URL changes. |
183 | 189 |
184 @param browser reference to the browser (HelpBrowser) | 190 @param browser reference to the browser |
185 @param url new URL (QUrl) | 191 @type WebBrowserView |
192 @param url new URL | |
193 @type QUrl | |
186 """ | 194 """ |
187 if browser == self.__mw.currentBrowser(): | 195 if browser == self.__mw.currentBrowser(): |
188 self.currentChanged() | 196 self.currentChanged() |