|
1 # -*- coding: utf-8 -*- |
|
2 |
|
3 # Copyright (c) 2016 - 2021 Detlev Offenbach <detlev@die-offenbachs.de> |
|
4 # |
|
5 |
|
6 """ |
|
7 Module implementing the Python side of the eric home page. |
|
8 """ |
|
9 |
|
10 from PyQt5.QtCore import pyqtSlot, QObject |
|
11 |
|
12 |
|
13 class StartPageJsObject(QObject): |
|
14 """ |
|
15 Class implementing the Python side of the eric home page. |
|
16 """ |
|
17 def __init__(self, parent=None): |
|
18 """ |
|
19 Constructor |
|
20 |
|
21 @param parent reference to the parent object |
|
22 @type ExternalJsObject |
|
23 """ |
|
24 super().__init__(parent) |
|
25 |
|
26 self.__external = parent |
|
27 |
|
28 @pyqtSlot(result=str) |
|
29 def providerString(self): |
|
30 """ |
|
31 Public method to get a string for the search provider. |
|
32 |
|
33 @return string for the search provider (string) |
|
34 """ |
|
35 return (self.tr("Search results provided by {0}") |
|
36 .format(self.__external.page().view().mainWindow() |
|
37 .openSearchManager().currentEngineName())) |
|
38 |
|
39 @pyqtSlot(str, result=str) |
|
40 def searchUrl(self, searchStr): |
|
41 """ |
|
42 Public method to get the search URL for the given search term. |
|
43 |
|
44 @param searchStr search term (string) |
|
45 @return search URL (string) |
|
46 """ |
|
47 return bytes( |
|
48 self.__external.page().view().mainWindow().openSearchManager() |
|
49 .currentEngine().searchUrl(searchStr).toEncoded()).decode() |