Tue, 05 May 2020 18:17:20 +0200
SiteInfoDialog: added a security icon and an indication for potentially insecure sites.
eric6/WebBrowser/SiteInfo/SiteInfoDialog.py | file | annotate | diff | comparison | revisions | |
eric6/WebBrowser/SiteInfo/SiteInfoDialog.ui | file | annotate | diff | comparison | revisions |
--- a/eric6/WebBrowser/SiteInfo/SiteInfoDialog.py Tue May 05 18:15:46 2020 +0200 +++ b/eric6/WebBrowser/SiteInfo/SiteInfoDialog.py Tue May 05 18:17:20 2020 +0200 @@ -24,14 +24,16 @@ from ..WebBrowserPage import WebBrowserPage import UI.PixmapCache +import Preferences + +from WebBrowser.WebBrowserWindow import WebBrowserWindow class SiteInfoDialog(QDialog, Ui_SiteInfoDialog): """ Class implementing a dialog to show some information about a site. """ - okStyle = "QLabel { color : white; background-color : green; }" - nokStyle = "QLabel { color : white; background-color : red; }" + securityStyleFormat = "QLabel {{ background-color : {0}; }}" def __init__(self, browser, parent=None): """ @@ -72,11 +74,31 @@ self.heading.setText("<b>{0}</b>".format(title)) self.siteAddressLabel.setText(self.__baseUrl.toString()) if self.__baseUrl.scheme() in ["https"]: - self.securityLabel.setStyleSheet(SiteInfoDialog.okStyle) - self.securityLabel.setText( - self.tr('<b>Connection is encrypted.</b>')) + if WebBrowserWindow.networkManager().isInsecureHost( + self.__baseUrl.host() + ): + self.securityIconLabel.setPixmap( + UI.PixmapCache.getPixmap("securityMedium")) + self.securityLabel.setStyleSheet( + SiteInfoDialog.securityStyleFormat.format( + Preferences.getWebBrowser("InsecureUrlColor").name() + ) + ) + self.securityLabel.setText(self.tr( + '<b>Connection is encrypted but may be insecure.</b>')) + else: + self.securityIconLabel.setPixmap( + UI.PixmapCache.getPixmap("securityHigh")) + self.securityLabel.setStyleSheet( + SiteInfoDialog.securityStyleFormat.format( + Preferences.getWebBrowser("SecureUrlColor").name() + ) + ) + self.securityLabel.setText( + self.tr('<b>Connection is encrypted.</b>')) else: - self.securityLabel.setStyleSheet(SiteInfoDialog.nokStyle) + self.securityIconLabel.setPixmap( + UI.PixmapCache.getPixmap("securityLow")) self.securityLabel.setText( self.tr('<b>Connection is not encrypted.</b>')) browser.page().runJavaScript(
--- a/eric6/WebBrowser/SiteInfo/SiteInfoDialog.ui Tue May 05 18:15:46 2020 +0200 +++ b/eric6/WebBrowser/SiteInfo/SiteInfoDialog.ui Tue May 05 18:17:20 2020 +0200 @@ -16,7 +16,7 @@ <property name="sizeGripEnabled"> <bool>true</bool> </property> - <layout class="QVBoxLayout" name="verticalLayout"> + <layout class="QVBoxLayout" name="verticalLayout_2"> <item> <widget class="QLabel" name="heading"> <property name="text"> @@ -36,7 +36,7 @@ <attribute name="title"> <string>General</string> </attribute> - <layout class="QVBoxLayout" name="verticalLayout_2"> + <layout class="QVBoxLayout" name="verticalLayout"> <item> <layout class="QGridLayout" name="gridLayout"> <item row="0" column="0"> @@ -140,13 +140,16 @@ </spacer> </item> <item row="1" column="1"> + <widget class="QLabel" name="securityIconLabel"/> + </item> + <item row="1" column="2"> <widget class="QLabel" name="securityLabel"> <property name="text"> <string/> </property> </widget> </item> - <item row="1" column="2"> + <item row="1" column="3"> <spacer name="horizontalSpacer_2"> <property name="orientation"> <enum>Qt::Horizontal</enum>