--- a/WebBrowser/WebBrowserView.py Thu Jan 10 14:23:49 2019 +0100 +++ b/WebBrowser/WebBrowserView.py Sat Feb 02 11:12:54 2019 +0100 @@ -21,7 +21,7 @@ QByteArray, QIODevice, QDataStream from PyQt5.QtGui import QDesktopServices, QClipboard, QIcon, \ QContextMenuEvent, QPixmap -from PyQt5.QtWidgets import qApp, QStyle, QMenu, QApplication +from PyQt5.QtWidgets import qApp, QStyle, QMenu, QApplication, QDialog from PyQt5.QtWebEngineWidgets import QWebEngineView, QWebEnginePage, \ QWebEngineDownloadItem @@ -154,7 +154,7 @@ self.__page.safeBrowsingAbort.connect(self.safeBrowsingAbort) self.__page.safeBrowsingBad.connect(self.safeBrowsingBad) - self.__page.printRequested.connect(self.__printPage) + self.__page.printPageRequested.connect(self.__printPage) try: self.__page.quotaRequested.connect(self.__quotaRequested) self.__page.registerProtocolHandlerRequested.connect( @@ -162,6 +162,12 @@ except AttributeError: # pre Qt 5.11 pass + try: + self.__page.selectClientCertificate.connect( + self.__selectClientCertificate) + except AttributeError: + # pre Qt 5.12 + pass def __setRwhvqt(self): """ @@ -1513,7 +1519,7 @@ self.parentWidget().installEventFilter(self) # find the render widget receiving events for the web page - if qVersionTuple() < (5, 8, 0): + if qVersionTuple() < (5, 8, 0) or qVersionTuple() >= (5, 12, 0): if obj is self and evt.type() == QEvent.ChildAdded: child = evt.child() if child and child.inherits( @@ -2289,3 +2295,35 @@ request.accept() else: request.reject() + + ########################################################################### + ## Methods below implement slots for Qt 5.12+ + ########################################################################### + + if qVersionTuple() >= (5, 12, 0): + @pyqtSlot("QWebEngineClientCertificateSelection") + def __selectClientCertificate(self, clientCertificateSelection): + """ + Private slot to handle the client certificate selection request. + + @param clientCertificateSelection list of client SSL certificates + found in system's client certificate store + @type QWebEngineClientCertificateSelection + """ + certificates = clientCertificateSelection.certificates() + if len(certificates) == 0: + clientCertificateSelection.selectNone() + elif len(certificates) == 1: + clientCertificateSelection.select(certificates[0]) + else: + certificate = None + from E5Network.E5SslCertificateSelectionDialog import \ + E5SslCertificateSelectionDialog + dlg = E5SslCertificateSelectionDialog(certificates, self) + if dlg.exec_() == QDialog.Accepted: + certificate = dlg.getSelectedCertificate() + + if certificate is None: + clientCertificateSelection.selectNone() + else: + clientCertificateSelection.select(certificate)