19 from PyQt5.QtCore import pyqtSignal, pyqtSlot, PYQT_VERSION, Qt, QUrl, \ |
19 from PyQt5.QtCore import pyqtSignal, pyqtSlot, PYQT_VERSION, Qt, QUrl, \ |
20 QFileInfo, QTimer, QEvent, QPoint, QPointF, QDateTime, QStandardPaths, \ |
20 QFileInfo, QTimer, QEvent, QPoint, QPointF, QDateTime, QStandardPaths, \ |
21 QByteArray, QIODevice, QDataStream |
21 QByteArray, QIODevice, QDataStream |
22 from PyQt5.QtGui import QDesktopServices, QClipboard, QIcon, \ |
22 from PyQt5.QtGui import QDesktopServices, QClipboard, QIcon, \ |
23 QContextMenuEvent, QPixmap |
23 QContextMenuEvent, QPixmap |
24 from PyQt5.QtWidgets import qApp, QStyle, QMenu, QApplication |
24 from PyQt5.QtWidgets import qApp, QStyle, QMenu, QApplication, QDialog |
25 from PyQt5.QtWebEngineWidgets import QWebEngineView, QWebEnginePage, \ |
25 from PyQt5.QtWebEngineWidgets import QWebEngineView, QWebEnginePage, \ |
26 QWebEngineDownloadItem |
26 QWebEngineDownloadItem |
27 |
27 |
28 from E5Gui import E5MessageBox, E5FileDialog |
28 from E5Gui import E5MessageBox, E5FileDialog |
29 |
29 |
152 self.__page = WebBrowserPage(self) |
152 self.__page = WebBrowserPage(self) |
153 self.setPage(self.__page) |
153 self.setPage(self.__page) |
154 |
154 |
155 self.__page.safeBrowsingAbort.connect(self.safeBrowsingAbort) |
155 self.__page.safeBrowsingAbort.connect(self.safeBrowsingAbort) |
156 self.__page.safeBrowsingBad.connect(self.safeBrowsingBad) |
156 self.__page.safeBrowsingBad.connect(self.safeBrowsingBad) |
157 self.__page.printRequested.connect(self.__printPage) |
157 self.__page.printPageRequested.connect(self.__printPage) |
158 try: |
158 try: |
159 self.__page.quotaRequested.connect(self.__quotaRequested) |
159 self.__page.quotaRequested.connect(self.__quotaRequested) |
160 self.__page.registerProtocolHandlerRequested.connect( |
160 self.__page.registerProtocolHandlerRequested.connect( |
161 self.__registerProtocolHandlerRequested) |
161 self.__registerProtocolHandlerRequested) |
162 except AttributeError: |
162 except AttributeError: |
163 # pre Qt 5.11 |
163 # pre Qt 5.11 |
|
164 pass |
|
165 try: |
|
166 self.__page.selectClientCertificate.connect( |
|
167 self.__selectClientCertificate) |
|
168 except AttributeError: |
|
169 # pre Qt 5.12 |
164 pass |
170 pass |
165 |
171 |
166 def __setRwhvqt(self): |
172 def __setRwhvqt(self): |
167 """ |
173 """ |
168 Private slot to set widget that receives input events. |
174 Private slot to set widget that receives input events. |
1511 if obj is self and evt.type() == QEvent.ParentChange and \ |
1517 if obj is self and evt.type() == QEvent.ParentChange and \ |
1512 self.parentWidget() is not None: |
1518 self.parentWidget() is not None: |
1513 self.parentWidget().installEventFilter(self) |
1519 self.parentWidget().installEventFilter(self) |
1514 |
1520 |
1515 # find the render widget receiving events for the web page |
1521 # find the render widget receiving events for the web page |
1516 if qVersionTuple() < (5, 8, 0): |
1522 if qVersionTuple() < (5, 8, 0) or qVersionTuple() >= (5, 12, 0): |
1517 if obj is self and evt.type() == QEvent.ChildAdded: |
1523 if obj is self and evt.type() == QEvent.ChildAdded: |
1518 child = evt.child() |
1524 child = evt.child() |
1519 if child and child.inherits( |
1525 if child and child.inherits( |
1520 "QtWebEngineCore::" |
1526 "QtWebEngineCore::" |
1521 "RenderWidgetHostViewQtDelegateWidget"): |
1527 "RenderWidgetHostViewQtDelegateWidget"): |
2287 |
2293 |
2288 if ok: |
2294 if ok: |
2289 request.accept() |
2295 request.accept() |
2290 else: |
2296 else: |
2291 request.reject() |
2297 request.reject() |
|
2298 |
|
2299 ########################################################################### |
|
2300 ## Methods below implement slots for Qt 5.12+ |
|
2301 ########################################################################### |
|
2302 |
|
2303 if qVersionTuple() >= (5, 12, 0): |
|
2304 @pyqtSlot("QWebEngineClientCertificateSelection") |
|
2305 def __selectClientCertificate(self, clientCertificateSelection): |
|
2306 """ |
|
2307 Private slot to handle the client certificate selection request. |
|
2308 |
|
2309 @param clientCertificateSelection list of client SSL certificates |
|
2310 found in system's client certificate store |
|
2311 @type QWebEngineClientCertificateSelection |
|
2312 """ |
|
2313 certificates = clientCertificateSelection.certificates() |
|
2314 if len(certificates) == 0: |
|
2315 clientCertificateSelection.selectNone() |
|
2316 elif len(certificates) == 1: |
|
2317 clientCertificateSelection.select(certificates[0]) |
|
2318 else: |
|
2319 certificate = None |
|
2320 from E5Network.E5SslCertificateSelectionDialog import \ |
|
2321 E5SslCertificateSelectionDialog |
|
2322 dlg = E5SslCertificateSelectionDialog(certificates, self) |
|
2323 if dlg.exec_() == QDialog.Accepted: |
|
2324 certificate = dlg.getSelectedCertificate() |
|
2325 |
|
2326 if certificate is None: |
|
2327 clientCertificateSelection.selectNone() |
|
2328 else: |
|
2329 clientCertificateSelection.select(certificate) |