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