10 from __future__ import unicode_literals |
10 from __future__ import unicode_literals |
11 |
11 |
12 import os |
12 import os |
13 |
13 |
14 from PyQt5.QtCore import pyqtSlot, QUrl, Qt, QFile, qVersion |
14 from PyQt5.QtCore import pyqtSlot, QUrl, Qt, QFile, qVersion |
15 from PyQt5.QtGui import QPixmap, QCursor |
15 from PyQt5.QtGui import QPixmap, QCursor, QPainter, QColor, QBrush |
16 from PyQt5.QtWidgets import QDialog, QTreeWidgetItem, QGraphicsScene, QMenu, \ |
16 from PyQt5.QtWidgets import QDialog, QTreeWidgetItem, QGraphicsScene, QMenu, \ |
17 QApplication, QListWidgetItem |
17 QApplication, QListWidgetItem |
18 from PyQt5.QtWebKit import QWebSettings |
18 from PyQt5.QtWebKit import QWebSettings |
19 |
19 |
20 from E5Gui import E5MessageBox, E5FileDialog |
20 from E5Gui import E5MessageBox, E5FileDialog |
59 if SSL: |
59 if SSL: |
60 self.tabWidget.setTabIcon( |
60 self.tabWidget.setTabIcon( |
61 3, UI.PixmapCache.getIcon("siteinfo-security.png")) |
61 3, UI.PixmapCache.getIcon("siteinfo-security.png")) |
62 |
62 |
63 self.__mainFrame = browser.page().mainFrame() |
63 self.__mainFrame = browser.page().mainFrame() |
|
64 self.__baseUrl = browser.url() |
64 title = browser.title() |
65 title = browser.title() |
65 sslInfo = browser.page().getSslCertificateChain() |
66 sslInfo = browser.page().getSslCertificateChain() |
|
67 |
|
68 #prepare background of image preview |
|
69 self.__imagePreviewStandardBackground = \ |
|
70 self.imagePreview.backgroundBrush() |
|
71 color1 = QColor(220, 220, 220) |
|
72 color2 = QColor(160, 160, 160) |
|
73 self.__tilePixmap = QPixmap(8, 8) |
|
74 self.__tilePixmap.fill(color1) |
|
75 tilePainter = QPainter(self.__tilePixmap) |
|
76 tilePainter.fillRect(0, 0, 4, 4, color2) |
|
77 tilePainter.fillRect(4, 4, 4, 4, color2) |
|
78 tilePainter.end() |
66 |
79 |
67 # populate General tab |
80 # populate General tab |
68 self.heading.setText("<b>{0}</b>".format(title)) |
81 self.heading.setText("<b>{0}</b>".format(title)) |
69 self.siteAddressLabel.setText(self.__mainFrame.baseUrl().toString()) |
82 self.siteAddressLabel.setText(self.__mainFrame.baseUrl().toString()) |
70 self.sizeLabel.setText(dataString(browser.page().totalBytes())) |
83 self.sizeLabel.setText(dataString(browser.page().totalBytes())) |
170 """ |
183 """ |
171 if current is None: |
184 if current is None: |
172 return |
185 return |
173 |
186 |
174 imageUrl = QUrl(current.text(1)) |
187 imageUrl = QUrl(current.text(1)) |
175 if not imageUrl.host(): |
188 if imageUrl.isRelative(): |
176 imageUrl.setHost(QUrl(self.siteAddressLabel.text()).host()) |
189 imageUrl = self.__baseUrl.resolved(imageUrl) |
177 imageUrl.setScheme(QUrl(self.siteAddressLabel.text()).scheme()) |
190 |
178 |
191 |
179 import Helpviewer.HelpWindow |
192 import Helpviewer.HelpWindow |
180 cache = Helpviewer.HelpWindow.HelpWindow.networkAccessManager().cache() |
193 cache = Helpviewer.HelpWindow.HelpWindow.networkAccessManager().cache() |
181 if cache: |
194 if cache: |
182 cacheData = cache.data(imageUrl) |
195 cacheData = cache.data(imageUrl) |
190 else: |
203 else: |
191 pixmap.loadFromData(cacheData.readAll()) |
204 pixmap.loadFromData(cacheData.readAll()) |
192 if pixmap.isNull(): |
205 if pixmap.isNull(): |
193 invalidPixmap = True |
206 invalidPixmap = True |
194 if invalidPixmap: |
207 if invalidPixmap: |
|
208 self.imagePreview.setBackgroundBrush( |
|
209 self.__imagePreviewStandardBackground) |
195 scene.addText(self.tr("Preview not available.")) |
210 scene.addText(self.tr("Preview not available.")) |
196 else: |
211 else: |
|
212 self.imagePreview.setBackgroundBrush(QBrush(self.__tilePixmap)) |
197 scene.addPixmap(pixmap) |
213 scene.addPixmap(pixmap) |
198 self.imagePreview.setScene(scene) |
214 self.imagePreview.setScene(scene) |
199 |
215 |
200 def __imagesTreeContextMenuRequested(self, pos): |
216 def __imagesTreeContextMenuRequested(self, pos): |
201 """ |
217 """ |