49 self.__openSearchManager.currentEngineChanged.connect( |
49 self.__openSearchManager.currentEngineChanged.connect( |
50 self.__currentEngineChanged) |
50 self.__currentEngineChanged) |
51 self.__currentEngine = "" |
51 self.__currentEngine = "" |
52 |
52 |
53 self.__enginesMenu = QMenu(self) |
53 self.__enginesMenu = QMenu(self) |
|
54 self.__enginesMenu.triggered.connect( |
|
55 self.__handleEnginesMenuActionTriggered) |
54 |
56 |
55 self.__engineButton = E5LineEditButton(self) |
57 self.__engineButton = E5LineEditButton(self) |
56 self.__engineButton.setMenu(self.__enginesMenu) |
58 self.__engineButton.setMenu(self.__enginesMenu) |
57 self.addWidget(self.__engineButton, E5LineEdit.LeftSide) |
59 self.addWidget(self.__engineButton, E5LineEdit.LeftSide) |
58 |
60 |
239 engineNames = self.__openSearchManager.allEnginesNames() |
241 engineNames = self.__openSearchManager.allEnginesNames() |
240 for engineName in engineNames: |
242 for engineName in engineNames: |
241 engine = self.__openSearchManager.engine(engineName) |
243 engine = self.__openSearchManager.engine(engineName) |
242 action = OpenSearchEngineAction(engine, self.__enginesMenu) |
244 action = OpenSearchEngineAction(engine, self.__enginesMenu) |
243 action.setData(engineName) |
245 action.setData(engineName) |
244 action.triggered.connect( |
|
245 lambda: self.__changeCurrentEngine(action)) |
|
246 self.__enginesMenu.addAction(action) |
246 self.__enginesMenu.addAction(action) |
247 |
247 |
248 if self.__openSearchManager.currentEngineName() == engineName: |
248 if self.__openSearchManager.currentEngineName() == engineName: |
249 action.setCheckable(True) |
249 action.setCheckable(True) |
250 action.setChecked(True) |
250 action.setChecked(True) |
276 |
276 |
277 action = self.__enginesMenu.addAction( |
277 action = self.__enginesMenu.addAction( |
278 self.tr("Add '{0}'").format(title)) |
278 self.tr("Add '{0}'").format(title)) |
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)) |
|
283 |
281 |
284 self.__enginesMenu.addSeparator() |
282 self.__enginesMenu.addSeparator() |
285 self.__enginesMenu.addAction(self.__mw.searchEnginesAction()) |
283 self.__enginesMenu.addAction(self.__mw.searchEnginesAction()) |
286 |
284 |
287 if self.__recentSearches: |
285 if self.__recentSearches: |
288 self.__enginesMenu.addAction(self.tr("Clear Recent Searches"), |
286 act = self.__enginesMenu.addAction( |
289 self.clear) |
287 self.tr("Clear Recent Searches")) |
290 |
288 act.setData("@@CLEAR@@") |
291 def __changeCurrentEngine(self, action): |
289 |
292 """ |
290 def __handleEnginesMenuActionTriggered(self, action): |
293 Private slot to handle the selection of a search engine. |
291 """ |
|
292 Private slot to handle an action of the menu being triggered. |
294 |
293 |
295 @param action reference to the action that triggered |
294 @param action reference to the action that triggered |
296 @type QAction |
295 @type QAction |
297 """ |
296 """ |
298 name = action.data() |
297 actData = action.data() |
299 self.__openSearchManager.setCurrentEngineName(name) |
298 if isinstance(actData, QUrl): |
300 |
299 # add search engine |
301 def __addEngineFromUrl(self, action): |
300 self.__openSearchManager.addEngine(actData) |
302 """ |
301 elif isinstance(actData, str): |
303 Private slot to add a search engine given its URL. |
302 # engine name or special action |
304 |
303 if actData == "@@CLEAR@@": |
305 @param action reference to the action that triggered |
304 self.clear() |
306 @type QAction |
305 else: |
307 """ |
306 self.__openSearchManager.setCurrentEngineName(actData) |
308 url = action.data() |
|
309 if not isinstance(url, QUrl): |
|
310 return |
|
311 |
|
312 self.__openSearchManager.addEngine(url) |
|
313 |
307 |
314 def __searchButtonClicked(self): |
308 def __searchButtonClicked(self): |
315 """ |
309 """ |
316 Private slot to show the search menu via the search button. |
310 Private slot to show the search menu via the search button. |
317 """ |
311 """ |