eric6/WebBrowser/SiteInfo/SiteInfoDialog.py

changeset 7577
6eaa43d3786e
parent 7533
88261c96484b
child 7759
51aa6c6b66f7
equal deleted inserted replaced
7576:72fa014332aa 7577:6eaa43d3786e
22 22
23 from ..Tools import Scripts, WebBrowserTools 23 from ..Tools import Scripts, WebBrowserTools
24 from ..WebBrowserPage import WebBrowserPage 24 from ..WebBrowserPage import WebBrowserPage
25 25
26 import UI.PixmapCache 26 import UI.PixmapCache
27 import Preferences
28
29 from WebBrowser.WebBrowserWindow import WebBrowserWindow
27 30
28 31
29 class SiteInfoDialog(QDialog, Ui_SiteInfoDialog): 32 class SiteInfoDialog(QDialog, Ui_SiteInfoDialog):
30 """ 33 """
31 Class implementing a dialog to show some information about a site. 34 Class implementing a dialog to show some information about a site.
32 """ 35 """
33 okStyle = "QLabel { color : white; background-color : green; }" 36 securityStyleFormat = "QLabel {{ background-color : {0}; }}"
34 nokStyle = "QLabel { color : white; background-color : red; }"
35 37
36 def __init__(self, browser, parent=None): 38 def __init__(self, browser, parent=None):
37 """ 39 """
38 Constructor 40 Constructor
39 41
70 72
71 # populate General tab 73 # populate General tab
72 self.heading.setText("<b>{0}</b>".format(title)) 74 self.heading.setText("<b>{0}</b>".format(title))
73 self.siteAddressLabel.setText(self.__baseUrl.toString()) 75 self.siteAddressLabel.setText(self.__baseUrl.toString())
74 if self.__baseUrl.scheme() in ["https"]: 76 if self.__baseUrl.scheme() in ["https"]:
75 self.securityLabel.setStyleSheet(SiteInfoDialog.okStyle) 77 if WebBrowserWindow.networkManager().isInsecureHost(
76 self.securityLabel.setText( 78 self.__baseUrl.host()
77 self.tr('<b>Connection is encrypted.</b>')) 79 ):
80 self.securityIconLabel.setPixmap(
81 UI.PixmapCache.getPixmap("securityMedium"))
82 self.securityLabel.setStyleSheet(
83 SiteInfoDialog.securityStyleFormat.format(
84 Preferences.getWebBrowser("InsecureUrlColor").name()
85 )
86 )
87 self.securityLabel.setText(self.tr(
88 '<b>Connection is encrypted but may be insecure.</b>'))
89 else:
90 self.securityIconLabel.setPixmap(
91 UI.PixmapCache.getPixmap("securityHigh"))
92 self.securityLabel.setStyleSheet(
93 SiteInfoDialog.securityStyleFormat.format(
94 Preferences.getWebBrowser("SecureUrlColor").name()
95 )
96 )
97 self.securityLabel.setText(
98 self.tr('<b>Connection is encrypted.</b>'))
78 else: 99 else:
79 self.securityLabel.setStyleSheet(SiteInfoDialog.nokStyle) 100 self.securityIconLabel.setPixmap(
101 UI.PixmapCache.getPixmap("securityLow"))
80 self.securityLabel.setText( 102 self.securityLabel.setText(
81 self.tr('<b>Connection is not encrypted.</b>')) 103 self.tr('<b>Connection is not encrypted.</b>'))
82 browser.page().runJavaScript( 104 browser.page().runJavaScript(
83 "document.charset", WebBrowserPage.SafeJsWorld, 105 "document.charset", WebBrowserPage.SafeJsWorld,
84 lambda res: self.encodingLabel.setText(res)) 106 lambda res: self.encodingLabel.setText(res))

eric ide

mercurial