22 from PyQt6.QtWidgets import QStyle, QMenu, QApplication, QDialog |
22 from PyQt6.QtWidgets import QStyle, QMenu, QApplication, QDialog |
23 from PyQt6.QtWebEngineWidgets import ( |
23 from PyQt6.QtWebEngineWidgets import ( |
24 QWebEngineView, QWebEnginePage, QWebEngineDownloadItem |
24 QWebEngineView, QWebEnginePage, QWebEngineDownloadItem |
25 ) |
25 ) |
26 |
26 |
27 from E5Gui import E5MessageBox, E5FileDialog |
27 from E5Gui import EricMessageBox, EricFileDialog |
28 from E5Gui.E5Application import e5App |
28 from E5Gui.EricApplication import ericApp |
29 |
29 |
30 from WebBrowser.WebBrowserWindow import WebBrowserWindow |
30 from WebBrowser.WebBrowserWindow import WebBrowserWindow |
31 from .WebBrowserPage import WebBrowserPage |
31 from .WebBrowserPage import WebBrowserPage |
32 |
32 |
33 from .Tools.WebIconLoader import WebIconLoader |
33 from .Tools.WebIconLoader import WebIconLoader |
254 if name.scheme() and len(name.scheme()) == 1: |
254 if name.scheme() and len(name.scheme()) == 1: |
255 # it is a local path on win os |
255 # it is a local path on win os |
256 name = QUrl.fromLocalFile(name.toString()) |
256 name = QUrl.fromLocalFile(name.toString()) |
257 |
257 |
258 if not QFileInfo(name.toLocalFile()).exists(): |
258 if not QFileInfo(name.toLocalFile()).exists(): |
259 E5MessageBox.critical( |
259 EricMessageBox.critical( |
260 self, |
260 self, |
261 self.tr("eric Web Browser"), |
261 self.tr("eric Web Browser"), |
262 self.tr( |
262 self.tr( |
263 """<p>The file <b>{0}</b> does not exist.</p>""") |
263 """<p>The file <b>{0}</b> does not exist.</p>""") |
264 .format(name.toLocalFile())) |
264 .format(name.toLocalFile())) |
265 return |
265 return |
266 |
266 |
267 if name.toLocalFile().lower().endswith((".pdf", ".chm")): |
267 if name.toLocalFile().lower().endswith((".pdf", ".chm")): |
268 started = QDesktopServices.openUrl(name) |
268 started = QDesktopServices.openUrl(name) |
269 if not started: |
269 if not started: |
270 E5MessageBox.critical( |
270 EricMessageBox.critical( |
271 self, |
271 self, |
272 self.tr("eric Web Browser"), |
272 self.tr("eric Web Browser"), |
273 self.tr( |
273 self.tr( |
274 """<p>Could not start a viewer""" |
274 """<p>Could not start a viewer""" |
275 """ for file <b>{0}</b>.</p>""") |
275 """ for file <b>{0}</b>.</p>""") |
276 .format(name.path())) |
276 .format(name.path())) |
277 return |
277 return |
278 elif name.scheme() in ["mailto"]: |
278 elif name.scheme() in ["mailto"]: |
279 started = QDesktopServices.openUrl(name) |
279 started = QDesktopServices.openUrl(name) |
280 if not started: |
280 if not started: |
281 E5MessageBox.critical( |
281 EricMessageBox.critical( |
282 self, |
282 self, |
283 self.tr("eric Web Browser"), |
283 self.tr("eric Web Browser"), |
284 self.tr( |
284 self.tr( |
285 """<p>Could not start an application""" |
285 """<p>Could not start an application""" |
286 """ for URL <b>{0}</b>.</p>""") |
286 """ for URL <b>{0}</b>.</p>""") |
288 return |
288 return |
289 else: |
289 else: |
290 if name.toString().lower().endswith((".pdf", ".chm")): |
290 if name.toString().lower().endswith((".pdf", ".chm")): |
291 started = QDesktopServices.openUrl(name) |
291 started = QDesktopServices.openUrl(name) |
292 if not started: |
292 if not started: |
293 E5MessageBox.critical( |
293 EricMessageBox.critical( |
294 self, |
294 self, |
295 self.tr("eric Web Browser"), |
295 self.tr("eric Web Browser"), |
296 self.tr( |
296 self.tr( |
297 """<p>Could not start a viewer""" |
297 """<p>Could not start a viewer""" |
298 """ for file <b>{0}</b>.</p>""") |
298 """ for file <b>{0}</b>.</p>""") |
1769 self.page().deleteLater() |
1769 self.page().deleteLater() |
1770 self.__createNewPage() |
1770 self.__createNewPage() |
1771 |
1771 |
1772 html = getHtmlPage("tabCrashPage.html") |
1772 html = getHtmlPage("tabCrashPage.html") |
1773 html = html.replace("@IMAGE@", pixmapToDataUrl( |
1773 html = html.replace("@IMAGE@", pixmapToDataUrl( |
1774 e5App().style().standardIcon( |
1774 ericApp().style().standardIcon( |
1775 QStyle.StandardPixmap.SP_MessageBoxWarning).pixmap(48, 48) |
1775 QStyle.StandardPixmap.SP_MessageBoxWarning).pixmap(48, 48) |
1776 ).toString()) |
1776 ).toString()) |
1777 html = html.replace("@FAVICON@", pixmapToDataUrl( |
1777 html = html.replace("@FAVICON@", pixmapToDataUrl( |
1778 e5App().style() .standardIcon( |
1778 ericApp().style() .standardIcon( |
1779 QStyle.StandardPixmap.SP_MessageBoxWarning).pixmap(16, 16) |
1779 QStyle.StandardPixmap.SP_MessageBoxWarning).pixmap(16, 16) |
1780 ).toString()) |
1780 ).toString()) |
1781 html = html.replace( |
1781 html = html.replace( |
1782 "@TITLE@", self.tr("Render Process terminated abnormally")) |
1782 "@TITLE@", self.tr("Render Process terminated abnormally")) |
1783 html = html.replace( |
1783 html = html.replace( |
1945 defaultFileName += ".mhtml" |
1945 defaultFileName += ".mhtml" |
1946 |
1946 |
1947 fileName = "" |
1947 fileName = "" |
1948 saveFormat = QWebEngineDownloadItem.SavePageFormat.MimeHtmlSaveFormat |
1948 saveFormat = QWebEngineDownloadItem.SavePageFormat.MimeHtmlSaveFormat |
1949 |
1949 |
1950 fileName, selectedFilter = E5FileDialog.getSaveFileNameAndFilter( |
1950 fileName, selectedFilter = EricFileDialog.getSaveFileNameAndFilter( |
1951 None, |
1951 None, |
1952 self.tr("Save Web Page"), |
1952 self.tr("Save Web Page"), |
1953 defaultFileName, |
1953 defaultFileName, |
1954 ";;".join(filterList), |
1954 ";;".join(filterList), |
1955 None) |
1955 None) |
2295 else: |
2295 else: |
2296 # ask user |
2296 # ask user |
2297 from .Download.DownloadUtilities import dataString |
2297 from .Download.DownloadUtilities import dataString |
2298 sizeStr = dataString(quotaRequest.requestedSize()) |
2298 sizeStr = dataString(quotaRequest.requestedSize()) |
2299 |
2299 |
2300 ok = E5MessageBox.yesNo( |
2300 ok = EricMessageBox.yesNo( |
2301 self, |
2301 self, |
2302 self.tr("Quota Request"), |
2302 self.tr("Quota Request"), |
2303 self.tr("""<p> Allow the website at <b>{0}</b> to use""" |
2303 self.tr("""<p> Allow the website at <b>{0}</b> to use""" |
2304 """ <b>{1}</b> of persistent storage?</p>""") |
2304 """ <b>{1}</b> of persistent storage?</p>""") |
2305 .format(quotaRequest.origin().host(), sizeStr) |
2305 .format(quotaRequest.origin().host(), sizeStr) |