Web Browser: added a configurable URL entry color to indicate sites with certificate issues.

Sun, 03 May 2020 10:26:40 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Sun, 03 May 2020 10:26:40 +0200
changeset 7567
bb196e51827d
parent 7566
7845da7a7ec2
child 7568
e8688eb98b98
child 7570
a7a5750aded4

Web Browser: added a configurable URL entry color to indicate sites with certificate issues.

docs/changelog file | annotate | diff | comparison | revisions
eric6/Preferences/ConfigurationPages/WebBrowserAppearancePage.py file | annotate | diff | comparison | revisions
eric6/Preferences/ConfigurationPages/WebBrowserAppearancePage.ui file | annotate | diff | comparison | revisions
eric6/Preferences/__init__.py file | annotate | diff | comparison | revisions
eric6/WebBrowser/UrlBar/UrlBar.py file | annotate | diff | comparison | revisions
--- a/docs/changelog	Sun May 03 09:36:15 2020 +0200
+++ b/docs/changelog	Sun May 03 10:26:40 2020 +0200
@@ -1,5 +1,10 @@
 Change Log
 ----------
+Version 20.6:
+- bug fixes
+- Web Browser:
+  -- added a configurable URL entry color to indicate sites with certificate
+     issues
 Version 20.5:
 - bug fixes
 - MicroPython
--- a/eric6/Preferences/ConfigurationPages/WebBrowserAppearancePage.py	Sun May 03 09:36:15 2020 +0200
+++ b/eric6/Preferences/ConfigurationPages/WebBrowserAppearancePage.py	Sun May 03 10:26:40 2020 +0200
@@ -80,7 +80,17 @@
             self.pictographFontLabel.setEnabled(False)
             self.pictographFontCombo.setEnabled(False)
         
