68 @param parent parent widget of this window (QWidget) |
68 @param parent parent widget of this window (QWidget) |
69 """ |
69 """ |
70 super(WebBrowserPage, self).__init__( |
70 super(WebBrowserPage, self).__init__( |
71 WebBrowserWindow.webProfile(), parent) |
71 WebBrowserWindow.webProfile(), parent) |
72 |
72 |
|
73 self.__printer = None |
|
74 self.__badSite = False |
|
75 self.__registerProtocolHandlerRequest = None |
|
76 |
73 self.featurePermissionRequested.connect( |
77 self.featurePermissionRequested.connect( |
74 self.__featurePermissionRequested) |
78 self.__featurePermissionRequested) |
75 |
|
76 self.authenticationRequired.connect( |
79 self.authenticationRequired.connect( |
77 lambda url, auth: WebBrowserWindow.networkManager().authentication( |
80 lambda url, auth: WebBrowserWindow.networkManager().authentication( |
78 url, auth, self)) |
81 url, auth, self)) |
79 |
|
80 self.proxyAuthenticationRequired.connect( |
82 self.proxyAuthenticationRequired.connect( |
81 WebBrowserWindow.networkManager().proxyAuthentication) |
83 WebBrowserWindow.networkManager().proxyAuthentication) |
82 |
|
83 self.fullScreenRequested.connect(self.__fullScreenRequested) |
84 self.fullScreenRequested.connect(self.__fullScreenRequested) |
84 |
|
85 self.urlChanged.connect(self.__urlChanged) |
85 self.urlChanged.connect(self.__urlChanged) |
86 |
86 |
87 try: |
87 try: |
88 self.contentsSizeChanged.connect(self.__contentsSizeChanged) |
88 self.contentsSizeChanged.connect(self.__contentsSizeChanged) |
89 except AttributeError: |
89 except AttributeError: |
90 # defined for Qt >= 5.7 |
90 # defined for Qt >= 5.7 |
91 pass |
91 pass |
92 |
92 |
93 self.__printer = None |
93 try: |
94 self.__badSite = False |
94 self.registerProtocolHandlerRequested.connect( |
95 |
95 self.__registerProtocolHandlerRequested) |
96 if qVersionTuple() >= (5, 10, 0): |
96 except AttributeError: |
97 # Workaround for broken load started/finished signals in |
97 # defined for Qt >= 5.11 |
98 # QtWebEngine 5.10, 5.11 |
98 pass |
99 self.loadProgress.connect(self.__loadProgress) |
|
100 |
99 |
101 # Workaround for changing webchannel world inside |
100 # Workaround for changing webchannel world inside |
102 # acceptNavigationRequest not working |
101 # acceptNavigationRequest not working |
103 self.__channelUrl = QUrl() |
102 self.__channelUrl = QUrl() |
104 self.__channelWorldId = -1 |
103 self.__channelWorldId = -1 |
105 self.__setupChannelTimer = QTimer(self) |
104 self.__setupChannelTimer = QTimer(self) |
106 self.__setupChannelTimer.setSingleShot(True) |
105 self.__setupChannelTimer.setSingleShot(True) |
107 self.__setupChannelTimer.setInterval(100) |
106 self.__setupChannelTimer.setInterval(100) |
108 self.__setupChannelTimer.timeout.connect(self.__setupChannelTimeout) |
107 self.__setupChannelTimer.timeout.connect(self.__setupChannelTimeout) |
109 |
|
110 @pyqtSlot(int) |
|
111 def __loadProgress(self, progress): |
|
112 """ |
|
113 Private slot to send the loadFinished signal for broken Qt versions. |
|
114 |
|
115 @param progress load progress in percent |
|
116 @type int |
|
117 """ |
|
118 if progress == 100: |
|
119 self.loadFinished.emit(True) |
|
120 |
108 |
121 @pyqtSlot() |
109 @pyqtSlot() |
122 def __setupChannelTimeout(self): |
110 def __setupChannelTimeout(self): |
123 """ |
111 """ |
124 Private slot to initiate the setup of the web channel. |
112 Private slot to initiate the setup of the web channel. |
555 pos = QPointF(pos["x"], pos["y"]) |
543 pos = QPointF(pos["x"], pos["y"]) |
556 else: |
544 else: |
557 pos = QPointF(0.0, 0.0) |
545 pos = QPointF(0.0, 0.0) |
558 |
546 |
559 return pos |
547 return pos |
|
548 |
|
549 ############################################################# |
|
550 ## Methods below implement protocol handler related functions |
|
551 ############################################################# |
|
552 |
|
553 @pyqtSlot("QWebEngineRegisterProtocolHandlerRequest") |
|
554 def __registerProtocolHandlerRequested(self, request): |
|
555 """ |
|
556 Private slot to handle the registration of a custom protocol handler. |
|
557 |
|
558 @param request reference to the registration request |
|
559 @type QWebEngineRegisterProtocolHandlerRequest |
|
560 """ |
|
561 from PyQt5.QtWebEngineCore import \ |
|
562 QWebEngineRegisterProtocolHandlerRequest |
|
563 |
|
564 if self.__registerProtocolHandlerRequest: |
|
565 del self.__registerProtocolHandlerRequest |
|
566 self.__registerProtocolHandlerRequest = None |
|
567 self.__registerProtocolHandlerRequest = \ |
|
568 QWebEngineRegisterProtocolHandlerRequest(request) |
|
569 |
|
570 def registerProtocolHandlerRequestUrl(self): |
|
571 """ |
|
572 Public method to get the registered protocol handler request URL. |
|
573 |
|
574 @return registered protocol handler request URL |
|
575 @rtype QUrl |
|
576 """ |
|
577 if self.__registerProtocolHandlerRequest and \ |
|
578 (self.url().host() == |
|
579 self.__registerProtocolHandlerRequest.origin().host()): |
|
580 return self.__registerProtocolHandlerRequest.origin() |
|
581 else: |
|
582 return QUrl() |
|
583 |
|
584 def registerProtocolHandlerRequestScheme(self): |
|
585 """ |
|
586 Public method to get the registered protocol handler request scheme. |
|
587 |
|
588 @return registered protocol handler request scheme |
|
589 @rtype str |
|
590 """ |
|
591 if self.__registerProtocolHandlerRequest and \ |
|
592 (self.url().host() == |
|
593 self.__registerProtocolHandlerRequest.origin().host()): |
|
594 return self.__registerProtocolHandlerRequest.scheme() |
|
595 else: |
|
596 return "" |