Continued porting the web browser. QtWebEngine

Tue, 29 Mar 2016 16:34:32 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Tue, 29 Mar 2016 16:34:32 +0200
branch
QtWebEngine
changeset 4907
1e3d61349671
parent 4906
939ff20f712d
child 4908
f1859c36d564

Continued porting the web browser.

- enabled the new web browser as a help viewer in the eric IDE

Documentation/Help/source.qch file | annotate | diff | comparison | revisions
Preferences/ConfigurationPages/HelpViewersPage.py file | annotate | diff | comparison | revisions
Preferences/__init__.py file | annotate | diff | comparison | revisions
UI/UserInterface.py file | annotate | diff | comparison | revisions
WebBrowser/Tools/WebIconProvider.py file | annotate | diff | comparison | revisions
WebBrowser/WebBrowserWindow.py file | annotate | diff | comparison | revisions
Binary file Documentation/Help/source.qch has changed
--- a/Preferences/ConfigurationPages/HelpViewersPage.py	Tue Mar 29 10:32:22 2016 +0200
+++ b/Preferences/ConfigurationPages/HelpViewersPage.py	Tue Mar 29 16:34:32 2016 +0200
@@ -9,7 +9,21 @@
 
 from __future__ import unicode_literals
 
+from PyQt5.QtCore import qVersion
 from PyQt5.QtWidgets import QButtonGroup
+try:
+    from PyQt5 import QtWebKit      # __IGNORE_WARNING__
+    WEBKIT_AVAILABLE = True
+except ImportError:
+    WEBKIT_AVAILABLE = False
+if qVersion() < "5.6.0":
+    WEBENGINE_AVAILABLE = False
+else:
+    try:
+        from PyQt5 import QtWebEngineWidgets    # __IGNORE_WARNING__
+        WEBENGINE_AVAILABLE = True
+    except ImportError:
+        WEBENGINE_AVAILABLE = False
 
 from E5Gui.E5PathPicker import E5PathPickerModes
 
@@ -40,14 +54,14 @@
         self.helpViewerGroup.addButton(self.customViewerButton)
         
         # set initial values
-        hvId = Preferences.getHelp("HelpViewerType")
-        # check availability of QtWebKit
-        try:
-            from PyQt5 import QtWebKit      # __IGNORE_WARNING__
-        except ImportError:
-            # not available, reset help viewer to default
+        if WEBENGINE_AVAILABLE:
+            hvId = Preferences.getWebBrowser("HelpViewerType")
+        else:
+            hvId = Preferences.getHelp("HelpViewerType")
+        if not WEBENGINE_AVAILABLE and not WEBKIT_AVAILABLE:
             if hvId == 1:
-                hvId = Preferences.Prefs.helpDefaults["HelpViewerType"]
+                hvId = Preferences.Prefs.webBrowserDefaultsDefaults[
+                    "HelpViewerType"]
             self.helpBrowserButton.setEnabled(False)
         
         if hvId == 1:
@@ -74,6 +88,7 @@
         elif self.customViewerButton.isChecked():
             hvId = 4
         Preferences.setHelp("HelpViewerType", hvId)
+        Preferences.setWebBrowser("HelpViewerType", hvId)
         Preferences.setHelp(
             "CustomViewer",
             self.customViewerPicker.text())
--- a/Preferences/__init__.py	Tue Mar 29 10:32:22 2016 +0200
+++ b/Preferences/__init__.py	Tue Mar 29 16:34:32 2016 +0200
@@ -1075,6 +1075,10 @@
         # PIM:                  identical to helpDefaults
         # VirusTotal:           identical to helpDefaults
     }
+    if QWebEngineSettings:
+        webBrowserDefaults["HelpViewerType"] = 1      # eric browser
+    else:
+        webBrowserDefaults["HelpViewerType"] = 2      # Qt Assistant
     
     @classmethod
     def initWebEngineSettingsDefaults(cls):
@@ -2773,17 +2777,14 @@
         from Utilities.crypto import pwConvert
         return pwConvert(prefClass.settings.value(
             "WebBrowser/" + key, prefClass.helpDefaults[key]), encode=False)
-    # TODO: QtHelp
-##    elif key == "HelpViewerType":
-##        # special treatment to adjust for missing QtWebKit
-##        value = int(prefClass.settings.value(
-##            "WebBrowser/" + key, prefClass.helpDefaults[key]))
-##        if QWebSettings is None:
-##            value = prefClass.helpDefaults[key]
-##        return value
-##    elif key in ["StartupBehavior",
-##                 "OfflineStorageDatabaseQuota",
-##                 "OfflineWebApplicationCacheQuota", "CachePolicy",
+    elif key == "HelpViewerType":
+        # special treatment to adjust for missing QtWebEngine
+        value = int(prefClass.settings.value(
+            "WebBrowser/" + key, prefClass.helpDefaults[key]))
+        if QWebEngineSettings is None:
+            value = prefClass.helpDefaults[key]
+        return value
+##    elif key in [ "CachePolicy",
 ##                  ]:
     elif key in ["StartupBehavior", "HistoryLimit",
                  "DownloadManagerRemovePolicy","SyncType", "SyncFtpPort",
@@ -2796,9 +2797,7 @@
                  ]:
         return int(prefClass.settings.value(
             "WebBrowser/" + key, prefClass.webBrowserDefaults[key]))
-##    elif key in ["PrintBackgrounds",
-##                 "JavaEnabled",
-##                 "JavaScriptCanCloseWindows",
+##    elif key in ["JavaScriptCanCloseWindows",
 ##                 "DnsPrefetchEnabled",
 ##                 "OfflineStorageDatabaseEnabled",
 ##                 "OfflineWebApplicationCacheEnabled", "LocalStorageEnabled",
