eric6/WebBrowser/SpeedDial/SpeedDial.py

changeset 7717
f32d7965a17e
parent 7360
9190402e4505
child 7781
607a6098cb44
equal deleted inserted replaced
7716:313e09453306 7717:f32d7965a17e
12 12
13 from PyQt5.QtCore import ( 13 from PyQt5.QtCore import (
14 pyqtSignal, pyqtSlot, QObject, QCryptographicHash, QByteArray, QUrl, 14 pyqtSignal, pyqtSlot, QObject, QCryptographicHash, QByteArray, QUrl,
15 qWarning 15 qWarning
16 ) 16 )
17 from PyQt5.QtGui import QPixmap
18 17
19 from E5Gui import E5MessageBox 18 from E5Gui import E5MessageBox
20 19
21 from ..Tools.WebBrowserTools import pixmapToDataUrl 20 from ..Tools.WebBrowserTools import pixmapFileToDataUrl
22 21
23 from Utilities.AutoSaver import AutoSaver 22 from Utilities.AutoSaver import AutoSaver
24 import Utilities 23 import Utilities
25 24
26 25
117 self.__regenerateScript = False 116 self.__regenerateScript = False
118 self.__initialScript = "" 117 self.__initialScript = ""
119 118
120 for page in self.__webPages: 119 for page in self.__webPages:
121 if page.broken: 120 if page.broken:
122 imgSource = "qrc:icons/brokenPage.png" 121 imgSource = pixmapFileToDataUrl("brokenPage.png", True)
123 else: 122 else:
124 imgSource = self.__imageFileName(page.url) 123 imgSource = self.__imageFileName(page.url)
125 if not os.path.exists(imgSource): 124 if not os.path.exists(imgSource):
126 self.loadThumbnail(page.url, False) 125 self.loadThumbnail(page.url, False)
127 imgSource = "qrc:icons/loading.gif" 126 imgSource = pixmapFileToDataUrl("loading.gif", True)
128 127
129 if not page.url: 128 if not page.url:
130 imgSource = "" 129 imgSource = ""
131 else: 130 else:
132 imgSource = pixmapToDataUrl( 131 imgSource = pixmapFileToDataUrl(imgSource, True)
133 QPixmap(imgSource)).toString()
134 132
135 self.__initialScript += ( 133 self.__initialScript += (
136 "addBox('{0}', '{1}', '{2}');\n").format( 134 "addBox('{0}', '{1}', '{2}');\n").format(
137 page.url, Utilities.html_uencode(page.title), 135 page.url, Utilities.html_uencode(page.title),
138 imgSource) 136 imgSource)
398 title = thumbnailer.title() 396 title = thumbnailer.title()
399 url = thumbnailer.url().toString() 397 url = thumbnailer.url().toString()
400 fileName = self.__imageFileName(url) 398 fileName = self.__imageFileName(url)
401 399
402 if image.isNull(): 400 if image.isNull():
403 fileName = "qrc:icons/brokenPage.png" 401 fileName = "brokenPage.png"
404 title = self.tr("Unable to load") 402 title = self.tr("Unable to load")
405 page = self.pageForUrl(thumbnailer.url()) 403 page = self.pageForUrl(thumbnailer.url())
406 page.broken = True 404 page.broken = True
407 else: 405 else:
408 if not image.save(fileName, "PNG"): 406 if not image.save(fileName, "PNG"):
416 414
417 if loadTitle: 415 if loadTitle:
418 self.pageTitleLoaded.emit(url, title) 416 self.pageTitleLoaded.emit(url, title)
419 417
420 self.thumbnailLoaded.emit( 418 self.thumbnailLoaded.emit(
421 url, pixmapToDataUrl(QPixmap(fileName)).toString()) 419 url, pixmapFileToDataUrl(fileName, True))
422 420
423 def __escapeTitle(self, title): 421 def __escapeTitle(self, title):
424 """ 422 """
425 Private method to escape a title string. 423 Private method to escape a title string.
426 424

eric ide

mercurial