eric6/WebBrowser/WebBrowserPage.py

branch
without_py2_and_pyqt4
changeset 7201
6b42677d7043
parent 7192
a22eee00b052
child 7229
53054eb5b15a
equal deleted inserted replaced
7200:ebab8ba287e6 7201:6b42677d7043
25 25
26 from .Tools.WebHitTestResult import WebHitTestResult 26 from .Tools.WebHitTestResult import WebHitTestResult
27 from .Tools import Scripts 27 from .Tools import Scripts
28 28
29 import Preferences 29 import Preferences
30 from Globals import qVersionTuple
31 30
32 31
33 class WebBrowserPage(QWebEnginePage): 32 class WebBrowserPage(QWebEnginePage):
34 """ 33 """
35 Class implementing an enhanced web page. 34 Class implementing an enhanced web page.
41 @signal printPageRequested() emitted to indicate a print request of the 40 @signal printPageRequested() emitted to indicate a print request of the
42 shown web page 41 shown web page
43 @signal navigationRequestAccepted(url, navigation type, main frame) emitted 42 @signal navigationRequestAccepted(url, navigation type, main frame) emitted
44 to signal an accepted navigation request 43 to signal an accepted navigation request
45 """ 44 """
46 if qVersionTuple() >= (5, 7, 0): 45 SafeJsWorld = QWebEngineScript.ApplicationWorld
47 SafeJsWorld = QWebEngineScript.ApplicationWorld 46 # SafeJsWorld = QWebEngineScript.MainWorld
48 # SafeJsWorld = QWebEngineScript.MainWorld
49 else:
50 SafeJsWorld = QWebEngineScript.MainWorld
51 UnsafeJsWorld = QWebEngineScript.MainWorld 47 UnsafeJsWorld = QWebEngineScript.MainWorld
52 48
53 safeBrowsingAbort = pyqtSignal() 49 safeBrowsingAbort = pyqtSignal()
54 safeBrowsingBad = pyqtSignal(str, str) 50 safeBrowsingBad = pyqtSignal(str, str)
55 51
77 url, auth, self)) 73 url, auth, self))
78 self.proxyAuthenticationRequired.connect( 74 self.proxyAuthenticationRequired.connect(
79 WebBrowserWindow.networkManager().proxyAuthentication) 75 WebBrowserWindow.networkManager().proxyAuthentication)
80 self.fullScreenRequested.connect(self.__fullScreenRequested) 76 self.fullScreenRequested.connect(self.__fullScreenRequested)
81 self.urlChanged.connect(self.__urlChanged) 77 self.urlChanged.connect(self.__urlChanged)
82 78 self.contentsSizeChanged.connect(self.__contentsSizeChanged)
83 try:
84 self.contentsSizeChanged.connect(self.__contentsSizeChanged)
85 except AttributeError:
86 # defined for Qt >= 5.7
87 pass
88 79
89 try: 80 try:
90 self.registerProtocolHandlerRequested.connect( 81 self.registerProtocolHandlerRequested.connect(
91 self.__registerProtocolHandlerRequested) 82 self.__registerProtocolHandlerRequested)
92 except AttributeError: 83 except AttributeError:
306 @type int 297 @type int
307 @param callback callback function to be executed when the script has 298 @param callback callback function to be executed when the script has
308 ended 299 ended
309 @type function 300 @type function
310 """ 301 """
311 if qVersionTuple() >= (5, 7, 0) and worldId > -1: 302 if worldId > -1:
312 if callback is None: 303 if callback is None:
313 QWebEnginePage.runJavaScript(self, script, worldId) 304 QWebEnginePage.runJavaScript(self, script, worldId)
314 else: 305 else:
315 QWebEnginePage.runJavaScript(self, script, worldId, callback) 306 QWebEnginePage.runJavaScript(self, script, worldId, callback)
316 else: 307 else:

eric ide

mercurial