Helpviewer/SiteInfo/SiteInfoDialog.py

changeset 4942
d6d362104f83
parent 4631
5c1a96925da4
child 4956
1496516b0f2c
diff -r b0e4e7a65872 -r d6d362104f83 Helpviewer/SiteInfo/SiteInfoDialog.py
--- a/Helpviewer/SiteInfo/SiteInfoDialog.py	Thu Apr 14 19:54:12 2016 +0200
+++ b/Helpviewer/SiteInfo/SiteInfoDialog.py	Fri Apr 15 19:55:52 2016 +0200
@@ -12,7 +12,7 @@
 import os
 
 from PyQt5.QtCore import pyqtSlot, QUrl, Qt, QFile, qVersion
-from PyQt5.QtGui import QPixmap, QCursor
+from PyQt5.QtGui import QPixmap, QCursor, QPainter, QColor, QBrush
 from PyQt5.QtWidgets import QDialog, QTreeWidgetItem, QGraphicsScene, QMenu, \
     QApplication, QListWidgetItem
 from PyQt5.QtWebKit import QWebSettings
@@ -61,9 +61,22 @@
                 3, UI.PixmapCache.getIcon("siteinfo-security.png"))
         
         self.__mainFrame = browser.page().mainFrame()
+        self.__baseUrl = browser.url()
         title = browser.title()
         sslInfo = browser.page().getSslCertificateChain()
         
+        #prepare background of image preview
+        self.__imagePreviewStandardBackground = \
+            self.imagePreview.backgroundBrush()
+        color1 = QColor(220, 220, 220)
+        color2 = QColor(160, 160, 160)
+        self.__tilePixmap = QPixmap(8, 8)
+        self.__tilePixmap.fill(color1)
+        tilePainter = QPainter(self.__tilePixmap)
+        tilePainter.fillRect(0, 0, 4, 4, color2)
+        tilePainter.fillRect(4, 4, 4, 4, color2)
+        tilePainter.end()
+        
         # populate General tab
         self.heading.setText("<b>{0}</b>".format(title))
         self.siteAddressLabel.setText(self.__mainFrame.baseUrl().toString())
@@ -172,9 +185,9 @@
             return
         
         imageUrl = QUrl(current.text(1))
-        if not imageUrl.host():
-            imageUrl.setHost(QUrl(self.siteAddressLabel.text()).host())
-            imageUrl.setScheme(QUrl(self.siteAddressLabel.text()).scheme())
+        if imageUrl.isRelative():
+            imageUrl = self.__baseUrl.resolved(imageUrl)
+        
         
         import Helpviewer.HelpWindow
         cache = Helpviewer.HelpWindow.HelpWindow.networkAccessManager().cache()
@@ -192,8 +205,11 @@
             if pixmap.isNull():
                 invalidPixmap = True
         if invalidPixmap:
+            self.imagePreview.setBackgroundBrush(
+                self.__imagePreviewStandardBackground)
             scene.addText(self.tr("Preview not available."))
         else:
+            self.imagePreview.setBackgroundBrush(QBrush(self.__tilePixmap))
             scene.addPixmap(pixmap)
         self.imagePreview.setScene(scene)
     

eric ide

mercurial