eric6/WebBrowser/WebBrowserView.py

branch
maintenance
changeset 8043
0acf98cd089a
parent 7939
0fc1df79965d
parent 7960
e8fc383322f7
child 8176
31965986ecd1
--- a/eric6/WebBrowser/WebBrowserView.py	Sun Jan 17 13:53:08 2021 +0100
+++ b/eric6/WebBrowser/WebBrowserView.py	Mon Feb 01 10:38:16 2021 +0100
@@ -38,7 +38,6 @@
 import Preferences
 import UI.PixmapCache
 import Utilities
-from Globals import qVersionTuple
 
 
 class WebBrowserView(QWebEngineView):
@@ -138,12 +137,6 @@
         if self.parentWidget() is not None:
             self.parentWidget().installEventFilter(self)
         
-        if qVersionTuple() < (5, 11, 0):
-            lay = self.layout()
-            lay.currentChanged.connect(
-                lambda: QTimer.singleShot(0, self.__setRwhvqt))
-            self.__setRwhvqt()
-        
         self.grabGesture(Qt.PinchGesture)
     
     def __createNewPage(self):
@@ -274,7 +267,7 @@
             if not QFileInfo(name.toLocalFile()).exists():
                 E5MessageBox.critical(
                     self,
-                    self.tr("eric6 Web Browser"),
+                    self.tr("eric Web Browser"),
                     self.tr(
                         """<p>The file <b>{0}</b> does not exist.</p>""")
                     .format(name.toLocalFile()))
