Fixed a few issues in the QWebEngine based web browser detected on Ubuntu 17.10.

Sat, 21 Oct 2017 19:17:27 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Sat, 21 Oct 2017 19:17:27 +0200
changeset 5920
e47dd106c3d6
parent 5919
d0de2b378b24
child 5921
d4797da58218

Fixed a few issues in the QWebEngine based web browser detected on Ubuntu 17.10.

Preferences/ConfigurationDialog.py file | annotate | diff | comparison | revisions
WebBrowser/Download/DownloadItem.py file | annotate | diff | comparison | revisions
WebBrowser/WebBrowserView.py file | annotate | diff | comparison | revisions
WebBrowser/WebBrowserWindow.py file | annotate | diff | comparison | revisions
--- a/Preferences/ConfigurationDialog.py	Sat Oct 21 15:18:15 2017 +0200
+++ b/Preferences/ConfigurationDialog.py	Sat Oct 21 19:17:27 2017 +0200
@@ -12,7 +12,7 @@
 import os
 import types
 
-from PyQt5.QtCore import QMetaObject, pyqtSignal, Qt, QRect, pyqtSlot
+from PyQt5.QtCore import pyqtSignal, pyqtSlot, PYQT_VERSION, Qt, QMetaObject, QRect
 from PyQt5.QtGui import QPixmap
 from PyQt5.QtWidgets import QSizePolicy, QSpacerItem, QWidget, QTreeWidget, \
     QStackedWidget, QDialog, QSplitter, QScrollArea, QApplication, \
@@ -346,7 +346,7 @@
                     [self.tr("VirusTotal Interface"), "virustotal.png",
                      "HelpVirusTotalPage", "0webBrowserPage", None],
                 })
-                if qVersionTuple() >= (5, 8, 0):
+                if qVersionTuple() >= (5, 8, 0) and PYQT_VERSION >= 0x50800:
                     self.configItems.update({
                         "webBrowserSpellCheckingPage":
                         [self.tr("Spell checking"),
@@ -470,7 +470,7 @@
                  "HelpVirusTotalPage", None, None],
             }
             
-            if qVersionTuple() >= (5, 8, 0):
+            if qVersionTuple() >= (5, 8, 0) and PYQT_VERSION >= 0x50800:
                 self.configItems.update({
                     "webBrowserSpellCheckingPage":
                     [self.tr("Spell checking"),
--- a/WebBrowser/Download/DownloadItem.py	Sat Oct 21 15:18:15 2017 +0200
+++ b/WebBrowser/Download/DownloadItem.py	Sat Oct 21 19:17:27 2017 +0200
@@ -11,7 +11,7 @@
 
 import os
 
-from PyQt5.QtCore import pyqtSlot, pyqtSignal, Qt, QTime, QUrl, \
+from PyQt5.QtCore import pyqtSlot, pyqtSignal, PYQT_VERSION, Qt, QTime, QUrl, \
     QStandardPaths, QFileInfo
 from PyQt5.QtGui import QPalette, QDesktopServices
 from PyQt5.QtWidgets import QWidget, QStyle, QDialog
@@ -130,10 +130,10 @@
         if self.__gettingFileName:
             return
         
-        if qVersionTuple() >= (5, 8, 0):
+        if qVersionTuple() >= (5, 8, 0) and PYQT_VERSION >= 0x50800:
             savePage = self.__downloadItem.type() == \
                 QWebEngineDownloadItem.SavePage
-        elif qVersionTuple() >= (5, 7, 0):
+        elif qVersionTuple() >= (5, 7, 0) and PYQT_VERSION >= 0x50700:
             savePage = self.__downloadItem.savePageFormat() != \
                 QWebEngineDownloadItem.UnknownSaveFormat
         else:
--- a/WebBrowser/WebBrowserView.py	Sat Oct 21 15:18:15 2017 +0200
+++ b/WebBrowser/WebBrowserView.py	Sat Oct 21 19:17:27 2017 +0200
@@ -16,9 +16,9 @@
 
 import os
 
-from PyQt5.QtCore import pyqtSignal, QUrl, QFileInfo, Qt, QTimer, QEvent, \
-    QPoint, QPointF, QDateTime, QStandardPaths, QByteArray, QIODevice, \
-    QDataStream
+from PyQt5.QtCore import pyqtSignal, PYQT_VERSION, Qt, QUrl, QFileInfo, \
+    QTimer, QEvent, QPoint, QPointF, QDateTime, QStandardPaths, QByteArray, \
+    QIODevice, QDataStream
 from PyQt5.QtGui import QDesktopServices, QClipboard, QIcon, \
     QContextMenuEvent, QPixmap
 from PyQt5.QtWidgets import qApp, QStyle, QMenu, QApplication
@@ -549,7 +549,7 @@
             contextMenuData = self.page().contextMenuData()
             hitTest.updateWithContextMenuData(contextMenuData)
             
-            if qVersionTuple() >= (5, 8, 0) and \
+            if qVersionTuple() >= (5, 8, 0) and PYQT_VERSION >= 0x50800 and \
                bool(contextMenuData.misspelledWord()):
                 boldFont = menu.font()
                 boldFont.setBold(True)
@@ -801,7 +801,7 @@
             language = languages[0]
             langCode = language.split("[")[1][:2]
             googleTranslatorUrl = QUrl(
-                "http://translate.google.com/#auto|{0}|{1}".format(
+                "http://translate.google.com/#auto/{0}/{1}".format(
                     langCode, self.selectedText()))
             menu.addAction(
                 UI.PixmapCache.getIcon("translate.png"),
@@ -1723,7 +1723,7 @@
         if url.isEmpty():
             return
         
-        if qVersionTuple() >= (5, 8, 0):
+        if qVersionTuple() >= (5, 8, 0) and PYQT_VERSION >= 0x50800:
             # since Qt 5.8.0
             fileName, savePageFormat = self.__getSavePageFileNameAndFormat()
             if fileName:
--- a/WebBrowser/WebBrowserWindow.py	Sat Oct 21 15:18:15 2017 +0200
+++ b/WebBrowser/WebBrowserWindow.py	Sat Oct 21 19:17:27 2017 +0200
@@ -3248,11 +3248,14 @@
                 profile.setHttpCacheType(QWebEngineProfile.MemoryHttpCache)
                 profile.setHttpCacheMaximumSize(0)
         
-        if qVersionTuple() >= (5, 8, 0):
+        try:
             profile.setSpellCheckEnabled(
                 Preferences.getWebBrowser("SpellCheckEnabled"))
             profile.setSpellCheckLanguages(
                 Preferences.getWebBrowser("SpellCheckLanguages"))
+        except AttributeError:
+            # not yet supported
+            pass
         
         self.__virusTotal.preferencesChanged()
         if not Preferences.getWebBrowser("VirusTotalEnabled") or \
@@ -4845,11 +4848,14 @@
                 cls._webProfile.setPersistentCookiesPolicy(
                     QWebEngineProfile.AllowPersistentCookies)
             
-            if qVersionTuple() >= (5, 8, 0):
+            try:
                 cls._webProfile.setSpellCheckEnabled(
                     Preferences.getWebBrowser("SpellCheckEnabled"))
                 cls._webProfile.setSpellCheckLanguages(
                     Preferences.getWebBrowser("SpellCheckLanguages"))
+            except AttributeError:
+                # not yet supported
+                pass
             
             # Setup QWebChannel user script
             from .WebBrowserPage import WebBrowserPage

eric ide

mercurial