Mon, 28 Mar 2016 16:06:39 +0200
Continued porting the web browser.
- added a page to be shown when the rendering process is terminated
--- a/WebBrowser/WebBrowserView.py Mon Mar 28 15:31:47 2016 +0200 +++ b/WebBrowser/WebBrowserView.py Mon Mar 28 16:06:39 2016 +0200 @@ -36,6 +36,7 @@ from .Network.LoadRequest import LoadRequest, LoadRequestOperations from . import WebInspector +from .Tools.WebBrowserTools import readAllFileContents, pixmapToDataUrl import Preferences import UI.PixmapCache @@ -120,8 +121,7 @@ self.loadStarted.connect(self.__loadStarted) self.loadProgress.connect(self.__loadProgress) self.loadFinished.connect(self.__loadFinished) - # TODO: renderProcessTerminated -## self.page().renderProcessTerminated.connect(self.__renderProcessTerminated) + self.renderProcessTerminated.connect(self.__renderProcessTerminated) ## self.page().setForwardUnsupportedContent(True) ## self.page().unsupportedContent.connect(self.__unsupportedContent) @@ -1500,10 +1500,45 @@ ## Signal handlers below ########################################################################### - # TODO: renderProcessTerminated -## def __renderProcessTerminated(self, status, exitCode): -## print(status, exitCode) -## + def __renderProcessTerminated(self, status, exitCode): + """ + Private slot handling a crash of the web page render process. + + @param status termination status + @type QWebEnginePage.RenderProcessTerminationStatus + @param exitCode exit code of the process + @type int + """ + if status == QWebEnginePage.NormalTerminationStatus: + return + + QTimer.singleShot(0, self.__showTabCrashPage) + + def __showTabCrashPage(self): + """ + Private slot to show the tab crash page. + """ + html = readAllFileContents(":/html/tabCrashPage.html") + html = html.replace("@IMAGE@", pixmapToDataUrl( + qApp.style().standardIcon(QStyle.SP_MessageBoxWarning).pixmap( + 48, 48)).toString()) + html = html.replace("@FAVICON@", pixmapToDataUrl( + qApp.style() .standardIcon(QStyle.SP_MessageBoxWarning).pixmap( + 16, 16)).toString()) + html = html.replace("@TITLE@", self.tr("Failed loading page")) + html = html.replace("@H1@", self.tr("Failed loading page")) + html = html.replace( + "@LI-1@", + self.tr("Something went wrong while loading this page.")) + html = html.replace( + "@LI-2@", + self.tr( + "Try reloading the page or closing some tabs to make more" + " memory available.")) + html = html.replace( + "@BUTTON@", self.tr("Reload Page")) + self.page().setHtml(html, self.url()) + def __loadStarted(self): """ Private method to handle the loadStarted signal.
--- a/WebBrowser/data/html.qrc Mon Mar 28 15:31:47 2016 +0200 +++ b/WebBrowser/data/html.qrc Mon Mar 28 16:06:39 2016 +0200 @@ -4,5 +4,6 @@ <file>html/adblockPage.html</file> <file>html/startPage.html</file> <file>html/speeddialPage.html</file> + <file>html/tabCrashPage.html</file> </qresource> </RCC>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/WebBrowser/data/html/tabCrashPage.html Mon Mar 28 16:06:39 2016 +0200 @@ -0,0 +1,56 @@ +<!DOCTYPE html> +<html> +<head> +<meta charset="utf-8"> +<meta http-equiv="content-type" content="text/html; charset=utf-8"> +<title>@TITLE@</title> +<link rel="icon" href="data:image/png;base64,@FAVICON@" type="image/x-icon" /> +<style> +body { + padding: 3em 0em; + background: -webkit-gradient(linear, left top, left bottom, from(#85784A), to(#FDFDFD), color-stop(0.5, #FDFDFD)); + background-repeat: repeat-x; +} +img { + float: left; + opacity: .8; +} +#box { + background: white; + border: 1px solid #85784A; + width: 600px; + padding: 60px; + margin: auto; + border-radius: 0.8em; +} +h1 { + font-size: 130%; + font-weight: bold; + border-bottom: 1px solid #85784A; + margin-left: 64px; +} +h2 { + font-size: 100%; + font-weight: normal; + border-bottom: 1px solid #85784A; + margin-left: 64px; +} +ul { + font-size: 100%; + padding-left: 64px; + margin: 5px 0; +} +</style> +</head> +<body> + <div id="box"> + <img src="@IMAGE@" width="48" height="48"/> + <h1>@H1@</h1> + <ul> + <li>@LI-1@</li> + <li>@LI-2@</li> + <input type="submit" id="reloadButton" value="@BUTTON@" onclick="window.location.reload()"> + </ul> + </div> +</body> +</html>
--- a/WebBrowser/data/html_rc.py Mon Mar 28 15:31:47 2016 +0200 +++ b/WebBrowser/data/html_rc.py Mon Mar 28 16:06:39 2016 +0200 @@ -309,6 +309,80 @@ \x1b\x35\xe9\x3a\xb2\xdc\x5a\x0f\x36\x59\x56\x5a\x15\x6f\x30\x97\ \x4b\x4d\xac\xc2\xd8\xd7\x83\x0e\xab\xdb\x0e\x3a\xec\xbf\x25\xf5\ \x7f\x9e\xbc\x80\x7b\ +\x00\x00\x04\x7b\ +\x3c\ +\x21\x44\x4f\x43\x54\x59\x50\x45\x20\x68\x74\x6d\x6c\x3e\x0a\x3c\ +\x68\x74\x6d\x6c\x3e\x0a\x3c\x68\x65\x61\x64\x3e\x0a\x3c\x6d\x65\ +\x74\x61\x20\x63\x68\x61\x72\x73\x65\x74\x3d\x22\x75\x74\x66\x2d\ +\x38\x22\x3e\x20\x0a\x3c\x6d\x65\x74\x61\x20\x68\x74\x74\x70\x2d\ +\x65\x71\x75\x69\x76\x3d\x22\x63\x6f\x6e\x74\x65\x6e\x74\x2d\x74\ +\x79\x70\x65\x22\x20\x63\x6f\x6e\x74\x65\x6e\x74\x3d\x22\x74\x65\ +\x78\x74\x2f\x68\x74\x6d\x6c\x3b\x20\x63\x68\x61\x72\x73\x65\x74\ +\x3d\x75\x74\x66\x2d\x38\x22\x3e\x0a\x3c\x74\x69\x74\x6c\x65\x3e\ +\x40\x54\x49\x54\x4c\x45\x40\x3c\x2f\x74\x69\x74\x6c\x65\x3e\x0a\ +\x3c\x6c\x69\x6e\x6b\x20\x72\x65\x6c\x3d\x22\x69\x63\x6f\x6e\x22\ +\x20\x68\x72\x65\x66\x3d\x22\x64\x61\x74\x61\x3a\x69\x6d\x61\x67\ +\x65\x2f\x70\x6e\x67\x3b\x62\x61\x73\x65\x36\x34\x2c\x40\x46\x41\ +\x56\x49\x43\x4f\x4e\x40\x22\x20\x74\x79\x70\x65\x3d\x22\x69\x6d\ +\x61\x67\x65\x2f\x78\x2d\x69\x63\x6f\x6e\x22\x20\x2f\x3e\x0a\x3c\ +\x73\x74\x79\x6c\x65\x3e\x0a\x62\x6f\x64\x79\x20\x7b\x0a\x20\x20\ +\x70\x61\x64\x64\x69\x6e\x67\x3a\x20\x33\x65\x6d\x20\x30\x65\x6d\ +\x3b\x0a\x20\x20\x62\x61\x63\x6b\x67\x72\x6f\x75\x6e\x64\x3a\x20\ +\x2d\x77\x65\x62\x6b\x69\x74\x2d\x67\x72\x61\x64\x69\x65\x6e\x74\ +\x28\x6c\x69\x6e\x65\x61\x72\x2c\x20\x6c\x65\x66\x74\x20\x74\x6f\ +\x70\x2c\x20\x6c\x65\x66\x74\x20\x62\x6f\x74\x74\x6f\x6d\x2c\x20\ +\x66\x72\x6f\x6d\x28\x23\x38\x35\x37\x38\x34\x41\x29\x2c\x20\x74\ +\x6f\x28\x23\x46\x44\x46\x44\x46\x44\x29\x2c\x20\x63\x6f\x6c\x6f\ +\x72\x2d\x73\x74\x6f\x70\x28\x30\x2e\x35\x2c\x20\x23\x46\x44\x46\ +\x44\x46\x44\x29\x29\x3b\x0a\x20\x20\x62\x61\x63\x6b\x67\x72\x6f\ +\x75\x6e\x64\x2d\x72\x65\x70\x65\x61\x74\x3a\x20\x72\x65\x70\x65\ +\x61\x74\x2d\x78\x3b\x0a\x7d\x0a\x69\x6d\x67\x20\x7b\x0a\x20\x20\ +\x66\x6c\x6f\x61\x74\x3a\x20\x6c\x65\x66\x74\x3b\x0a\x20\x20\x6f\ +\x70\x61\x63\x69\x74\x79\x3a\x20\x2e\x38\x3b\x0a\x7d\x0a\x23\x62\ +\x6f\x78\x20\x7b\x0a\x20\x20\x62\x61\x63\x6b\x67\x72\x6f\x75\x6e\ +\x64\x3a\x20\x77\x68\x69\x74\x65\x3b\x0a\x20\x20\x62\x6f\x72\x64\ +\x65\x72\x3a\x20\x31\x70\x78\x20\x73\x6f\x6c\x69\x64\x20\x23\x38\ +\x35\x37\x38\x34\x41\x3b\x0a\x20\x20\x77\x69\x64\x74\x68\x3a\x20\ +\x36\x30\x30\x70\x78\x3b\x0a\x20\x20\x70\x61\x64\x64\x69\x6e\x67\ +\x3a\x20\x36\x30\x70\x78\x3b\x0a\x20\x20\x6d\x61\x72\x67\x69\x6e\ +\x3a\x20\x61\x75\x74\x6f\x3b\x0a\x20\x20\x62\x6f\x72\x64\x65\x72\ +\x2d\x72\x61\x64\x69\x75\x73\x3a\x20\x30\x2e\x38\x65\x6d\x3b\x0a\ +\x7d\x0a\x68\x31\x20\x7b\x0a\x20\x20\x66\x6f\x6e\x74\x2d\x73\x69\ +\x7a\x65\x3a\x20\x31\x33\x30\x25\x3b\x0a\x20\x20\x66\x6f\x6e\x74\ +\x2d\x77\x65\x69\x67\x68\x74\x3a\x20\x62\x6f\x6c\x64\x3b\x0a\x20\ +\x20\x62\x6f\x72\x64\x65\x72\x2d\x62\x6f\x74\x74\x6f\x6d\x3a\x20\ +\x31\x70\x78\x20\x73\x6f\x6c\x69\x64\x20\x23\x38\x35\x37\x38\x34\ +\x41\x3b\x0a\x20\x20\x6d\x61\x72\x67\x69\x6e\x2d\x6c\x65\x66\x74\ +\x3a\x20\x36\x34\x70\x78\x3b\x0a\x7d\x0a\x68\x32\x20\x7b\x0a\x20\ +\x20\x66\x6f\x6e\x74\x2d\x73\x69\x7a\x65\x3a\x20\x31\x30\x30\x25\ +\x3b\x0a\x20\x20\x66\x6f\x6e\x74\x2d\x77\x65\x69\x67\x68\x74\x3a\ +\x20\x6e\x6f\x72\x6d\x61\x6c\x3b\x0a\x20\x20\x62\x6f\x72\x64\x65\ +\x72\x2d\x62\x6f\x74\x74\x6f\x6d\x3a\x20\x31\x70\x78\x20\x73\x6f\ +\x6c\x69\x64\x20\x23\x38\x35\x37\x38\x34\x41\x3b\x0a\x20\x20\x6d\ +\x61\x72\x67\x69\x6e\x2d\x6c\x65\x66\x74\x3a\x20\x36\x34\x70\x78\ +\x3b\x0a\x7d\x0a\x75\x6c\x20\x7b\x0a\x20\x20\x66\x6f\x6e\x74\x2d\ +\x73\x69\x7a\x65\x3a\x20\x31\x30\x30\x25\x3b\x0a\x20\x20\x70\x61\ +\x64\x64\x69\x6e\x67\x2d\x6c\x65\x66\x74\x3a\x20\x36\x34\x70\x78\ +\x3b\x0a\x20\x20\x6d\x61\x72\x67\x69\x6e\x3a\x20\x35\x70\x78\x20\ +\x30\x3b\x0a\x7d\x0a\x3c\x2f\x73\x74\x79\x6c\x65\x3e\x0a\x3c\x2f\ +\x68\x65\x61\x64\x3e\x0a\x3c\x62\x6f\x64\x79\x3e\x0a\x20\x20\x3c\ +\x64\x69\x76\x20\x69\x64\x3d\x22\x62\x6f\x78\x22\x3e\x0a\x20\x20\ +\x20\x20\x3c\x69\x6d\x67\x20\x73\x72\x63\x3d\x22\x40\x49\x4d\x41\ +\x47\x45\x40\x22\x20\x77\x69\x64\x74\x68\x3d\x22\x34\x38\x22\x20\ +\x68\x65\x69\x67\x68\x74\x3d\x22\x34\x38\x22\x2f\x3e\x0a\x20\x20\ +\x20\x20\x3c\x68\x31\x3e\x40\x48\x31\x40\x3c\x2f\x68\x31\x3e\x0a\ +\x20\x20\x20\x20\x3c\x75\x6c\x3e\x0a\x20\x20\x20\x20\x20\x20\x3c\ +\x6c\x69\x3e\x40\x4c\x49\x2d\x31\x40\x3c\x2f\x6c\x69\x3e\x0a\x20\ +\x20\x20\x20\x20\x20\x3c\x6c\x69\x3e\x40\x4c\x49\x2d\x32\x40\x3c\ +\x2f\x6c\x69\x3e\x0a\x20\x20\x20\x20\x20\x20\x3c\x69\x6e\x70\x75\ +\x74\x20\x74\x79\x70\x65\x3d\x22\x73\x75\x62\x6d\x69\x74\x22\x20\ +\x69\x64\x3d\x22\x72\x65\x6c\x6f\x61\x64\x42\x75\x74\x74\x6f\x6e\ +\x22\x20\x76\x61\x6c\x75\x65\x3d\x22\x40\x42\x55\x54\x54\x4f\x4e\ +\x40\x22\x20\x6f\x6e\x63\x6c\x69\x63\x6b\x3d\x22\x77\x69\x6e\x64\ +\x6f\x77\x2e\x6c\x6f\x63\x61\x74\x69\x6f\x6e\x2e\x72\x65\x6c\x6f\ +\x61\x64\x28\x29\x22\x3e\x0a\x20\x20\x20\x20\x3c\x2f\x75\x6c\x3e\ +\x0a\x20\x20\x3c\x2f\x64\x69\x76\x3e\x0a\x3c\x2f\x62\x6f\x64\x79\ +\x3e\x0a\x3c\x2f\x68\x74\x6d\x6c\x3e\x0a\ \x00\x00\x03\x7c\ \x3c\ \x21\x44\x4f\x43\x54\x59\x50\x45\x20\x68\x74\x6d\x6c\x3e\x0a\x3c\ @@ -582,6 +656,11 @@ \x00\x73\ \x00\x70\x00\x65\x00\x65\x00\x64\x00\x64\x00\x69\x00\x61\x00\x6c\x00\x50\x00\x61\x00\x67\x00\x65\x00\x2e\x00\x68\x00\x74\x00\x6d\ \x00\x6c\ +\x00\x11\ +\x0d\xbe\x8d\x7c\ +\x00\x74\ +\x00\x61\x00\x62\x00\x43\x00\x72\x00\x61\x00\x73\x00\x68\x00\x50\x00\x61\x00\x67\x00\x65\x00\x2e\x00\x68\x00\x74\x00\x6d\x00\x6c\ +\ \x00\x10\ \x0b\xe9\x1d\x9c\ \x00\x61\ @@ -594,9 +673,10 @@ qt_resource_struct = b"\ \x00\x00\x00\x00\x00\x02\x00\x00\x00\x01\x00\x00\x00\x01\ -\x00\x00\x00\x00\x00\x02\x00\x00\x00\x03\x00\x00\x00\x02\ +\x00\x00\x00\x00\x00\x02\x00\x00\x00\x04\x00\x00\x00\x02\ \x00\x00\x00\x0e\x00\x01\x00\x00\x00\x01\x00\x00\x00\x00\ -\x00\x00\x00\x5e\x00\x00\x00\x00\x00\x01\x00\x00\x16\x1a\ +\x00\x00\x00\x86\x00\x00\x00\x00\x00\x01\x00\x00\x1a\x99\ +\x00\x00\x00\x60\x00\x00\x00\x00\x00\x01\x00\x00\x17\x19\ \x00\x00\x00\x38\x00\x00\x00\x00\x00\x01\x00\x00\x12\x9a\ "
--- a/eric6.e4p Mon Mar 28 15:31:47 2016 +0200 +++ b/eric6.e4p Mon Mar 28 16:06:39 2016 +0200 @@ -2063,6 +2063,7 @@ <Other>WebBrowser/data/html/adblockPage.html</Other> <Other>WebBrowser/data/html/speeddialPage.html</Other> <Other>WebBrowser/data/html/startPage.html</Other> + <Other>WebBrowser/data/html/tabCrashPage.html</Other> <Other>WebBrowser/data/icons/adBlockPlus16.png</Other> <Other>WebBrowser/data/icons/adBlockPlus64.png</Other> <Other>WebBrowser/data/icons/box-border-small.png</Other>