7 """ |
7 """ |
8 Module implementing the helpbrowser using QWebView. |
8 Module implementing the helpbrowser using QWebView. |
9 """ |
9 """ |
10 |
10 |
11 from PyQt6.QtCore import ( |
11 from PyQt6.QtCore import ( |
12 pyqtSlot, pyqtSignal, QUrl, QUrlQuery, QTimer, QEventLoop, QPoint, QPointF |
12 pyqtSlot, pyqtSignal, QUrl, QUrlQuery, QTimer, QEventLoop, QPoint |
13 ) |
13 ) |
14 from PyQt6.QtGui import QDesktopServices |
14 from PyQt6.QtGui import QDesktopServices |
15 from PyQt6.QtWebEngineCore import ( |
15 from PyQt6.QtWebEngineCore import ( |
16 QWebEnginePage, QWebEngineSettings, QWebEngineScript |
16 QWebEnginePage, QWebEngineSettings, QWebEngineScript |
17 ) |
17 ) |
533 @return flag indicating a safe site |
533 @return flag indicating a safe site |
534 @rtype bool |
534 @rtype bool |
535 """ |
535 """ |
536 return not self.__badSite |
536 return not self.__badSite |
537 |
537 |
538 ################################################## |
|
539 ## Methods below implement compatibility functions |
|
540 ################################################## |
|
541 |
|
542 if not hasattr(QWebEnginePage, "icon"): |
|
543 def icon(self): |
|
544 """ |
|
545 Public method to get the web site icon. |
|
546 |
|
547 @return web site icon |
|
548 @rtype QIcon |
|
549 """ |
|
550 return self.__view.icon() |
|
551 |
|
552 if not hasattr(QWebEnginePage, "scrollPosition"): |
|
553 def scrollPosition(self): |
|
554 """ |
|
555 Public method to get the scroll position of the web page. |
|
556 |
|
557 @return scroll position |
|
558 @rtype QPointF |
|
559 """ |
|
560 pos = self.execJavaScript( |
|
561 "(function() {" |
|
562 "var res = {" |
|
563 " x: 0," |
|
564 " y: 0," |
|
565 "};" |
|
566 "res.x = window.scrollX;" |
|
567 "res.y = window.scrollY;" |
|
568 "return res;" |
|
569 "})()", |
|
570 WebBrowserPage.SafeJsWorld |
|
571 ) |
|
572 pos = ( |
|
573 QPointF(0.0, 0.0) if pos is None |
|
574 else QPointF(pos["x"], pos["y"]) |
|
575 ) |
|
576 |
|
577 return pos |
|
578 |
|
579 ############################################################# |
538 ############################################################# |
580 ## Methods below implement protocol handler related functions |
539 ## Methods below implement protocol handler related functions |
581 ############################################################# |
540 ############################################################# |
582 |
541 |
583 @pyqtSlot("QWebEngineRegisterProtocolHandlerRequest") |
542 @pyqtSlot("QWebEngineRegisterProtocolHandlerRequest") |