@@ -285,7 +278,7 @@
                 if not started:
                     E5MessageBox.critical(
                         self,
-                        self.tr("eric6 Web Browser"),
+                        self.tr("eric Web Browser"),
                         self.tr(
                             """<p>Could not start a viewer"""
                             """ for file <b>{0}</b>.</p>""")
@@ -296,7 +289,7 @@
             if not started:
                 E5MessageBox.critical(
                     self,
-                    self.tr("eric6 Web Browser"),
+                    self.tr("eric Web Browser"),
                     self.tr(
                         """<p>Could not start an application"""
                         """ for URL <b>{0}</b>.</p>""")
@@ -308,7 +301,7 @@
                 if not started:
                     E5MessageBox.critical(
                         self,
-                        self.tr("eric6 Web Browser"),
+                        self.tr("eric Web Browser"),
                         self.tr(
                             """<p>Could not start a viewer"""
                             """ for file <b>{0}</b>.</p>""")
@@ -451,7 +444,7 @@
         Public method to set the zoom value.
         
         @param value zoom value (integer)
-        @keyparam saveValue flag indicating to save the zoom value with the
+        @param saveValue flag indicating to save the zoom value with the
             zoom manager
         @type bool
         """
@@ -583,14 +576,10 @@
             self.__menu.addSeparator()
             self.__menu.addAction(self.__mw.adBlockIcon().menuAction())
         
-        if (
-            qVersionTuple() >= (5, 11, 0) or
-            Preferences.getWebBrowser("WebInspectorEnabled")
-        ):
-            self.__menu.addSeparator()
-            self.__menu.addAction(
-                UI.PixmapCache.getIcon("webInspector"),
-                self.tr("Inspect Element..."), self.__webInspector)
+        self.__menu.addSeparator()
+        self.__menu.addAction(
+            UI.PixmapCache.getIcon("webInspector"),
+            self.tr("Inspect Element..."), self.__webInspector)
         
         if not self.__menu.isEmpty():
             pos = evt.globalPos()
@@ -1571,8 +1560,7 @@
         
         # find the render widget receiving events for the web page
         if obj is self and evt.type() == QEvent.ChildAdded:
-            if qVersionTuple() >= (5, 11, 0):
-                QTimer.singleShot(0, self.__setRwhvqt)
+            QTimer.singleShot(0, self.__setRwhvqt)
         
         # forward events to WebBrowserView
         if (
@@ -2277,70 +2265,68 @@
     ## Methods below implement slots for Qt 5.11+
     ###########################################################################
     
-    if qVersionTuple() >= (5, 11, 0):
-        @pyqtSlot("QWebEngineQuotaRequest")
-        def __quotaRequested(self, quotaRequest):
-            """
-            Private slot to handle quota requests of the web page.
+    @pyqtSlot("QWebEngineQuotaRequest")
+    def __quotaRequested(self, quotaRequest):
+        """
+        Private slot to handle quota requests of the web page.
+        
+        @param quotaRequest reference to the quota request object
+        @type QWebEngineQuotaRequest
+        """
+        acceptRequest = Preferences.getWebBrowser("AcceptQuotaRequest")
+        # map yes/no/ask from (0, 1, 2)
+        if acceptRequest == 0:
+            # always yes
+            ok = True
+        elif acceptRequest == 1:
+            # always no
+            ok = False
+        else:
+            # ask user
+            from .Download.DownloadUtilities import dataString
+            sizeStr = dataString(quotaRequest.requestedSize())
             
-            @param quotaRequest reference to the quota request object
-            @type QWebEngineQuotaRequest
-            """
-            acceptRequest = Preferences.getWebBrowser("AcceptQuotaRequest")
-            # map yes/no/ask from (0, 1, 2)
-            if acceptRequest == 0:
-                # always yes
-                ok = True
-            elif acceptRequest == 1:
-                # always no
-                ok = False
-            else:
-                # ask user
-                from .Download.DownloadUtilities import dataString
-                sizeStr = dataString(quotaRequest.requestedSize())
-                
-                ok = E5MessageBox.yesNo(
-                    self,
-                    self.tr("Quota Request"),
-                    self.tr("""<p> Allow the website at <b>{0}</b> to use"""
-                            """ <b>{1}</b> of persistent storage?</p>""")
-                    .format(quotaRequest.origin().host(), sizeStr)
-                )
-            
-            if ok:
-                quotaRequest.accept()
-            else:
-                quotaRequest.reject()
+            ok = E5MessageBox.yesNo(
+                self,
+                self.tr("Quota Request"),
+                self.tr("""<p> Allow the website at <b>{0}</b> to use"""
+                        """ <b>{1}</b> of persistent storage?</p>""")
+                .format(quotaRequest.origin().host(), sizeStr)
+            )
+        
+        if ok:
+            quotaRequest.accept()
+        else:
+            quotaRequest.reject()
     
     ###########################################################################
     ## Methods below implement slots for Qt 5.12+
     ###########################################################################
     
-    if qVersionTuple() >= (5, 12, 0):
-        @pyqtSlot("QWebEngineClientCertificateSelection")
-        def __selectClientCertificate(self, clientCertificateSelection):
-            """
-            Private slot to handle the client certificate selection request.
+    @pyqtSlot("QWebEngineClientCertificateSelection")
+    def __selectClientCertificate(self, clientCertificateSelection):
+        """
+        Private slot to handle the client certificate selection request.
+        
+        @param clientCertificateSelection list of client SSL certificates
+            found in system's client certificate store
+        @type QWebEngineClientCertificateSelection
+        """
+        certificates = clientCertificateSelection.certificates()
+        if len(certificates) == 0:
+            clientCertificateSelection.selectNone()
+        elif len(certificates) == 1:
+            clientCertificateSelection.select(certificates[0])
+        else:
+            certificate = None
+            from E5Network.E5SslCertificateSelectionDialog import (
+                E5SslCertificateSelectionDialog
+            )
+            dlg = E5SslCertificateSelectionDialog(certificates, self)
+            if dlg.exec() == QDialog.Accepted:
+                certificate = dlg.getSelectedCertificate()
             
-            @param clientCertificateSelection list of client SSL certificates
-                found in system's client certificate store
-            @type QWebEngineClientCertificateSelection
-            """
-            certificates = clientCertificateSelection.certificates()
-            if len(certificates) == 0:
+            if certificate is None:
                 clientCertificateSelection.selectNone()
-            elif len(certificates) == 1:
-                clientCertificateSelection.select(certificates[0])
             else:
-                certificate = None
-                from E5Network.E5SslCertificateSelectionDialog import (
-                    E5SslCertificateSelectionDialog
-                )
-                dlg = E5SslCertificateSelectionDialog(certificates, self)
-                if dlg.exec() == QDialog.Accepted:
-                    certificate = dlg.getSelectedCertificate()
-                
-                if certificate is None:
-                    clientCertificateSelection.selectNone()
-                else:
-                    clientCertificateSelection.select(certificate)
+                clientCertificateSelection.select(certificate)

eric ide

mercurial