1472 @type int |
1472 @type int |
1473 """ |
1473 """ |
1474 if status == QWebEnginePage.NormalTerminationStatus: |
1474 if status == QWebEnginePage.NormalTerminationStatus: |
1475 return |
1475 return |
1476 |
1476 |
1477 QTimer.singleShot(0, self.__showTabCrashPage) |
1477 QTimer.singleShot(0, lambda: self.__showTabCrashPage(status)) |
1478 |
1478 |
1479 def __showTabCrashPage(self): |
1479 def __showTabCrashPage(self, status): |
1480 """ |
1480 """ |
1481 Private slot to show the tab crash page. |
1481 Private slot to show the tab crash page. |
1482 """ |
1482 |
|
1483 @param status termination status |
|
1484 @type QWebEnginePage.RenderProcessTerminationStatus |
|
1485 """ |
|
1486 self.page().deleteLater() |
|
1487 self.__page = WebBrowserPage(self) |
|
1488 self.setPage(self.__page) |
|
1489 |
1483 html = readAllFileContents(":/html/tabCrashPage.html") |
1490 html = readAllFileContents(":/html/tabCrashPage.html") |
1484 html = html.replace("@IMAGE@", pixmapToDataUrl( |
1491 html = html.replace("@IMAGE@", pixmapToDataUrl( |
1485 qApp.style().standardIcon(QStyle.SP_MessageBoxWarning).pixmap( |
1492 qApp.style().standardIcon(QStyle.SP_MessageBoxWarning).pixmap( |
1486 48, 48)).toString()) |
1493 48, 48)).toString()) |
1487 html = html.replace("@FAVICON@", pixmapToDataUrl( |
1494 html = html.replace("@FAVICON@", pixmapToDataUrl( |
1488 qApp.style() .standardIcon(QStyle.SP_MessageBoxWarning).pixmap( |
1495 qApp.style() .standardIcon(QStyle.SP_MessageBoxWarning).pixmap( |
1489 16, 16)).toString()) |
1496 16, 16)).toString()) |
1490 html = html.replace("@TITLE@", self.tr("Failed loading page")) |
|
1491 html = html.replace("@H1@", self.tr("Failed loading page")) |
|
1492 html = html.replace( |
1497 html = html.replace( |
1493 "@LI-1@", |
1498 "@TITLE@", self.tr("Render Process terminated abnormally")) |
1494 self.tr("Something went wrong while loading this page.")) |
1499 html = html.replace( |
|
1500 "@H1@", self.tr("Render Process terminated abnormally")) |
|
1501 if status == QWebEnginePage.CrashedTerminationStatus: |
|
1502 msg = self.tr("The render process crashed while" |
|
1503 " loading this page.") |
|
1504 elif status == QWebEnginePage.KilledTerminationStatus: |
|
1505 msg = self.tr("The render process was killed.") |
|
1506 else: |
|
1507 msg = self.tr("The render process terminated while" |
|
1508 " loading this page.") |
|
1509 html = html.replace("@LI-1@", msg) |
1495 html = html.replace( |
1510 html = html.replace( |
1496 "@LI-2@", |
1511 "@LI-2@", |
1497 self.tr( |
1512 self.tr( |
1498 "Try reloading the page or closing some tabs to make more" |
1513 "Try reloading the page or closing some tabs to make more" |
1499 " memory available.")) |
1514 " memory available.")) |
1500 html = html.replace( |
|
1501 "@BUTTON@", self.tr("Reload Page")) |
|
1502 self.page().setHtml(html, self.url()) |
1515 self.page().setHtml(html, self.url()) |
1503 |
1516 |
1504 def __loadStarted(self): |
1517 def __loadStarted(self): |
1505 """ |
1518 """ |
1506 Private method to handle the loadStarted signal. |
1519 Private method to handle the loadStarted signal. |