WebBrowser/ImageSearch/ImageSearchEngine.py

changeset 4957
55c9bb589b0a
parent 4956
1496516b0f2c
child 5389
9b1c800daff3
equal deleted inserted replaced
4956:1496516b0f2c 4957:55c9bb589b0a
26 @type QObject 26 @type QObject
27 """ 27 """
28 super(ImageSearchEngine, self).__init__(parent) 28 super(ImageSearchEngine, self).__init__(parent)
29 29
30 self.__searchEngineNames = ["Google", "TinEye", "Yandex"] 30 self.__searchEngineNames = ["Google", "TinEye", "Yandex"]
31
32 self.__searchEngine = Preferences.getWebBrowser("ImmageSearchEngine")
33 31
34 def searchEngine(self): 32 def searchEngine(self):
35 """ 33 """
36 Public method to get the name of the current search engine. 34 Public method to get the name of the current search engine.
37 35
38 @return name of the current search engine 36 @return name of the current search engine
39 @rtype str 37 @rtype str
40 """ 38 """
41 return self.__searchEngine 39 return Preferences.getWebBrowser("ImageSearchEngine")
42 40
43 def setSearchEngine(self, searchEngine): 41 def setSearchEngine(self, searchEngine):
44 """ 42 """
45 Public method to set the current search engine. 43 Public method to set the current search engine.
46 44
47 @param searchEngine name of the search engine 45 @param searchEngine name of the search engine
48 @type str 46 @type str
49 """ 47 """
50 self.__searchEngine = searchEngine 48 Preferences.setWebBrowser("ImageSearchEngine", searchEngine)
51 Preferences.setWebBrowser("ImmageSearchEngine", searchEngine)
52 49
53 def searchEngineNames(self): 50 def searchEngineNames(self):
54 """ 51 """
55 Public method to get the list of supported search engines. 52 Public method to get the list of supported search engines.
56 53
69 @type str 66 @type str
70 @return search query URL 67 @return search query URL
71 @rtype QUrl 68 @rtype QUrl
72 """ 69 """
73 if not searchEngine: 70 if not searchEngine:
74 searchEngine = self.__searchEngine 71 searchEngine = self.searchEngine()
75 72
76 searchEngine_l = searchEngine.lower() 73 searchEngine_l = searchEngine.lower()
77 if searchEngine_l == "google": 74 if searchEngine_l == "google":
78 return QUrl("https://www.google.com/searchbyimage?" 75 return QUrl("https://www.google.com/searchbyimage?"
79 "site=search&image_url={0}".format( 76 "site=search&image_url={0}".format(

eric ide

mercurial