src/eric7/WebBrowser/WebBrowserView.py

branch
eric7
changeset 10847
b3f04b83fc84
parent 10806
2f6df822e3b9
child 10851
5c47172bb240
equal deleted inserted replaced
10846:3db357d07c48 10847:b3f04b83fc84
42 QAbstractPrintDialog, 42 QAbstractPrintDialog,
43 QPrintDialog, 43 QPrintDialog,
44 QPrinter, 44 QPrinter,
45 QPrintPreviewDialog, 45 QPrintPreviewDialog,
46 ) 46 )
47 from PyQt6.QtWebEngineCore import QWebEngineDownloadRequest, QWebEnginePage 47 from PyQt6.QtWebEngineCore import (
48 QWebEngineDownloadRequest,
49 QWebEnginePage,
50 QWebEngineWebAuthUxRequest,
51 )
48 from PyQt6.QtWebEngineWidgets import QWebEngineView 52 from PyQt6.QtWebEngineWidgets import QWebEngineView
49 from PyQt6.QtWidgets import QApplication, QDialog, QMenu, QStyle 53 from PyQt6.QtWidgets import QApplication, QDialog, QMenu, QStyle
50 54
51 from eric7 import EricUtilities, Preferences 55 from eric7 import EricUtilities, Preferences
52 from eric7.__version__ import VersionOnly 56 from eric7.__version__ import VersionOnly
168 self.__clickedPos = QPoint() 172 self.__clickedPos = QPoint()
169 self.__firstLoad = False 173 self.__firstLoad = False
170 self.__preview = QPixmap() 174 self.__preview = QPixmap()
171 self.__currentPrinter = None 175 self.__currentPrinter = None
172 self.__printPreviewLoop = None 176 self.__printPreviewLoop = None
177 self.__webAuthDialog = None
173 178
174 self.__currentZoom = 100 179 self.__currentZoom = 100
175 self.__zoomLevels = WebBrowserView.ZoomLevels[:] 180 self.__zoomLevels = WebBrowserView.ZoomLevels[:]
176 181
177 self.setContextMenuPolicy(Qt.ContextMenuPolicy.CustomContextMenu) 182 self.setContextMenuPolicy(Qt.ContextMenuPolicy.CustomContextMenu)
226 self.__page.quotaRequested.connect(self.__quotaRequested) 231 self.__page.quotaRequested.connect(self.__quotaRequested)
227 with contextlib.suppress(AttributeError): 232 with contextlib.suppress(AttributeError):
228 # Qt 6.4+ 233 # Qt 6.4+
229 self.__page.fileSystemAccessRequested.connect( 234 self.__page.fileSystemAccessRequested.connect(
230 self.__fileSystemAccessRequested 235 self.__fileSystemAccessRequested
236 )
237 with contextlib.suppress(AttributeError):
238 # Qt 6.7+
239 self.__page.webAuthUxRequested.connect(
240 self.__webAuthUxRequested
231 ) 241 )
232 # The registerProtocolHandlerRequested signal is handled in 242 # The registerProtocolHandlerRequested signal is handled in
233 # WebBrowserPage. 243 # WebBrowserPage.
234 self.__page.selectClientCertificate.connect(self.__selectClientCertificate) 244 self.__page.selectClientCertificate.connect(self.__selectClientCertificate)
235 self.__page.findTextFinished.connect(self.__findTextFinished) 245 self.__page.findTextFinished.connect(self.__findTextFinished)
2662 2672
2663 if ok: 2673 if ok:
2664 accessRequest.accept() 2674 accessRequest.accept()
2665 else: 2675 else:
2666 accessRequest.reject() 2676 accessRequest.reject()
2677
2678 ###########################################################################
2679 ## Methods below implement slots for Qt 6.7+
2680 ###########################################################################
2681
2682 with contextlib.suppress(TypeError):
2683
2684 @pyqtSlot("QWebEngineWebAuthUxRequest*")
2685 def __webAuthUxRequested(self, authUxRequest):
2686 """
2687 Private slot to handle WebAuth requests.
2688
2689 @param authUxRequest reference to the WebAuth request object
2690 @type QWebEngineWebAuthUxRequest
2691 """
2692 from .WebBrowserWebAuthDialog import WebBrowserWebAuthDialog
2693
2694 if self.__webAuthDialog is not None:
2695 del self.__webAuthDialog
2696 self.__webAuthDialog = None
2697
2698 self.__webAuthDialog = WebBrowserWebAuthDialog(authUxRequest, self.__mw)
2699 self.__webAuthDialog.setModal(False)
2700 self.__webAuthDialog.setWindowFlags(
2701 self.__webAuthDialog.windowFlags()
2702 & Qt.WindowType.WindowContextHelpButtonHint
2703 )
2704
2705 authUxRequest.stateChanged.connect(self.__webAuthUxRequestStateChanged)
2706 self.__webAuthDialog.show()
2707
2708 with contextlib.suppress(TypeError):
2709
2710 @pyqtSlot("QWebEngineWebAuthUxRequest.WebAuthUxState")
2711 def __webAuthUxRequestStateChanged(self, state):
2712 """
2713 Private slot to handle a change of state of the current WebAuth request.
2714
2715 @param state new state
2716 @type QWebEngineWebAuthUxRequest.WebAuthUxState
2717 """
2718 if state in (
2719 QWebEngineWebAuthUxRequest.WebAuthUxState.Cancelled,
2720 QWebEngineWebAuthUxRequest.WebAuthUxState.Completed,
2721 ):
2722 self.__webAuthDialog.hide()
2723 del self.__webAuthDialog
2724 self.__webAuthDialog = None
2725 else:
2726 self.__webAuthDialog.updateDialog()
2727 self.__webAuthDialog.show()

eric ide

mercurial