Some minor changes in the web browser.

Sun, 11 Feb 2018 19:51:10 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Sun, 11 Feb 2018 19:51:10 +0100
changeset 6137
27962f3f457f
parent 6136
dfef226f9c7f
child 6138
b235f6fe5c9f

Some minor changes in the web browser.

WebBrowser/WebBrowserPage.py file | annotate | diff | comparison | revisions
WebBrowser/WebBrowserWindow.py file | annotate | diff | comparison | revisions
diff -r dfef226f9c7f -r 27962f3f457f WebBrowser/WebBrowserPage.py
--- a/WebBrowser/WebBrowserPage.py	Sun Feb 11 18:28:09 2018 +0100
+++ b/WebBrowser/WebBrowserPage.py	Sun Feb 11 19:51:10 2018 +0100
@@ -78,6 +78,16 @@
         
         self.__printer = None
         self.__badSite = False
+        
+##    // Workaround for broken load started/finished signals in QtWebEngine 5.10
+##    if (qstrcmp(qVersion(), "5.10.0") == 0) {
+##        connect(this, &QWebEnginePage::loadProgress, this, [this](int progress) {
+##            if (progress == 100) {
+##                emit loadFinished(true);
+##            }
+##        });
+##    }
+##
     
     def acceptNavigationRequest(self, url, type_, isMainFrame):
         """
@@ -139,8 +149,21 @@
                     .getThreatType(threatLists[0])
                 self.safeBrowsingBad.emit(threatType, "".join(threatMessages))
         
-        return QWebEnginePage.acceptNavigationRequest(self, url, type_,
-                                                      isMainFrame)
+        result = QWebEnginePage.acceptNavigationRequest(self, url, type_,
+                                                        isMainFrame)
+        
+        if result and isMainFrame:
+            isWeb = url.scheme() in ("http", "https", "ftp", "ftps", "file")
+            globalJsEnabled = WebBrowserWindow.webSettings().testAttribute(
+                QWebEngineSettings.JavascriptEnabled)
+            if isWeb:
+                enable = globalJsEnabled
+            else:
+                enable = True
+            self.settings().setAttribute(
+                QWebEngineSettings.JavascriptEnabled, enable)
+        
+        return result
     
     @pyqtSlot(QUrl)
     def __urlChanged(self, url):
diff -r dfef226f9c7f -r 27962f3f457f WebBrowser/WebBrowserWindow.py
--- a/WebBrowser/WebBrowserWindow.py	Sun Feb 11 18:28:09 2018 +0100
+++ b/WebBrowser/WebBrowserWindow.py	Sun Feb 11 19:51:10 2018 +0100
@@ -570,6 +570,7 @@
         settings.setAttribute(
             QWebEngineSettings.AutoLoadImages,
             Preferences.getWebBrowser("AutoLoadImages"))
+        # TODO: make this configurable as it is overwritten for pages that need it enabled
         settings.setAttribute(
             QWebEngineSettings.JavascriptEnabled,
             True)

eric ide

mercurial