eric6/WebBrowser/WebBrowserView.py

branch
maintenance
changeset 7824
096b3ebc1409
parent 7737
5371a22cf2aa
parent 7781
607a6098cb44
child 7924
8a96736d465e
equal deleted inserted replaced
7738:10554f5fac78 7824:096b3ebc1409
6 6
7 """ 7 """
8 Module implementing the web browser using QWebEngineView. 8 Module implementing the web browser using QWebEngineView.
9 """ 9 """
10 10
11
12 import os 11 import os
13 12
14 from PyQt5.QtCore import ( 13 from PyQt5.QtCore import (
15 pyqtSignal, pyqtSlot, Qt, QUrl, QFileInfo, QTimer, QEvent, QPoint, 14 pyqtSignal, pyqtSlot, Qt, QUrl, QFileInfo, QTimer, QEvent, QPoint,
16 QPointF, QDateTime, QStandardPaths, QByteArray, QIODevice, QDataStream 15 QPointF, QDateTime, QStandardPaths, QByteArray, QIODevice, QDataStream
17 ) 16 )
18 from PyQt5.QtGui import ( 17 from PyQt5.QtGui import (
19 QDesktopServices, QClipboard, QIcon, QContextMenuEvent, QPixmap, QCursor 18 QDesktopServices, QClipboard, QIcon, QContextMenuEvent, QPixmap, QCursor
20 ) 19 )
21 from PyQt5.QtWidgets import qApp, QStyle, QMenu, QApplication, QDialog 20 from PyQt5.QtWidgets import QStyle, QMenu, QApplication, QDialog
22 from PyQt5.QtWebEngineWidgets import ( 21 from PyQt5.QtWebEngineWidgets import (
23 QWebEngineView, QWebEnginePage, QWebEngineDownloadItem 22 QWebEngineView, QWebEnginePage, QWebEngineDownloadItem
24 ) 23 )
25 24
26 from E5Gui import E5MessageBox, E5FileDialog 25 from E5Gui import E5MessageBox, E5FileDialog
26 from E5Gui.E5Application import e5App
27 27
28 from WebBrowser.WebBrowserWindow import WebBrowserWindow 28 from WebBrowser.WebBrowserWindow import WebBrowserWindow
29 from .WebBrowserPage import WebBrowserPage 29 from .WebBrowserPage import WebBrowserPage
30 30
31 from .Tools.WebIconLoader import WebIconLoader 31 from .Tools.WebIconLoader import WebIconLoader
1148 return 1148 return
1149 1149
1150 from .Bookmarks.AddBookmarkDialog import AddBookmarkDialog 1150 from .Bookmarks.AddBookmarkDialog import AddBookmarkDialog
1151 dlg = AddBookmarkDialog() 1151 dlg = AddBookmarkDialog()
1152 dlg.setUrl(bytes(url.toEncoded()).decode()) 1152 dlg.setUrl(bytes(url.toEncoded()).decode())
1153 dlg.exec_() 1153 dlg.exec()
1154 1154
1155 def __sendLink(self, act): 1155 def __sendLink(self, act):
1156 """ 1156 """
1157 Private slot to send a link via email. 1157 Private slot to send a link via email.
1158 1158
1344 from .Bookmarks.AddBookmarkDialog import AddBookmarkDialog 1344 from .Bookmarks.AddBookmarkDialog import AddBookmarkDialog
1345 dlg = AddBookmarkDialog() 1345 dlg = AddBookmarkDialog()
1346 dlg.setUrl(bytes(self.url().toEncoded()).decode()) 1346 dlg.setUrl(bytes(self.url().toEncoded()).decode())
1347 dlg.setTitle(self.title()) 1347 dlg.setTitle(self.title())
1348 dlg.setDescription(description) 1348 dlg.setDescription(description)
1349 dlg.exec_() 1349 dlg.exec()
1350 1350
1351 def dragEnterEvent(self, evt): 1351 def dragEnterEvent(self, evt):
1352 """ 1352 """
1353 Protected method called by a drag enter event. 1353 Protected method called by a drag enter event.
1354 1354
1682 self.__siteIcon = QIcon() 1682 self.__siteIcon = QIcon()
1683 if self.__siteIconLoader is not None: 1683 if self.__siteIconLoader is not None:
1684 self.__siteIconLoader.deleteLater() 1684 self.__siteIconLoader.deleteLater()
1685 self.__siteIconLoader = WebIconLoader(url, self) 1685 self.__siteIconLoader = WebIconLoader(url, self)
1686 self.__siteIconLoader.iconLoaded.connect(self.__iconLoaded) 1686 self.__siteIconLoader.iconLoaded.connect(self.__iconLoaded)
1687 try:
1688 self.__siteIconLoader.sslConfiguration.connect(
1689 self.page().setSslConfiguration)
1690 self.__siteIconLoader.clearSslConfiguration.connect(
1691 self.page().clearSslConfiguration)
1692 except AttributeError:
1693 # no SSL available
1694 pass
1687 1695
1688 def __iconLoaded(self, icon): 1696 def __iconLoaded(self, icon):
1689 """ 1697 """
1690 Private slot handling the loaded web site icon. 1698 Private slot handling the loaded web site icon.
1691 1699
1771 self.page().deleteLater() 1779 self.page().deleteLater()
1772 self.__createNewPage() 1780 self.__createNewPage()
1773 1781
1774 html = getHtmlPage("tabCrashPage.html") 1782 html = getHtmlPage("tabCrashPage.html")
1775 html = html.replace("@IMAGE@", pixmapToDataUrl( 1783 html = html.replace("@IMAGE@", pixmapToDataUrl(
1776 qApp.style().standardIcon(QStyle.SP_MessageBoxWarning).pixmap( 1784 e5App().style().standardIcon(QStyle.SP_MessageBoxWarning).pixmap(
1777 48, 48)).toString()) 1785 48, 48)).toString())
1778 html = html.replace("@FAVICON@", pixmapToDataUrl( 1786 html = html.replace("@FAVICON@", pixmapToDataUrl(
1779 qApp.style() .standardIcon(QStyle.SP_MessageBoxWarning).pixmap( 1787 e5App().style() .standardIcon(QStyle.SP_MessageBoxWarning).pixmap(
1780 16, 16)).toString()) 1788 16, 16)).toString())
1781 html = html.replace( 1789 html = html.replace(
1782 "@TITLE@", self.tr("Render Process terminated abnormally")) 1790 "@TITLE@", self.tr("Render Process terminated abnormally"))
1783 html = html.replace( 1791 html = html.replace(
1784 "@H1@", self.tr("Render Process terminated abnormally")) 1792 "@H1@", self.tr("Render Process terminated abnormally"))
2326 certificate = None 2334 certificate = None
2327 from E5Network.E5SslCertificateSelectionDialog import ( 2335 from E5Network.E5SslCertificateSelectionDialog import (
2328 E5SslCertificateSelectionDialog 2336 E5SslCertificateSelectionDialog
2329 ) 2337 )
2330 dlg = E5SslCertificateSelectionDialog(certificates, self) 2338 dlg = E5SslCertificateSelectionDialog(certificates, self)
2331 if dlg.exec_() == QDialog.Accepted: 2339 if dlg.exec() == QDialog.Accepted:
2332 certificate = dlg.getSelectedCertificate() 2340 certificate = dlg.getSelectedCertificate()
2333 2341
2334 if certificate is None: 2342 if certificate is None:
2335 clientCertificateSelection.selectNone() 2343 clientCertificateSelection.selectNone()
2336 else: 2344 else:

eric ide

mercurial