Next batch of changes for QtWebEngine as of Qt 6.2.0. eric7

Tue, 31 Aug 2021 17:48:20 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Tue, 31 Aug 2021 17:48:20 +0200
branch
eric7
changeset 8563
3c6547443fb2
parent 8562
9250a6d5fde2
child 8564
c48137b0d7ba

Next batch of changes for QtWebEngine as of Qt 6.2.0.

eric7/Preferences/__init__.py file | annotate | diff | comparison | revisions
eric7/WebBrowser/Download/DownloadItem.py file | annotate | diff | comparison | revisions
eric7/WebBrowser/VirusTotal/VirusTotalApi.py file | annotate | diff | comparison | revisions
eric7/WebBrowser/VirusTotal/VirusTotalDomainReportDialog.py file | annotate | diff | comparison | revisions
eric7/WebBrowser/VirusTotal/VirusTotalDomainReportDialog.ui file | annotate | diff | comparison | revisions
--- a/eric7/Preferences/__init__.py	Tue Aug 31 17:31:23 2021 +0200
+++ b/eric7/Preferences/__init__.py	Tue Aug 31 17:48:20 2021 +0200
@@ -1119,7 +1119,6 @@
                 QWebEngineSettings.WebAttribute.ScreenCaptureEnabled),
             "WebGLEnabled": webEngineSettings.testAttribute(
                 QWebEngineSettings.WebAttribute.WebGLEnabled),
