diff -r cc296ba99a3f -r 6f958d5765f4 WebBrowser/WebBrowserView.py --- a/WebBrowser/WebBrowserView.py Wed Nov 01 19:22:02 2017 +0100 +++ b/WebBrowser/WebBrowserView.py Fri Nov 03 12:10:16 2017 +0100 @@ -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 @@ -362,9 +362,10 @@ """ Public slot to clear the current selection. """ - if qVersionTuple() >= (5, 7, 0): + try: self.triggerPageAction(QWebEnginePage.Unselect) - else: + except AttributeError: + # prior to 5.7.0 self.page().runJavaScript( "window.getSelection().empty()", WebBrowserPage.SafeJsWorld) @@ -545,11 +546,11 @@ @type WebHitTestResult """ spellCheckActionCount = 0 - if qVersionTuple() >= (5, 7, 0): + if qVersionTuple() >= (5, 7, 0) and PYQT_VERSION >= 0x50700: 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 +802,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 +1724,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: