1
mirror of https://invent.kde.org/network/falkon.git synced 2024-12-20 02:36:34 +01:00

WebPage: Add page to display when render process crashes

This commit is contained in:
David Rosca 2015-10-14 16:19:54 +02:00
parent e9cbb32e26
commit 0fade63d86
4 changed files with 52 additions and 0 deletions

View File

@ -21,6 +21,7 @@
<file>html/config.html</file>
<file>html/restore.html</file>
<file>html/dirlist.html</file>
<file>html/tabcrash.html</file>
<file>html/qwebchannel.js</file>
</qresource>
</RCC>

View File

@ -0,0 +1,27 @@
<html><head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<title>%TITLE%</title>
<link rel="icon" href="%FAVICON%" type="image/x-icon" />
<style>
html {background: #dddddd;font-family: sans-serif;color: #525c66;}
html * {font-size: 100%;line-height: 1.6;}
#box {max-width:650px;min-width:400px;overflow:auto;margin: 25px auto 10px auto;padding: 10px 40px;border-width: 20px;text-align: %LEFT_STR%;-webkit-border-image: url(%BOX-BORDER%) 25;direction: %DIRECTION%;}
hr {color: lightgray;width: 100%;}
img {float: %LEFT_STR%;margin-%LEFT_STR%: -20px;margin-top: 15px;}
h1 {font-size: 150%;font-weight: bold;border-bottom: 1px solid #f4f4f4;margin-%LEFT_STR%: 48px;margin-%RIGHT_STR%: 50px;}
ul {font-size: 90%;padding-%LEFT_STR%: 48px;margin: 20px 0;max-width:600px;}
li {padding: 5px;}
#reloadButton {margin-top: 20px;min-width: 100px;}
</style>
</head>
<body>
<div id="box">
<img src="%IMAGE%" >
<h1>%HEADING%</h1>
<ul>
<li>%LI-1%</li>
<li>%LI-2%</li>
<input type="submit" id="reloadButton" value="%RELOAD-PAGE%" onclick="window.location.reload()">
</ul>
</div>
</body></html>

View File

@ -81,6 +81,7 @@ WebPage::WebPage(QObject* parent)
connect(this, &QWebEnginePage::featurePermissionRequested, this, &WebPage::featurePermissionRequested);
connect(this, &QWebEnginePage::windowCloseRequested, this, &WebPage::windowCloseRequested);
connect(this, &QWebEnginePage::fullScreenRequested, this, &WebPage::fullScreenRequested);
connect(this, &QWebEnginePage::renderProcessTerminated, this, &WebPage::renderProcessTerminated);
connect(this, &QWebEnginePage::authenticationRequired, this, [this](const QUrl &url, QAuthenticator *auth) {
mApp->networkManager()->authentication(url, auth, view());
@ -328,6 +329,28 @@ void WebPage::featurePermissionRequested(const QUrl &origin, const QWebEnginePag
mApp->html5PermissionsManager()->requestPermissions(this, origin, feature);
}
void WebPage::renderProcessTerminated(QWebEnginePage::RenderProcessTerminationStatus terminationStatus, int exitCode)
{
Q_UNUSED(exitCode)
if (terminationStatus == NormalTerminationStatus)
return;
QTimer::singleShot(0, this, [this]() {
QString page = QzTools::readAllFileContents(":html/tabcrash.html");
page.replace(QL1S("%IMAGE%"), QzTools::pixmapToDataUrl(IconProvider::standardIcon(QStyle::SP_MessageBoxWarning).pixmap(45)).toString());
page.replace(QL1S("%FAVICON%"), QzTools::pixmapToDataUrl(IconProvider::standardIcon(QStyle::SP_MessageBoxWarning).pixmap(16)).toString());
page.replace(QL1S("%BOX-BORDER%"), QLatin1String("qrc:html/box-border.png"));
page.replace(QL1S("%TITLE%"), tr("Failed loading page"));
page.replace(QL1S("%HEADING%"), tr("Failed loading page"));
page.replace(QL1S("%LI-1%"), tr("Something went wrong while loading this page."));
page.replace(QL1S("%LI-2%"), tr("Try reloading the page or closing some tabs to make more memory available."));
page.replace(QL1S("%RELOAD-PAGE%"), tr("Reload page"));
page = QzTools::applyDirectionToPage(page);
setHtml(page.toUtf8(), url());
});
}
bool WebPage::isFullScreen()
{
return view()->isFullScreen();

View File

@ -76,6 +76,7 @@ private slots:
void windowCloseRequested();
void fullScreenRequested(bool fullScreen);
void featurePermissionRequested(const QUrl &origin, const QWebEnginePage::Feature &feature);
void renderProcessTerminated(RenderProcessTerminationStatus terminationStatus, int exitCode);
private:
bool isFullScreen() Q_DECL_OVERRIDE;