-            # TODO: add support for these attributes
             "Accelerated2dCanvasEnabled": webEngineSettings.testAttribute(
                 QWebEngineSettings.WebAttribute.Accelerated2dCanvasEnabled),
             "AutoLoadIconsForPage": webEngineSettings.testAttribute(
--- a/eric7/WebBrowser/Download/DownloadItem.py	Tue Aug 31 17:31:23 2021 +0200
+++ b/eric7/WebBrowser/Download/DownloadItem.py	Tue Aug 31 17:48:20 2021 +0200
@@ -7,6 +7,7 @@
 Module implementing a widget controlling a download.
 """
 
+import enum
 import os
 
 from PyQt6.QtCore import (
@@ -27,6 +28,15 @@
 import Utilities.MimeTypes
 
 
+class DownloadState(enum.Enum):
+    """
+    Class implementing the various download states.
+    """
+    Downloading = 0
+    Successful = 1
+    Cancelled = 2
+
+
 class DownloadItem(QWidget, Ui_DownloadItem):
     """
     Class implementing a widget controlling a download.
@@ -39,11 +49,6 @@
     downloadFinished = pyqtSignal(bool)
     progress = pyqtSignal(int, int)
     
-    # TODO: convert this to an enum
-    Downloading = 0
-    DownloadSuccessful = 1
-    DownloadCancelled = 2
-    
     def __init__(self, downloadRequest=None, pageUrl=None, parent=None):
         """
         Constructor
@@ -71,7 +76,7 @@
         self.openButton.setEnabled(False)
         self.openButton.setVisible(False)
         
-        self.__state = DownloadItem.Downloading
+        self.__state = DownloadState.Downloading
         
         icon = self.style().standardIcon(QStyle.StandardPixmap.SP_FileIcon)
         self.fileIcon.setPixmap(icon.pixmap(48, 48))
@@ -110,7 +115,8 @@
         
         # attach to the download item object
         self.__url = self.__downloadRequest.url()
-        self.__downloadRequest.receivedBytesChanged.connect(self.__downloadProgress)
+        self.__downloadRequest.receivedBytesChanged.connect(
+            self.__downloadProgress)
         self.__downloadRequest.isFinishedChanged.connect(self.__finished)
         
         # reset info
@@ -307,7 +313,7 @@
         self.pauseButton.setEnabled(False)
         self.pauseButton.setVisible(False)
         self.setUpdatesEnabled(True)
-        self.__state = DownloadItem.DownloadCancelled
+        self.__state = DownloadState.Cancelled
         self.__downloadRequest.cancel()
         self.__setDateTime()
         self.downloadFinished.emit(False)
@@ -463,7 +469,7 @@
         
         @return flag indicating a download is in progress (boolean)
         """
-        return self.__state == DownloadItem.Downloading
+        return self.__state == DownloadState.Downloading
     
     def downloadedSuccessfully(self):
         """
@@ -471,7 +477,7 @@
         
         @return flag indicating a successful download (boolean)
         """
-        return self.__state == DownloadItem.DownloadSuccessful
+        return self.__state == DownloadState.Successful
     
     def downloadCanceled(self):
         """
@@ -479,7 +485,7 @@
         
         @return flag indicating a canceled download (boolean)
         """
-        return self.__state == DownloadItem.DownloadCancelled
+        return self.__state == DownloadState.Cancelled
     
     def __finished(self):
         """
@@ -497,7 +503,7 @@
         self.stopButton.setVisible(False)
         self.openButton.setEnabled(noError)
         self.openButton.setVisible(noError)
-        self.__state = DownloadItem.DownloadSuccessful
+        self.__state = DownloadState.Successful
         self.__updateInfoLabel()
         self.__setDateTime()
         
@@ -588,9 +594,9 @@
         self.openButton.setEnabled(data["Done"])
         self.openButton.setVisible(data["Done"])
         if data["Done"]:
-            self.__state = DownloadItem.DownloadSuccessful
+            self.__state = DownloadState.Successful
         else:
-            self.__state = DownloadItem.DownloadCancelled
+            self.__state = DownloadState.Cancelled
         self.progressBar.setVisible(False)
         
         self.__adjustSize()
--- a/eric7/WebBrowser/VirusTotal/VirusTotalApi.py	Tue Aug 31 17:31:23 2021 +0200
+++ b/eric7/WebBrowser/VirusTotal/VirusTotalApi.py	Tue Aug 31 17:48:20 2021 +0200
@@ -369,13 +369,6 @@
         @param reply reference to the network reply
         @type QNetworkReply
         """
-        categoriesMapping = {
-            "bitdefender": ("BitDefender category",),
-            "sophos": ("sophos category", "Sophos category"),
-            "valkyrie": ("Comodo Valkyrie Verdict category",),
-            "alpha": ("alphaMountain.ai category",),
-            "forcepoint": ("Forcepoint ThreatSeeker category",),
-        }
         if reply.error() == QNetworkReply.NetworkError.NoError:
             result = json.loads(str(reply.readAll(), "utf-8"))
             if result["response_code"] == 0:
@@ -399,6 +392,14 @@
                     subdomains = result["subdomains"]
                 except KeyError:
                     subdomains = []
+                
+                categoriesMapping = {
+                    "bitdefender": ("BitDefender category",),
+                    "sophos": ("sophos category", "Sophos category"),
+                    "valkyrie": ("Comodo Valkyrie Verdict category",),
+                    "alpha": ("alphaMountain.ai category",),
+                    "forcepoint": ("Forcepoint ThreatSeeker category",),
+                }
                 categories = {}
                 for key, vtCategories in categoriesMapping.items():
                     for vtCategory in vtCategories:
@@ -411,17 +412,27 @@
                     whois = result["whois"]
                 except KeyError:
                     whois = ""
-                # TODO: add "Webutation domain info" with subdict
-                #   "Adult content" (yes/no)
-                #   "Safety score"  (0-100, integer)
-                #   "Verdict"       (string)
+                
+                webutationData = {
+                    "adult": "--",
+                    "safety": "--",
+                    "verdict": "--"
+                }
+                with contextlib.suppress(KeyError):
+                    webutation = result["Webutation domain info"]
+                    with contextlib.suppress(KeyError):
+                        webutationData["adult"] = webutation["Adult content"]
+                    with contextlib.suppress(KeyError):
+                        webutationData["safety"] = webutation["Safety score"]
+                    with contextlib.suppress(KeyError):
+                        webutationData["verdict"] = webutation["Verdict"]
                 
                 from .VirusTotalDomainReportDialog import (
                     VirusTotalDomainReportDialog
                 )
                 self.__domainReportDlg = VirusTotalDomainReportDialog(
                     self.__lastDomain, resolutions, urls, subdomains,
-                    categories, whois)
+                    categories, webutationData, whois)
                 self.__domainReportDlg.show()
         self.__replies.remove(reply)
         reply.deleteLater()
--- a/eric7/WebBrowser/VirusTotal/VirusTotalDomainReportDialog.py	Tue Aug 31 17:31:23 2021 +0200
+++ b/eric7/WebBrowser/VirusTotal/VirusTotalDomainReportDialog.py	Tue Aug 31 17:48:20 2021 +0200
@@ -20,7 +20,7 @@
     Class implementing a dialog to show the VirusTotal domain report.
     """
     def __init__(self, domain, resolutions, urls, subdomains,
-                 categories, whois, parent=None):
+                 categories, webutation, whois, parent=None):
         """
         Constructor
         
@@ -35,6 +35,8 @@
         @param categories dictionary with various categorizations with keys
             'bitdefender', 'sophos', 'valkyrie', 'alpha', 'forcepoint'
         @type dict
