7 """ |
7 """ |
8 Module implementing the helpbrowser using QWebView. |
8 Module implementing the helpbrowser using QWebView. |
9 """ |
9 """ |
10 |
10 |
11 from PyQt5.QtCore import ( |
11 from PyQt5.QtCore import ( |
12 pyqtSlot, pyqtSignal, QUrl, QUrlQuery, QTimer, QEventLoop, QPoint, QPointF |
12 pyqtSlot, pyqtSignal, QUrl, QUrlQuery, QTimer, QEventLoop, QPoint, QPointF, |
|
13 QT_VERSION |
13 ) |
14 ) |
14 from PyQt5.QtGui import QDesktopServices |
15 from PyQt5.QtGui import QDesktopServices |
15 from PyQt5.QtWebEngineWidgets import ( |
16 from PyQt5.QtWebEngineWidgets import ( |
16 QWebEnginePage, QWebEngineSettings, QWebEngineScript |
17 QWebEnginePage, QWebEngineSettings, QWebEngineScript |
17 ) |
18 ) |
|
19 try: |
|
20 from PyQt5.QtWebEngine import PYQT_WEBENGINE_VERSION |
|
21 except AttributeError: |
|
22 PYQT_WEBENGINE_VERSION = QT_VERSION |
18 from PyQt5.QtWebChannel import QWebChannel |
23 from PyQt5.QtWebChannel import QWebChannel |
19 |
24 |
20 from E5Gui import E5MessageBox |
25 from E5Gui import E5MessageBox |
21 |
26 |
22 from WebBrowser.WebBrowserWindow import WebBrowserWindow |
27 from WebBrowser.WebBrowserWindow import WebBrowserWindow |
122 if url.scheme() == "abp": |
127 if url.scheme() == "abp": |
123 if WebBrowserWindow.adBlockManager().addSubscriptionFromUrl(url): |
128 if WebBrowserWindow.adBlockManager().addSubscriptionFromUrl(url): |
124 return False |
129 return False |
125 |
130 |
126 # GreaseMonkey |
131 # GreaseMonkey |
127 if ( |
132 if PYQT_WEBENGINE_VERSION >= 0x50e00: # PyQtWebEngine >= 5.14.0 |
128 type_ == QWebEnginePage.NavigationTypeLinkClicked and |
133 navigationType = type_ in [ |
129 url.toString().endswith(".user.js") |
134 QWebEnginePage.NavigationTypeLinkClicked, |
130 ): |
135 QWebEnginePage.NavigationTypeRedirect |
|
136 ] |
|
137 else: |
|
138 navigationType = type_ == QWebEnginePage.NavigationTypeLinkClicked |
|
139 if navigationType and url.toString().endswith(".user.js"): |
131 WebBrowserWindow.greaseMonkeyManager().downloadScript(url) |
140 WebBrowserWindow.greaseMonkeyManager().downloadScript(url) |
132 return False |
141 return False |
133 |
142 |
134 if url.scheme() == "eric": |
143 if url.scheme() == "eric": |
135 if url.path() == "AddSearchProvider": |
144 if url.path() == "AddSearchProvider": |
177 WebBrowserWindow.safeBrowsingManager() |
186 WebBrowserWindow.safeBrowsingManager() |
178 .getThreatType(threatLists[0]) |
187 .getThreatType(threatLists[0]) |
179 ) |
188 ) |
180 self.safeBrowsingBad.emit(threatType, "".join(threatMessages)) |
189 self.safeBrowsingBad.emit(threatType, "".join(threatMessages)) |
181 |
190 |
182 result = QWebEnginePage.acceptNavigationRequest(self, url, type_, |
191 result = QWebEnginePage.acceptNavigationRequest( |
183 isMainFrame) |
192 self, url, type_, isMainFrame) |
184 |
193 |
185 if result: |
194 if result: |
186 if isMainFrame: |
195 if isMainFrame: |
187 isWeb = url.scheme() in ("http", "https", "ftp", "ftps", |
196 isWeb = url.scheme() in ("http", "https", "ftp", "ftps", |
188 "file") |
197 "file") |