WebBrowser/WebBrowserPage.py

changeset 5785
7c7c5f9e4fad
parent 5784
362bbcc49ac1
child 5829
d3448873ced3
equal deleted inserted replaced
5784:362bbcc49ac1 5785:7c7c5f9e4fad
12 try: 12 try:
13 str = unicode # __IGNORE_EXCEPTION__ 13 str = unicode # __IGNORE_EXCEPTION__
14 except NameError: 14 except NameError:
15 pass 15 pass
16 16
17 from PyQt5.QtCore import pyqtSlot, QUrl, QTimer, QEventLoop, QPoint, QPointF, \ 17 from PyQt5.QtCore import pyqtSlot, QUrl, QTimer, QEventLoop, QPoint, QPointF
18 QByteArray, QDataStream, QIODevice
19 from PyQt5.QtGui import QDesktopServices 18 from PyQt5.QtGui import QDesktopServices
20 from PyQt5.QtWebEngineWidgets import QWebEnginePage, QWebEngineSettings, \ 19 from PyQt5.QtWebEngineWidgets import QWebEnginePage, QWebEngineSettings, \
21 QWebEngineScript 20 QWebEngineScript
22 from PyQt5.QtWebChannel import QWebChannel 21 from PyQt5.QtWebChannel import QWebChannel
23 22
372 @param sourceId source URL causing the error 371 @param sourceId source URL causing the error
373 @type str 372 @type str
374 """ 373 """
375 self.view().mainWindow().javascriptConsole().javaScriptConsoleMessage( 374 self.view().mainWindow().javascriptConsole().javaScriptConsoleMessage(
376 level, message, lineNumber, sourceId) 375 level, message, lineNumber, sourceId)
377
378 ####################################################
379 ## Methods below implement session related functions
380 ####################################################
381 ##
382 ## def getSessionData(self):
383 ## """
384 ## Public method to populate the session data.
385 ##
386 ## @return dictionary containing the session data
387 ## @rtype dict
388 ## """
389 ## sessionData = {}
390 ##
391 ## # 1. zoom factor
392 ## sessionData["ZoomFactor"] = self.zoomFactor()
393 ##
394 ## # 2. scroll position
395 ## scrollPos = self.scrollPosition()
396 ## sessionData["ScrollPosition"] = {
397 ## "x": scrollPos.x(),
398 ## "y": scrollPos.y(),
399 ## }
400 ##
401 ## # 3. page history
402 ## historyArray = QByteArray()
403 ## stream = QDataStream(historyArray, QIODevice.WriteOnly)
404 ## stream << self.history()
405 ## sessionData["History"] = str(
406 ## historyArray.toBase64(QByteArray.Base64UrlEncoding),
407 ## encoding="ascii")
408 ## sessionData["HistoryIndex"] = self.history().currentItemIndex()
409 ##
410 ## # 4. current URL
411 ## sessionData["Url"] = self.url().toString(
412 ## QUrl.PrettyDecoded | QUrl.RemovePassword)
413 ##
414 ## return sessionData
415 ##
416 ## def loadFromSessionData(self, sessionData):
417 ## """
418 ## Public method to load the session data.
419 ##
420 ## @param sessionData dictionary containing the session data as
421 ## generated by getSessionData()
422 ## @type dict
423 ## """
424 ## # 1. page history
425 ## if "History" in sessionData:
426 ## historyArray = QByteArray.fromBase64(
427 ## sessionData["History"].encode("ascii"),
428 ## QByteArray.Base64UrlEncoding)
429 ## stream = QDataStream(historyArray, QIODevice.ReadOnly)
430 ## stream >> self.history()
431 ##
432 ## if "HistoryIndex" in sessionData:
433 ## item = self.history().itemAt(sessionData["HistoryIndex"])
434 ## if item is not None:
435 ## self.history().goToItem(item)
436 ##
437 ## # 2. zoom factor
438 ## if "ZoomFactor" in sessionData:
439 ## self.setZoomFactor(sessionData["ZoomFactor"])
440 ##
441 ## # 3. scroll position
442 ## if "ScrollPosition" in sessionData:
443 ## scrollPos = sessionData["ScrollPosition"]
444 ## self.scrollTo(QPointF(scrollPos["x"], scrollPos["y"]))
445 376
446 ################################################## 377 ##################################################
447 ## Methods below implement compatibility functions 378 ## Methods below implement compatibility functions
448 ################################################## 379 ##################################################
449 380

eric ide

mercurial