239 engineNames = self.__openSearchManager.allEnginesNames() |
239 engineNames = self.__openSearchManager.allEnginesNames() |
240 for engineName in engineNames: |
240 for engineName in engineNames: |
241 engine = self.__openSearchManager.engine(engineName) |
241 engine = self.__openSearchManager.engine(engineName) |
242 action = OpenSearchEngineAction(engine, self.__enginesMenu) |
242 action = OpenSearchEngineAction(engine, self.__enginesMenu) |
243 action.setData(engineName) |
243 action.setData(engineName) |
244 action.triggered.connect(self.__changeCurrentEngine) |
244 action.triggered.connect( |
|
245 lambda: self.__changeCurrentEngine(action)) |
245 self.__enginesMenu.addAction(action) |
246 self.__enginesMenu.addAction(action) |
246 |
247 |
247 if self.__openSearchManager.currentEngineName() == engineName: |
248 if self.__openSearchManager.currentEngineName() == engineName: |
248 action.setCheckable(True) |
249 action.setCheckable(True) |
249 action.setChecked(True) |
250 action.setChecked(True) |
272 title = url.host() |
273 title = url.host() |
273 else: |
274 else: |
274 title = ct.title() |
275 title = ct.title() |
275 |
276 |
276 action = self.__enginesMenu.addAction( |
277 action = self.__enginesMenu.addAction( |
277 self.tr("Add '{0}'").format(title), |
278 self.tr("Add '{0}'").format(title)) |
278 self.__addEngineFromUrl) |
|
279 action.setData(url) |
279 action.setData(url) |
280 action.setIcon(ct.icon()) |
280 action.setIcon(ct.icon()) |
|
281 action.triggered.connect( |
|
282 lambda: self.__addEngineFromUrl(action)) |
281 |
283 |
282 self.__enginesMenu.addSeparator() |
284 self.__enginesMenu.addSeparator() |
283 self.__enginesMenu.addAction(self.__mw.searchEnginesAction()) |
285 self.__enginesMenu.addAction(self.__mw.searchEnginesAction()) |
284 |
286 |
285 if self.__recentSearches: |
287 if self.__recentSearches: |
286 self.__enginesMenu.addAction(self.tr("Clear Recent Searches"), |
288 self.__enginesMenu.addAction(self.tr("Clear Recent Searches"), |
287 self.clear) |
289 self.clear) |
288 |
290 |
289 def __changeCurrentEngine(self): |
291 def __changeCurrentEngine(self, action): |
290 """ |
292 """ |
291 Private slot to handle the selection of a search engine. |
293 Private slot to handle the selection of a search engine. |
292 """ |
294 |
293 action = self.sender() |
295 @param action reference to the action that triggered |
294 if action is not None: |
296 @type QAction |
295 name = action.data() |
297 """ |
296 self.__openSearchManager.setCurrentEngineName(name) |
298 name = action.data() |
297 |
299 self.__openSearchManager.setCurrentEngineName(name) |
298 def __addEngineFromUrl(self): |
300 |
|
301 def __addEngineFromUrl(self, action): |
299 """ |
302 """ |
300 Private slot to add a search engine given its URL. |
303 Private slot to add a search engine given its URL. |
301 """ |
304 |
302 action = self.sender() |
305 @param action reference to the action that triggered |
303 if action is not None: |
306 @type QAction |
304 url = action.data() |
307 """ |
305 if not isinstance(url, QUrl): |
308 url = action.data() |
306 return |
309 if not isinstance(url, QUrl): |
307 |
310 return |
308 self.__openSearchManager.addEngine(url) |
311 |
|
312 self.__openSearchManager.addEngine(url) |
309 |
313 |
310 def __searchButtonClicked(self): |
314 def __searchButtonClicked(self): |
311 """ |
315 """ |
312 Private slot to show the search menu via the search button. |
316 Private slot to show the search menu via the search button. |
313 """ |
317 """ |