eric6/WebBrowser/Tools/WebIconProvider.py

changeset 7593
68b03f6ebed5
parent 7533
88261c96484b
child 7595
5db6bfeff23e
equal deleted inserted replaced
7592:f79dc58bdf62 7593:68b03f6ebed5
78 self.__loaded = False 78 self.__loaded = False
79 self.__iconsDB = {} 79 self.__iconsDB = {}
80 80
81 def load(self): 81 def load(self):
82 """ 82 """
83 Public method to load the bookmarks. 83 Public method to load the web site icons.
84 """ 84 """
85 if self.__loaded: 85 if self.__loaded:
86 return 86 return
87 87
88 if self.__iconDatabasePath: 88 if self.__iconDatabasePath:
103 103
104 self.__loaded = True 104 self.__loaded = True
105 105
106 def save(self): 106 def save(self):
107 """ 107 """
108 Public method to save the zoom values. 108 Public method to save the web site icons.
109 """ 109 """
110 if not self.__loaded: 110 if not self.__loaded:
111 return 111 return
112 112
113 from WebBrowser.WebBrowserWindow import WebBrowserWindow 113 from WebBrowser.WebBrowserWindow import WebBrowserWindow
159 @type QUrl 159 @type QUrl
160 @return string representation of the URL 160 @return string representation of the URL
161 @rtype str 161 @rtype str
162 """ 162 """
163 return url.toString(QUrl.PrettyDecoded | QUrl.RemoveUserInfo | 163 return url.toString(QUrl.PrettyDecoded | QUrl.RemoveUserInfo |
164 QUrl.RemoveFragment) 164 QUrl.RemoveFragment| QUrl.RemovePath)
165 165
166 def iconForUrl(self, url): 166 def iconForUrl(self, url):
167 """ 167 """
168 Public method to get an icon for an URL. 168 Public method to get an icon for an URL.
169 169
185 return UI.PixmapCache.getIcon("network-server") 185 return UI.PixmapCache.getIcon("network-server")
186 186
187 self.load() 187 self.load()
188 188
189 urlStr = self.__urlToString(url) 189 urlStr = self.__urlToString(url)
190 for iconUrlStr in self.__iconsDB: 190 if urlStr in self.__iconsDB:
191 if iconUrlStr.startswith(urlStr): 191 return self.__iconsDB[urlStr]
192 return self.__iconsDB[iconUrlStr] 192 else:
193 for iconUrlStr in self.__iconsDB:
194 if iconUrlStr.startswith(urlStr):
195 return self.__iconsDB[iconUrlStr]
193 196
194 # try replacing http scheme with https scheme 197 # try replacing http scheme with https scheme
195 url = QUrl(url) 198 url = QUrl(url)
196 if url.scheme() == "http": 199 if url.scheme() == "http":
197 url.setScheme("https") 200 url.setScheme("https")
198 urlStr = self.__urlToString(url) 201 urlStr = self.__urlToString(url)
199 for iconUrlStr in self.__iconsDB: 202 if urlStr in self.__iconsDB:
200 if iconUrlStr.startswith(urlStr): 203 return self.__iconsDB[urlStr]
201 return self.__iconsDB[iconUrlStr] 204 else:
205 for iconUrlStr in self.__iconsDB:
206 if iconUrlStr.startswith(urlStr):
207 return self.__iconsDB[iconUrlStr]
202 208
203 if scheme == "https": 209 if scheme == "https":
204 return UI.PixmapCache.getIcon("securityHigh32") 210 return UI.PixmapCache.getIcon("securityHigh32")
205 else: 211 else:
206 return UI.PixmapCache.getIcon("defaultIcon") 212 return UI.PixmapCache.getIcon("defaultIcon")

eric ide

mercurial