--- a/UI/UserInterface.py	Tue Mar 29 10:32:22 2016 +0200
+++ b/UI/UserInterface.py	Tue Mar 29 16:34:32 2016 +0200
@@ -4864,7 +4864,10 @@
         if home.endswith(".chm"):
             self.__chmViewer(home)
         else:
-            hvType = Preferences.getHelp("HelpViewerType")
+            if WEBENGINE_AVAILABLE:
+                hvType = Preferences.getWebBrowser("HelpViewerType")
+            else:
+                hvType = Preferences.getHelp("HelpViewerType")
             if hvType == 1:
                 self.launchHelpViewer(home)
             elif hvType == 2:
@@ -4923,7 +4926,10 @@
         if home.endswith(".chm"):
             self.__chmViewer(home)
         else:
-            hvType = Preferences.getHelp("HelpViewerType")
+            if WEBENGINE_AVAILABLE:
+                hvType = Preferences.getWebBrowser("HelpViewerType")
+            else:
+                hvType = Preferences.getHelp("HelpViewerType")
             if hvType == 1:
                 self.launchHelpViewer(home)
             elif hvType == 2:
@@ -4989,7 +4995,10 @@
             else:
                 home = "file://" + home
         
-        hvType = Preferences.getHelp("HelpViewerType")
+        if WEBENGINE_AVAILABLE:
+            hvType = Preferences.getWebBrowser("HelpViewerType")
+        else:
+            hvType = Preferences.getHelp("HelpViewerType")
         if hvType == 1:
             self.launchHelpViewer(home)
         elif hvType == 2:
@@ -5051,7 +5060,10 @@
         else:
             home = pyqt4DocDir
         
-        hvType = Preferences.getHelp("HelpViewerType")
+        if WEBENGINE_AVAILABLE:
+            hvType = Preferences.getWebBrowser("HelpViewerType")
+        else:
+            hvType = Preferences.getHelp("HelpViewerType")
         if hvType == 1:
             self.launchHelpViewer(home)
         elif hvType == 2:
@@ -5115,7 +5127,10 @@
         else:
             home = pyqt5DocDir
         
-        hvType = Preferences.getHelp("HelpViewerType")
+        if WEBENGINE_AVAILABLE:
+            hvType = Preferences.getWebBrowser("HelpViewerType")
+        else:
+            hvType = Preferences.getHelp("HelpViewerType")
         if hvType == 1:
             self.launchHelpViewer(home)
         elif hvType == 2:
@@ -5152,7 +5167,10 @@
             else:
                 home = "file://" + home
         
-        hvType = Preferences.getHelp("HelpViewerType")
+        if WEBENGINE_AVAILABLE:
+            hvType = Preferences.getWebBrowser("HelpViewerType")
+        else:
+            hvType = Preferences.getHelp("HelpViewerType")
         if hvType == 1:
             self.launchHelpViewer(home)
         elif hvType == 2:
@@ -5204,7 +5222,10 @@
         else:
             home = pysideDocDir
         
-        hvType = Preferences.getHelp("HelpViewerType")
+        if WEBENGINE_AVAILABLE:
+            hvType = Preferences.getWebBrowser("HelpViewerType")
+        else:
+            hvType = Preferences.getHelp("HelpViewerType")
         if hvType == 1:
             self.launchHelpViewer(home)
         elif hvType == 2:
--- a/WebBrowser/Tools/WebIconProvider.py	Tue Mar 29 10:32:22 2016 +0200
+++ b/WebBrowser/Tools/WebIconProvider.py	Tue Mar 29 16:34:32 2016 +0200
@@ -185,9 +185,20 @@
         self.load()
         
         urlStr = self.__urlToString(url)
-        if urlStr in self.__iconsDB:
-            return self.__iconsDB[urlStr]
-        elif scheme == "https":
+        for iconUrlStr in self.__iconsDB:
+            if iconUrlStr.startswith(urlStr):
+                return self.__iconsDB[iconUrlStr]
+        
+        # try replacing http scheme with https scheme
+        url = QUrl(url)
+        if url.scheme() == "http":
+            url.setScheme("https")
+        urlStr = self.__urlToString(url)
+        for iconUrlStr in self.__iconsDB:
+            if iconUrlStr.startswith(urlStr):
+                return self.__iconsDB[iconUrlStr]
+        
+        if scheme == "https":
             return UI.PixmapCache.getIcon("securityHigh32.png")
         else:
             return UI.PixmapCache.getIcon("defaultIcon.png")
--- a/WebBrowser/WebBrowserWindow.py	Tue Mar 29 10:32:22 2016 +0200
+++ b/WebBrowser/WebBrowserWindow.py	Tue Mar 29 16:34:32 2016 +0200
@@ -140,6 +140,8 @@
         self.__eventKeyboardModifiers = Qt.NoModifier
         
         if self.__initShortcutsOnly:
+            WebBrowserWindow.setUseQtHelp(
+                self.__fromEric or qthelp or bool(searchWord))
             self.__initActions()
         else:
             if Preferences.getWebBrowser("WebInspectorEnabled"):
@@ -169,10 +171,9 @@
                 self.setStyle(Preferences.getUI("Style"),
                               Preferences.getUI("StyleSheet"))
                 
-                # TODO: Check if this is needed with QtWebEngine
                 # initialize some SSL stuff
-##                from E5Network.E5SslUtilities import initSSL
-##                initSSL()
+                from E5Network.E5SslUtilities import initSSL
+                initSSL()
             
             if WebBrowserWindow.useQtHelp:
                 self.__helpEngine = QHelpEngine(

eric ide

mercurial