eric6/WebBrowser/Tools/WebIconProvider.py

changeset 8143
2c730d5fd177
parent 7923
91e843545d9a
child 8218
7c09585bd960
equal deleted inserted replaced
8141:27f636beebad 8143:2c730d5fd177
112 if not WebBrowserWindow.isPrivate() and bool(self.__iconDatabasePath): 112 if not WebBrowserWindow.isPrivate() and bool(self.__iconDatabasePath):
113 db = {} 113 db = {}
114 for url, icon in self.__iconsDB.items(): 114 for url, icon in self.__iconsDB.items():
115 ba = QByteArray() 115 ba = QByteArray()
116 buffer = QBuffer(ba) 116 buffer = QBuffer(ba)
117 buffer.open(QIODevice.WriteOnly) 117 buffer.open(QIODevice.OpenModeFlag.WriteOnly)
118 icon.pixmap(32).toImage().save(buffer, "PNG") 118 icon.pixmap(32).toImage().save(buffer, "PNG")
119 db[url] = bytes(buffer.data()).decode(self.__encoding) 119 db[url] = bytes(buffer.data()).decode(self.__encoding)
120 120
121 filename = os.path.join(self.__iconDatabasePath, 121 filename = os.path.join(self.__iconDatabasePath,
122 self.__iconsFileName) 122 self.__iconsFileName)
155 @param url URL to be converted 155 @param url URL to be converted
156 @type QUrl 156 @type QUrl
157 @return string representation of the URL 157 @return string representation of the URL
158 @rtype str 158 @rtype str
159 """ 159 """
160 return url.toString(QUrl.PrettyDecoded | QUrl.RemoveUserInfo | 160 return url.toString(
161 QUrl.RemoveFragment | QUrl.RemovePath) 161 QUrl.ComponentFormattingOption.PrettyDecoded |
162 QUrl.UrlFormattingOption.RemoveUserInfo |
163 QUrl.UrlFormattingOption.RemoveFragment |
164 QUrl.UrlFormattingOption.RemovePath
165 )
162 166
163 def iconForUrl(self, url): 167 def iconForUrl(self, url):
164 """ 168 """
165 Public method to get an icon for an URL. 169 Public method to get an icon for an URL.
166 170
223 """ 227 """
224 self.load() 228 self.load()
225 229
226 from .WebIconDialog import WebIconDialog 230 from .WebIconDialog import WebIconDialog
227 dlg = WebIconDialog(self.__iconsDB) 231 dlg = WebIconDialog(self.__iconsDB)
228 if dlg.exec() == QDialog.Accepted: 232 if dlg.exec() == QDialog.DialogCode.Accepted:
229 changed = False 233 changed = False
230 urls = dlg.getUrls() 234 urls = dlg.getUrls()
231 for url in list(self.__iconsDB.keys())[:]: 235 for url in list(self.__iconsDB.keys())[:]:
232 if url not in urls: 236 if url not in urls:
233 del self.__iconsDB[url] 237 del self.__iconsDB[url]

eric ide

mercurial