-        self.initColour("SaveUrlColor", self.secureURLsColourButton,
+        self.initColour("SecureUrlColor",
+                        self.secureURLsColourButton,
+                        Preferences.getWebBrowser)
+        self.initColour("InsecureUrlColor",
+                        self.insecureURLsColourButton,
+                        Preferences.getWebBrowser)
+        self.initColour("MaliciousUrlColor",
+                        self.maliciousURLsColourButton,
+                        Preferences.getWebBrowser)
+        self.initColour("PrivateModeUrlColor",
+                        self.privateModeURLsColourButton,
                         Preferences.getWebBrowser)
         
         self.autoLoadImagesCheckBox.setChecked(
--- a/eric6/Preferences/ConfigurationPages/WebBrowserAppearancePage.ui	Sun May 03 09:36:15 2020 +0200
+++ b/eric6/Preferences/ConfigurationPages/WebBrowserAppearancePage.ui	Sun May 03 10:26:40 2020 +0200
@@ -7,10 +7,10 @@
     <x>0</x>
     <y>0</y>
     <width>499</width>
-    <height>905</height>
+    <height>1256</height>
    </rect>
   </property>
-  <layout class="QVBoxLayout" name="verticalLayout_5">
+  <layout class="QVBoxLayout" name="verticalLayout_6">
    <item>
     <widget class="QLabel" name="headerLabel">
      <property name="text">
@@ -278,43 +278,121 @@
      <property name="title">
       <string>Colors</string>
      </property>
-     <layout class="QGridLayout" name="gridLayout_2">
-      <item row="0" column="0">
-       <widget class="QLabel" name="textLabel1_3">
-        <property name="text">
-         <string>Background color of secure URLs:</string>
-        </property>
-       </widget>
-      </item>
-      <item row="0" column="1">
-       <widget class="QPushButton" name="secureURLsColourButton">
-        <property name="minimumSize">
-         <size>
-          <width>100</width>
-          <height>0</height>
-         </size>
+     <layout class="QVBoxLayout" name="verticalLayout_5">
+      <item>
+       <widget class="QGroupBox" name="groupBox_8">
+        <property name="title">
+         <string>URL Entry Background</string>
         </property>
-        <property name="toolTip">
-         <string>Select the background color for secure URLs.</string>
-        </property>
-        <property name="text">
-         <string/>
-        </property>
+        <layout class="QGridLayout" name="gridLayout_2">
+         <item row="0" column="0">
+          <widget class="QLabel" name="textLabel1_3">
+           <property name="text">
+            <string>Secure URLs:</string>
+           </property>
+          </widget>
+         </item>
+         <item row="0" column="1">
+          <widget class="QPushButton" name="secureURLsColourButton">
+           <property name="minimumSize">
+            <size>
+             <width>100</width>
+             <height>0</height>
+            </size>
+           </property>
+           <property name="toolTip">
+            <string>Select the background color for secure URLs.</string>
+           </property>
+           <property name="text">
+            <string/>
+           </property>
+          </widget>
+         </item>
+         <item row="0" column="2">
+          <spacer name="horizontalSpacer">
+           <property name="orientation">
+            <enum>Qt::Horizontal</enum>
+           </property>
+           <property name="sizeHint" stdset="0">
+            <size>
+             <width>223</width>
+             <height>17</height>
+            </size>
+           </property>
+          </spacer>
+         </item>
+         <item row="1" column="0">
+          <widget class="QLabel" name="textLabel1_4">
+           <property name="text">
+            <string>Insecure URLs:</string>
+           </property>
+          </widget>
+         </item>
+         <item row="1" column="1">
+          <widget class="QPushButton" name="insecureURLsColourButton">
+           <property name="minimumSize">
+            <size>
+             <width>100</width>
+             <height>0</height>
+            </size>
+           </property>
+           <property name="toolTip">
+            <string>Select the background color for insecure URLs.</string>
+           </property>
+           <property name="text">
+            <string/>
+           </property>
+          </widget>
+         </item>
+         <item row="2" column="0">
+          <widget class="QLabel" name="textLabel1_5">
+           <property name="text">
+            <string>Malicious URLs:</string>
+           </property>
+          </widget>
+         </item>
+         <item row="2" column="1">
+          <widget class="QPushButton" name="maliciousURLsColourButton">
+           <property name="minimumSize">
+            <size>
+             <width>100</width>
+             <height>0</height>
+            </size>
+           </property>
+           <property name="toolTip">
+            <string>Select the background color for malicious URLs.</string>
+           </property>
+           <property name="text">
+            <string/>
+           </property>
+          </widget>
+         </item>
+         <item row="3" column="0">
+          <widget class="QLabel" name="label_12">
+           <property name="text">
+            <string>Private Mode:</string>
+           </property>
+          </widget>
+         </item>
+         <item row="3" column="1">
+          <widget class="QPushButton" name="privateModeURLsColourButton">
+           <property name="minimumSize">
+            <size>
+             <width>100</width>
+             <height>0</height>
+            </size>
+           </property>
+           <property name="toolTip">
+            <string>Select the background color for URLs in private mode.</string>
+           </property>
+           <property name="text">
+            <string/>
+           </property>
+          </widget>
+         </item>
+        </layout>
        </widget>
       </item>
-      <item row="0" column="2">
-       <spacer name="horizontalSpacer">
-        <property name="orientation">
-         <enum>Qt::Horizontal</enum>
-        </property>
-        <property name="sizeHint" stdset="0">
-         <size>
-          <width>141</width>
-          <height>20</height>
-         </size>
-        </property>
-       </spacer>
-      </item>
      </layout>
     </widget>
    </item>
@@ -482,6 +560,9 @@
   <tabstop>minSizeSpinBox</tabstop>
   <tabstop>minLogicalSizeSpinBox</tabstop>
   <tabstop>secureURLsColourButton</tabstop>
+  <tabstop>insecureURLsColourButton</tabstop>
+  <tabstop>maliciousURLsColourButton</tabstop>
+  <tabstop>privateModeURLsColourButton</tabstop>
   <tabstop>autoLoadImagesCheckBox</tabstop>
   <tabstop>styleSheetPicker</tabstop>
   <tabstop>warnOnMultipleCloseCheckBox</tabstop>
--- a/eric6/Preferences/__init__.py	Sun May 03 09:36:15 2020 +0200
+++ b/eric6/Preferences/__init__.py	Sun May 03 10:26:40 2020 +0200
@@ -960,8 +960,10 @@
         "AcceptCookies": 2,         # CookieJar.AcceptOnlyFromSitesNavigatedTo
         "KeepCookiesUntil": 0,      # CookieJar.KeepUntilExpire
         "FilterTrackingCookies": True,
-        "SaveUrlColor": QColor(184, 248, 169),
-        # TODO: add colors for insecure URLs and malicious URLs
+        "SecureUrlColor": QColor(184, 248, 169),
+        "InsecureUrlColor": QColor(248, 227, 169),
+        "MaliciousUrlColor": QColor(255, 132, 140),
+        "PrivateModeUrlColor": QColor(220, 220, 220),
         "UserAgent": "",
         "AcceptQuotaRequest": 2,            # yes/no/ask (0, 1, 2)
         "AcceptProtocolHandlerRequest": 2,  # yes/no/ask (0, 1, 2)
@@ -1483,13 +1485,13 @@
         "MicrobitDocuUrl":
             "https://microbit-micropython.readthedocs.io/en/latest/",
         "CalliopeDocuUrl":
-            "https://github.com/calliope-mini/calliope-mini-micropython/", 
+            "https://github.com/calliope-mini/calliope-mini-micropython/",
         # MicroPython firmware URLs
         "MicroPythonFirmwareUrl": "http://micropython.org/download/",
         "CircuitPythonFirmwareUrl": "https://circuitpython.org/downloads/",
         "MicrobitFirmwareUrl": "https://microbit.org/guide/firmware/",
         "CalliopeFirmwareUrl":
-            "https://github.com/calliope-mini/calliope-mini-micropython/", 
+            "https://github.com/calliope-mini/calliope-mini-micropython/",
     }
     if Globals.isWindowsPlatform():
         microPythonDefaults["ColorScheme"] = "Windows 10"
@@ -2721,7 +2723,8 @@
         f.fromString(prefClass.settings.value(
             "WebBrowser/" + key, prefClass.webBrowserDefaults[key]))
         return f
-    elif key in ["SaveUrlColor"]:
+    elif key in ["SecureUrlColor", "InsecureUrlColor", "MaliciousUrlColor",
+                 "PrivateModeUrlColor"]:
         col = prefClass.settings.value("WebBrowser/" + key)
         if col is not None:
             return QColor(col)
@@ -2868,7 +2871,8 @@
     """
     if key in ["StandardFont", "FixedFont"]:
         prefClass.settings.setValue("WebBrowser/" + key, value.toString())
-    elif key == "SaveUrlColor":
+    elif key in ["SecureUrlColor", "InsecureUrlColor", "MaliciousUrlColor",
+                 "PrivateModeUrlColor"]:
         prefClass.settings.setValue("WebBrowser/" + key, value.name())
     elif key == "WebSearchKeywords":
         # value is list of tuples of (keyword, engine name)
--- a/eric6/WebBrowser/UrlBar/UrlBar.py	Sun May 03 09:36:15 2020 +0200
+++ b/eric6/WebBrowser/UrlBar/UrlBar.py	Sun May 03 10:26:40 2020 +0200
@@ -221,12 +221,12 @@
         
         @param evt reference to the paint event (QPaintEvent)
         """
+        foregroundColor = QApplication.palette().color(QPalette.Text)
+        
         if self.__privateMode:
-            backgroundColor = QColor(220, 220, 220)     # light gray
-            foregroundColor = Qt.black
+            backgroundColor = Preferences.getWebBrowser("PrivateModeUrlColor")
         else:
             backgroundColor = QApplication.palette().color(QPalette.Base)
-            foregroundColor = QApplication.palette().color(QPalette.Text)
         
         if self.__browser is not None:
             p = self.palette()
@@ -234,18 +234,17 @@
             
             if not self.__browser.getSafeBrowsingStatus():
                 # malicious web site
-                # TODO: make this color configurable
-                backgroundColor = QColor(170, 0, 0)
-                foregroundColor = QColor(Qt.white)
+                backgroundColor = Preferences.getWebBrowser(
+                        "MaliciousUrlColor")
             elif self.__browser.url().scheme() == "https":
                 if WebBrowserWindow.networkManager().isInsecureHost(
                     self.__browser.url().host()
                 ):
-                    # TODO: make this color configurable
-                    backgroundColor = QColor(170, 170, 0)
+                    backgroundColor = Preferences.getWebBrowser(
+                        "InsecureUrlColor")
                 else:
                     backgroundColor = Preferences.getWebBrowser(
-                        "SaveUrlColor")
+                        "SecureUrlColor")
             
             if progress == 0 or progress == 100:
                 p.setBrush(QPalette.Base, backgroundColor)

eric ide

mercurial