+        @param webutation dictionary with Webutation data with keys
+            'adult', 'safety', 'verdict'
         @param whois whois information
         @type str
         @param parent reference to the parent widget
@@ -82,6 +84,10 @@
         self.amLabel.setText(categories["alpha"])
         self.ftsLabel.setText(categories["forcepoint"])
         
+        self.webutationAdultLabel.setText(webutation["adult"])
+        self.webutationSafetyLabel.setText(str(webutation["safety"]))
+        self.webutationVerdictLabel.setText(webutation["verdict"])
+        
         self.__whois = whois
         self.__whoisDomain = domain
         self.whoisButton.setEnabled(bool(whois))
--- a/eric7/WebBrowser/VirusTotal/VirusTotalDomainReportDialog.ui	Tue Aug 31 17:31:23 2021 +0200
+++ b/eric7/WebBrowser/VirusTotal/VirusTotalDomainReportDialog.ui	Tue Aug 31 17:48:20 2021 +0200
@@ -7,7 +7,7 @@
     <x>0</x>
     <y>0</y>
     <width>900</width>
-    <height>750</height>
+    <height>700</height>
    </rect>
   </property>
   <property name="windowTitle">
@@ -48,14 +48,7 @@
     </widget>
    </item>
    <item>
-    <layout class="QGridLayout" name="gridLayout_2">
-     <item row="0" column="1">
-      <widget class="QPushButton" name="whoisButton">
-       <property name="text">
-        <string>Whois</string>
-       </property>
-      </widget>
-     </item>
+    <layout class="QGridLayout" name="gridLayout_3">
      <item row="0" column="0" rowspan="2">
       <widget class="QGroupBox" name="groupBox">
        <property name="sizePolicy">
@@ -186,18 +179,87 @@
        </layout>
       </widget>
      </item>
-     <item row="1" column="1">
-      <spacer name="verticalSpacer">
-       <property name="orientation">
-        <enum>Qt::Vertical</enum>
-       </property>
-       <property name="sizeHint" stdset="0">
+     <item row="0" column="1">
+      <widget class="QGroupBox" name="groupBox_2">
+       <property name="maximumSize">
         <size>
-         <width>20</width>
-         <height>108</height>
+         <width>300</width>
+         <height>16777215</height>
         </size>
        </property>
-      </spacer>
+       <property name="title">
+        <string notr="true">Webutation</string>
+       </property>
+       <layout class="QGridLayout" name="gridLayout_2">
+        <item row="0" column="0">
+         <widget class="QLabel" name="label_6">
+          <property name="text">
+           <string>Adult Content:</string>
+          </property>
+         </widget>
+        </item>
+        <item row="0" column="1">
+         <widget class="QLabel" name="webutationAdultLabel">
+          <property name="sizePolicy">
+           <sizepolicy hsizetype="Expanding" vsizetype="Preferred">
+            <horstretch>0</horstretch>
+            <verstretch>0</verstretch>
+           </sizepolicy>
+          </property>
+          <property name="text">
+           <string/>
+          </property>
+         </widget>
+        </item>
+        <item row="1" column="0">
+         <widget class="QLabel" name="label_7">
+          <property name="text">
+           <string>Safety Score:</string>
+          </property>
+         </widget>
+        </item>
+        <item row="1" column="1">
+         <widget class="QLabel" name="webutationSafetyLabel">
+          <property name="sizePolicy">
+           <sizepolicy hsizetype="Expanding" vsizetype="Preferred">
+            <horstretch>0</horstretch>
+            <verstretch>0</verstretch>
+           </sizepolicy>
+          </property>
+          <property name="text">
+           <string/>
+          </property>
+         </widget>
+        </item>
+        <item row="2" column="0">
+         <widget class="QLabel" name="label_8">
+          <property name="text">
+           <string>Verdict:</string>
+          </property>
+         </widget>
+        </item>
+        <item row="2" column="1">
+         <widget class="QLabel" name="webutationVerdictLabel">
+          <property name="sizePolicy">
+           <sizepolicy hsizetype="Expanding" vsizetype="Preferred">
+            <horstretch>0</horstretch>
+            <verstretch>0</verstretch>
+           </sizepolicy>
+          </property>
+          <property name="text">
+           <string/>
+          </property>
+         </widget>
+        </item>
+       </layout>
+      </widget>
+     </item>
+     <item row="1" column="1">
+      <widget class="QPushButton" name="whoisButton">
+       <property name="text">
+        <string notr="true">Whois</string>
+       </property>
+      </widget>
      </item>
     </layout>
    </item>

eric ide

mercurial