--- a/Helpviewer/HelpBrowserWV.py Tue Oct 15 22:03:54 2013 +0200 +++ b/Helpviewer/HelpBrowserWV.py Fri Oct 18 23:00:41 2013 +0200 @@ -14,12 +14,12 @@ except (NameError): pass -from PyQt4.QtCore import pyqtSlot, pyqtSignal, QObject, QT_TRANSLATE_NOOP, QUrl, \ - QBuffer, QIODevice, QFileInfo, Qt, QTimer, QEvent, QRect, QFile, QPoint, \ - QByteArray, qVersion +from PyQt4.QtCore import pyqtSlot, pyqtSignal, QObject, QT_TRANSLATE_NOOP, \ + QUrl, QBuffer, QIODevice, QFileInfo, Qt, QTimer, QEvent, QRect, QFile, \ + QPoint, QByteArray, qVersion from PyQt4.QtGui import qApp, QDesktopServices, QStyle, QMenu, QApplication, \ - QInputDialog, QLineEdit, QClipboard, QMouseEvent, QLabel, QToolTip, QColor, \ - QPalette, QFrame, QPrinter, QPrintDialog, QDialog + QInputDialog, QLineEdit, QClipboard, QMouseEvent, QLabel, QToolTip, \ + QColor, QPalette, QFrame, QPrinter, QPrintDialog, QDialog from PyQt4.QtWebKit import QWebView, QWebPage, QWebSettings try: from PyQt4.QtWebKit import QWebElement @@ -39,7 +39,7 @@ except ImportError: SSL_AVAILABLE = False -########################################################################################## +############################################################################### class JavaScriptExternalObject(QObject): @@ -80,16 +80,19 @@ self.href = "" self.title = "" -########################################################################################## +############################################################################### class JavaScriptEricObject(QObject): """ - Class implementing an external javascript object to search via the startpage. + Class implementing an external javascript object to search via the + startpage. """ - # these must be in line with the strings used by the javascript part of the start page + # these must be in line with the strings used by the javascript part of + # the start page translations = [ - QT_TRANSLATE_NOOP("JavaScriptEricObject", "Welcome to eric5 Web Browser!"), + QT_TRANSLATE_NOOP("JavaScriptEricObject", + "Welcome to eric5 Web Browser!"), QT_TRANSLATE_NOOP("JavaScriptEricObject", "eric5 Web Browser"), QT_TRANSLATE_NOOP("JavaScriptEricObject", "Search!"), QT_TRANSLATE_NOOP("JavaScriptEricObject", "About eric5"), @@ -145,7 +148,7 @@ self.__mw.openSearchManager().currentEngine()\ .searchUrl(searchStr).toEncoded()).decode() -########################################################################################## +############################################################################### class HelpWebPage(QWebPage): @@ -168,7 +171,8 @@ self.__lastRequestType = QWebPage.NavigationTypeOther import Helpviewer.HelpWindow - from .Network.NetworkAccessManagerProxy import NetworkAccessManagerProxy + from .Network.NetworkAccessManagerProxy import \ + NetworkAccessManagerProxy self.__proxy = NetworkAccessManagerProxy(self) self.__proxy.setWebPage(self) self.__proxy.setPrimaryNetworkAccessManager( @@ -203,11 +207,12 @@ if type_ == QWebPage.NavigationTypeFormResubmitted: res = E5MessageBox.yesNo(self.view(), self.trUtf8("Resending POST request"), - self.trUtf8("""In order to display the site, the request along with""" - """ all the data must be sent once again, which may lead""" - """ to some unexpected behaviour of the site e.g. the""" - """ same action might be performed once again. Do you want""" - """ to continue anyway?"""), + self.trUtf8( + """In order to display the site, the request along with""" + """ all the data must be sent once again, which may lead""" + """ to some unexpected behaviour of the site e.g. the""" + """ same action might be performed once again. Do you""" + """ want to continue anyway?"""), icon=E5MessageBox.Warning) if not res: return False @@ -218,14 +223,18 @@ """ Public method to add data to a network request. - @param request reference to the network request object (QNetworkRequest) + @param request reference to the network request object + (QNetworkRequest) """ try: request.setAttribute(QNetworkRequest.User + 100, self) if self.__lastRequest.url() == request.url(): - request.setAttribute(QNetworkRequest.User + 101, self.__lastRequestType) - if self.__lastRequestType == QWebPage.NavigationTypeLinkClicked: - request.setRawHeader("X-Eric5-UserLoadAction", QByteArray("1")) + request.setAttribute(QNetworkRequest.User + 101, + self.__lastRequestType) + if self.__lastRequestType == \ + QWebPage.NavigationTypeLinkClicked: + request.setRawHeader("X-Eric5-UserLoadAction", + QByteArray("1")) except TypeError: pass @@ -258,13 +267,16 @@ Public method to implement a specific extension. @param extension extension to be executed (QWebPage.Extension) - @param option provides input to the extension (QWebPage.ExtensionOption) + @param option provides input to the extension + (QWebPage.ExtensionOption) @param output stores the output results (QWebPage.ExtensionReturn) @return flag indicating a successful call of the extension (boolean) """ if extension == QWebPage.ChooseMultipleFilesExtension: - info = sip.cast(option, QWebPage.ChooseMultipleFilesExtensionOption) - files = sip.cast(output, QWebPage.ChooseMultipleFilesExtensionReturn) + info = sip.cast(option, + QWebPage.ChooseMultipleFilesExtensionOption) + files = sip.cast(output, + QWebPage.ChooseMultipleFilesExtensionReturn) if info is None or files is None: return super(HelpWebPage, self).extension(extension, option, output) @@ -281,7 +293,8 @@ if extension == QWebPage.ErrorPageExtension: info = sip.cast(option, QWebPage.ErrorPageExtensionOption) if info.error == 102: - # this is something of a hack; hopefully it will work in the future + # this is something of a hack; hopefully it will work in + # the future return False errorPage = sip.cast(output, QWebPage.ErrorPageExtensionReturn) @@ -292,7 +305,8 @@ info.errorString.startswith("AdBlockRule:"): if info.frame != info.frame.page().mainFrame(): # content in <iframe> - docElement = info.frame.page().mainFrame().documentElement() + docElement = info.frame.page().mainFrame()\ + .documentElement() for element in docElement.findAll("iframe"): src = element.attribute("src") if src in info.url.toString(): @@ -302,13 +316,16 @@ # the whole page is blocked rule = info.errorString.replace("AdBlockRule:", "") title = self.trUtf8("Content blocked by AdBlock Plus") - message = self.trUtf8("Blocked by rule: <i>{0}</i>").format(rule) + message = self.trUtf8( + "Blocked by rule: <i>{0}</i>").format(rule) htmlFile = QFile(":/html/adblockPage.html") htmlFile.open(QFile.ReadOnly) html = htmlFile.readAll() - html = html.replace("@FAVICON@", "qrc:icons/adBlockPlus16.png") - html = html.replace("@IMAGE@", "qrc:icons/adBlockPlus64.png") + html = html.replace( + "@FAVICON@", "qrc:icons/adBlockPlus16.png") + html = html.replace( + "@IMAGE@", "qrc:icons/adBlockPlus64.png") html = html.replace("@TITLE@", title.encode("utf8")) html = html.replace("@MESSAGE@", message.encode("utf8")) errorPage.content = html @@ -334,27 +351,32 @@ imageBuffer = QBuffer() imageBuffer.open(QIODevice.ReadWrite) if pixmap.save(imageBuffer, "PNG"): - html = html.replace("@FAVICON@", imageBuffer.buffer().toBase64()) + html = html.replace( + "@FAVICON@", imageBuffer.buffer().toBase64()) html = html.replace("@TITLE@", title.encode("utf8")) html = html.replace("@H1@", info.errorString.encode("utf8")) - html = html.replace("@H2@", self.trUtf8("When connecting to: {0}.")\ + html = html.replace( + "@H2@", self.trUtf8("When connecting to: {0}.")\ .format(urlString).encode("utf8")) html = html.replace("@LI-1@", self.trUtf8("Check the address for errors such as " "<b>ww</b>.example.org instead of " "<b>www</b>.example.org").encode("utf8")) html = html.replace("@LI-2@", - self.trUtf8("If the address is correct, try checking the network " - "connection.").encode("utf8")) + self.trUtf8( + "If the address is correct, try checking the network " + "connection.").encode("utf8")) html = html.replace("@LI-3@", - self.trUtf8("If your computer or network is protected by a firewall " - "or proxy, make sure that the browser is permitted to " - "access the network.").encode("utf8")) + self.trUtf8( + "If your computer or network is protected by a firewall " + "or proxy, make sure that the browser is permitted to " + "access the network.").encode("utf8")) html = html.replace("@LI-4@", self.trUtf8("If your cache policy is set to offline browsing," "only pages in the local cache are available.")\ .encode("utf8")) - html = html.replace("@BUTTON@", self.trUtf8("Try Again").encode("utf8")) + html = html.replace( + "@BUTTON@", self.trUtf8("Try Again").encode("utf8")) errorPage.content = html return True @@ -423,7 +445,8 @@ @return user agent string (string) """ import Helpviewer.HelpWindow - agent = Helpviewer.HelpWindow.HelpWindow.userAgentsManager().userAgentForUrl(url) + agent = Helpviewer.HelpWindow.HelpWindow.userAgentsManager()\ + .userAgentForUrl(url) if agent == "": # no agent string specified for the given host -> use global one agent = Preferences.getHelp("UserAgent") @@ -469,7 +492,8 @@ manager = Helpviewer.HelpWindow.HelpWindow.bookmarksManager() from .Bookmarks.BookmarkNode import BookmarkNode for bookmark in manager.bookmarksForUrl(reply.url()): - manager.setTimestamp(bookmark, BookmarkNode.TsModified, modified) + manager.setTimestamp(bookmark, BookmarkNode.TsModified, + modified) def getSslCertificate(self): """ @@ -507,11 +531,13 @@ def showSslInfo(self, pos): """ Public slot to show some SSL information for the loaded page. + + @param pos position to show the info at (QPoint) """ if SSL_AVAILABLE and self.__sslConfiguration is not None: from E5Network.E5SslInfoWidget import E5SslInfoWidget - widget = E5SslInfoWidget(self.mainFrame().url(), self.__sslConfiguration, - self.view()) + widget = E5SslInfoWidget( + self.mainFrame().url(), self.__sslConfiguration, self.view()) widget.showAt(pos) else: E5MessageBox.warning(self.view(), @@ -580,7 +606,7 @@ return super(HelpWebPage, self).event(evt) -########################################################################################## +############################################################################### class HelpBrowser(QWebView): @@ -622,8 +648,8 @@ super(HelpBrowser, self).__init__(parent) self.setObjectName(name) self.setWhatsThis(self.trUtf8( - """<b>Help Window</b>""" - """<p>This window displays the selected help information.</p>""" + """<b>Help Window</b>""" + """<p>This window displays the selected help information.</p>""" )) import Helpviewer.HelpWindow @@ -693,7 +719,8 @@ @param frame reference to the web frame (QWebFrame) """ - self.page().settings().setAttribute(QWebSettings.JavascriptEnabled, True) + self.page().settings().setAttribute(QWebSettings.JavascriptEnabled, + True) if self.__javaScriptBinding is None: self.__javaScriptBinding = JavaScriptExternalObject(self.mw, self) @@ -704,14 +731,19 @@ frame = frame.mainFrame() if frame.url().scheme() == "eric" and frame.url().path() == "home": if self.__javaScriptEricObject is None: - self.__javaScriptEricObject = JavaScriptEricObject(self.mw, self) - frame.addToJavaScriptWindowObject("eric", self.__javaScriptEricObject) - elif frame.url().scheme() == "eric" and frame.url().path() == "speeddial": - frame.addToJavaScriptWindowObject("speeddial", self.__speedDial) + self.__javaScriptEricObject = JavaScriptEricObject( + self.mw, self) + frame.addToJavaScriptWindowObject( + "eric", self.__javaScriptEricObject) + elif frame.url().scheme() == "eric" and \ + frame.url().path() == "speeddial": + frame.addToJavaScriptWindowObject( + "speeddial", self.__speedDial) self.__speedDial.addWebFrame(frame) else: # called from QWebPage.frameCreated - frame.javaScriptWindowObjectCleared.connect(self.__addExternalBinding) + frame.javaScriptWindowObjectCleared.connect( + self.__addExternalBinding) frame.addToJavaScriptWindowObject("external", self.__javaScriptBinding) def linkedResources(self, relation=""): @@ -725,7 +757,8 @@ baseUrl = self.page().mainFrame().baseUrl() - linkElements = self.page().mainFrame().findAllElements("html > head > link") + linkElements = self.page().mainFrame().findAllElements( + "html > head > link") for linkElement in linkElements.toList(): rel = linkElement.attribute("rel") @@ -788,7 +821,8 @@ if not QFileInfo(name.toLocalFile()).exists(): E5MessageBox.critical(self, self.trUtf8("eric5 Web Browser"), - self.trUtf8("""<p>The file <b>{0}</b> does not exist.</p>""")\ + self.trUtf8( + """<p>The file <b>{0}</b> does not exist.</p>""")\ .format(name.toLocalFile())) return @@ -987,7 +1021,8 @@ @param case flag indicating a case sensitive search (boolean) @param backwards flag indicating a backwards search (boolean) @param wrap flag indicating to wrap around (boolean) - @param highlightAll flag indicating to highlight all occurrences (boolean) + @param highlightAll flag indicating to highlight all occurrences + (boolean) @return flag indicating that a match was found (boolean) """ findFlags = QWebPage.FindFlags() @@ -1020,7 +1055,8 @@ This method is overridden from QWebView. - @param evt reference to the context menu event object (QContextMenuEvent) + @param evt reference to the context menu event object + (QContextMenuEvent) """ from .UserAgent.UserAgentMenu import UserAgentMenu menu = QMenu(self) @@ -1040,13 +1076,16 @@ menu.addSeparator() menu.addAction(UI.PixmapCache.getIcon("editCopy.png"), self.trUtf8("Copy Link to Clipboard"), self.__copyLink) - menu.addAction(UI.PixmapCache.getIcon("mailSend.png"), - self.trUtf8("Send Link"), self.__sendLink).setData(hit.linkUrl()) + menu.addAction( + UI.PixmapCache.getIcon("mailSend.png"), + self.trUtf8("Send Link"), + self.__sendLink).setData(hit.linkUrl()) if Preferences.getHelp("VirusTotalEnabled") and \ Preferences.getHelp("VirusTotalServiceKey") != "": - menu.addAction(UI.PixmapCache.getIcon("virustotal.png"), - self.trUtf8("Scan Link with VirusTotal"), self.__virusTotal)\ - .setData(hit.linkUrl()) + menu.addAction( + UI.PixmapCache.getIcon("virustotal.png"), + self.trUtf8("Scan Link with VirusTotal"), + self.__virusTotal).setData(hit.linkUrl()) if not hit.imageUrl().isEmpty(): if not menu.isEmpty(): @@ -1057,21 +1096,25 @@ menu.addSeparator() menu.addAction(UI.PixmapCache.getIcon("download.png"), self.trUtf8("Save Image"), self.__downloadImage) - menu.addAction(self.trUtf8("Copy Image to Clipboard"), self.__copyImage) + menu.addAction( + self.trUtf8("Copy Image to Clipboard"), self.__copyImage) menu.addAction(UI.PixmapCache.getIcon("editCopy.png"), self.trUtf8("Copy Image Location to Clipboard"), self.__copyLocation).setData(hit.imageUrl().toString()) - menu.addAction(UI.PixmapCache.getIcon("mailSend.png"), - self.trUtf8("Send Image Link"), self.__sendLink).setData(hit.imageUrl()) + menu.addAction( + UI.PixmapCache.getIcon("mailSend.png"), + self.trUtf8("Send Image Link"), + self.__sendLink).setData(hit.imageUrl()) menu.addSeparator() menu.addAction(UI.PixmapCache.getIcon("adBlockPlus.png"), self.trUtf8("Block Image"), self.__blockImage)\ .setData(hit.imageUrl().toString()) if Preferences.getHelp("VirusTotalEnabled") and \ Preferences.getHelp("VirusTotalServiceKey") != "": - menu.addAction(UI.PixmapCache.getIcon("virustotal.png"), - self.trUtf8("Scan Image with VirusTotal"), self.__virusTotal)\ - .setData(hit.imageUrl()) + menu.addAction( + UI.PixmapCache.getIcon("virustotal.png"), + self.trUtf8("Scan Image with VirusTotal"), + self.__virusTotal).setData(hit.imageUrl()) element = hit.element() if not element.isNull(): @@ -1086,16 +1129,20 @@ videoUrl = QUrl(element.evaluateJavaScript("this.currentSrc")) if paused: - menu.addAction(UI.PixmapCache.getIcon("mediaPlaybackStart.png"), + menu.addAction( + UI.PixmapCache.getIcon("mediaPlaybackStart.png"), self.trUtf8("Play"), self.__pauseMedia) else: - menu.addAction(UI.PixmapCache.getIcon("mediaPlaybackPause.png"), + menu.addAction( + UI.PixmapCache.getIcon("mediaPlaybackPause.png"), self.trUtf8("Pause"), self.__pauseMedia) if muted: - menu.addAction(UI.PixmapCache.getIcon("audioVolumeHigh.png"), + menu.addAction( + UI.PixmapCache.getIcon("audioVolumeHigh.png"), self.trUtf8("Unmute"), self.__muteMedia) else: - menu.addAction(UI.PixmapCache.getIcon("audioVolumeMuted.png"), + menu.addAction( + UI.PixmapCache.getIcon("audioVolumeMuted.png"), self.trUtf8("Mute"), self.__muteMedia) menu.addSeparator() menu.addAction(UI.PixmapCache.getIcon("editCopy.png"), @@ -1111,14 +1158,16 @@ if element.tagName().lower() in ["input", "textarea"]: if menu.isEmpty(): pageMenu = self.page().createStandardContextMenu() - directionFound = False # used to detect double direction entry + directionFound = False # used to detect double + # direction entry for act in pageMenu.actions(): if act.isSeparator(): menu.addSeparator() continue if act.menu(): - if self.pageAction(QWebPage.SetTextDirectionDefault) in \ - act.menu().actions(): + if self.pageAction( + QWebPage.SetTextDirectionDefault) in \ + act.menu().actions(): if directionFound: act.setVisible(False) directionFound = True @@ -1178,7 +1227,8 @@ menu.addAction(UI.PixmapCache.getIcon("mailSend.png"), self.trUtf8("Send Page Link"), self.__sendLink).setData(self.url()) menu.addSeparator() - self.__userAgentMenu = UserAgentMenu(self.trUtf8("User Agent"), url=self.url()) + self.__userAgentMenu = UserAgentMenu(self.trUtf8("User Agent"), + url=self.url()) menu.addMenu(self.__userAgentMenu) menu.addSeparator() menu.addAction(self.mw.backAct) @@ -1191,14 +1241,17 @@ menu.addSeparator() if self.selectedText(): menu.addAction(self.mw.copyAct) - menu.addAction(UI.PixmapCache.getIcon("mailSend.png"), - self.trUtf8("Send Text"), self.__sendLink).setData(self.selectedText()) + menu.addAction( + UI.PixmapCache.getIcon("mailSend.png"), + self.trUtf8("Send Text"), + self.__sendLink).setData(self.selectedText()) menu.addAction(self.mw.findAct) menu.addSeparator() if self.selectedText(): self.__searchMenu = menu.addMenu(self.trUtf8("Search with...")) - from .OpenSearch.OpenSearchEngineAction import OpenSearchEngineAction + from .OpenSearch.OpenSearchEngineAction import \ + OpenSearchEngineAction engineNames = self.mw.openSearchManager().allEnginesNames() for engineName in engineNames: engine = self.mw.openSearchManager().engine(engineName) @@ -1223,8 +1276,8 @@ self.trUtf8("Google Translate"), self.__openLinkInNewTab)\ .setData(googleTranslatorUrl) wiktionaryUrl = QUrl( - "http://{0}.wiktionary.org/wiki/Special:Search?search={1}".format( - langCode, self.selectedText())) + "http://{0}.wiktionary.org/wiki/Special:Search?search={1}" + .format(langCode, self.selectedText())) menu.addAction(UI.PixmapCache.getIcon("wikipedia.png"), self.trUtf8("Dictionary"), self.__openLinkInNewTab)\ .setData(wiktionaryUrl) @@ -1232,8 +1285,9 @@ guessedUrl = QUrl.fromUserInput(self.selectedText().strip()) if self.__isUrlValid(guessedUrl): - menu.addAction(self.trUtf8("Go to web address"), self.__openLinkInNewTab)\ - .setData(guessedUrl) + menu.addAction( + self.trUtf8("Go to web address"), + self.__openLinkInNewTab).setData(guessedUrl) menu.addSeparator() element = hit.element() @@ -1263,7 +1317,8 @@ def __openLinkInNewTab(self): """ - Private method called by the context menu to open a link in a new window. + Private method called by the context menu to open a link in a new + window. """ act = self.sender() url = act.data() @@ -1419,7 +1474,8 @@ if method != "get": E5MessageBox.warning(self, self.trUtf8("Method not supported"), - self.trUtf8("""{0} method is not supported.""").format(method.upper())) + self.trUtf8( + """{0} method is not supported.""").format(method.upper())) return searchUrl = QUrl(self.page().mainFrame().baseUrl().resolved( @@ -1449,7 +1505,8 @@ selectFields = formElement.findAll("select") for selectField in selectFields.toList(): name = selectField.attribute("name") - selectedIndex = selectField.evaluateJavaScript("this.selectedIndex") + selectedIndex = selectField.evaluateJavaScript( + "this.selectedIndex") if selectedIndex == -1: continue @@ -1469,7 +1526,8 @@ return if searchEngines[searchEngine] != "": - searchUrl.addQueryItem(searchEngines[searchEngine], searchEngine) + searchUrl.addQueryItem( + searchEngines[searchEngine], searchEngine) engineName = "" labels = formElement.findAll('label[for="{0}"]'.format(elementName)) @@ -1702,9 +1760,9 @@ self.history().clear() self.__urlChanged(self.history().currentItem().url()) - ############################################################################ + ########################################################################### ## Signal converters below - ############################################################################ + ########################################################################### def __urlChanged(self, url): """ @@ -1735,9 +1793,9 @@ """ self.highlighted.emit(link) - ############################################################################ + ########################################################################### ## Signal handlers below - ############################################################################ + ########################################################################### def __loadStarted(self): """ @@ -1783,6 +1841,8 @@ def progress(self): """ Public method to get the load progress. + + @return load progress (integer) """ return self.__progress @@ -1796,7 +1856,8 @@ self.mw.downloadManager().download(url, True, mainWindow=self.mw) - def __unsupportedContent(self, reply, requestFilename=None, download=False): + def __unsupportedContent(self, reply, requestFilename=None, + download=False): """ Private slot to handle the unsupportedContent signal. @@ -1863,14 +1924,16 @@ self.trUtf8("If the address is correct, try checking the network " "connection.").encode("utf8")) html = html.replace("@LI-3@", - self.trUtf8("If your computer or network is protected by a firewall " - "or proxy, make sure that the browser is permitted to " - "access the network.").encode("utf8")) + self.trUtf8( + "If your computer or network is protected by a firewall " + "or proxy, make sure that the browser is permitted to " + "access the network.").encode("utf8")) html = html.replace("@LI-4@", self.trUtf8("If your cache policy is set to offline browsing," "only pages in the local cache are available.")\ .encode("utf8")) - html = html.replace("@BUTTON@", self.trUtf8("Try Again").encode("utf8")) + html = html.replace( + "@BUTTON@", self.trUtf8("Try Again").encode("utf8")) notFoundFrame.setHtml(bytes(html).decode("utf8"), replyUrl) self.mw.historyManager().removeHistoryEntry(replyUrl, self.title()) self.loadFinished.emit(False) @@ -1899,20 +1962,25 @@ res = E5MessageBox.yesNo(self, self.trUtf8("Web Database Quota"), - self.trUtf8("""<p>The database quota of <strong>{0}</strong> has""" - """ been exceeded while accessing database <strong>{1}""" - """</strong>.</p><p>Shall it be changed?</p>""")\ - .format(self.__dataString(securityOrigin.databaseQuota()), databaseName), + self.trUtf8( + """<p>The database quota of <strong>{0}</strong> has""" + """ been exceeded while accessing database <strong>{1}""" + """</strong>.</p><p>Shall it be changed?</p>""")\ + .format(self.__dataString(securityOrigin.databaseQuota()), + databaseName), yesDefault=True) if res: newQuota, ok = QInputDialog.getInt( self, self.trUtf8("New Web Database Quota"), - self.trUtf8("Enter the new quota in MB (current = {0}, used = {1}; " - "step size = 5 MB):"\ - .format(self.__dataString(securityOrigin.databaseQuota()), - self.__dataString(securityOrigin.databaseUsage()))), - securityOrigin.databaseQuota() // (1024 * 1024), 0, 2147483647, 5) + self.trUtf8( + "Enter the new quota in MB (current = {0}, used = {1}; " + "step size = 5 MB):"\ + .format( + self.__dataString(securityOrigin.databaseQuota()), + self.__dataString(securityOrigin.databaseUsage()))), + securityOrigin.databaseQuota() // (1024 * 1024), + 0, 2147483647, 5) if ok: securityOrigin.setDatabaseQuota(newQuota * 1024 * 1024) @@ -1934,9 +2002,9 @@ unit = self.trUtf8("MB") return "{0:.1f} {1}".format(size, unit) - ############################################################################ + ########################################################################### ## Access key related methods below - ############################################################################ + ########################################################################### def __accessKeyShortcut(self): """ @@ -1980,11 +2048,15 @@ while frame and frame != self.page().mainFrame(): p -= frame.scrollPosition() frame = frame.parentFrame() - pevent = QMouseEvent(QEvent.MouseButtonPress, p, Qt.LeftButton, - Qt.MouseButtons(Qt.NoButton), Qt.KeyboardModifiers(Qt.NoModifier)) + pevent = QMouseEvent( + QEvent.MouseButtonPress, p, Qt.LeftButton, + Qt.MouseButtons(Qt.NoButton), + Qt.KeyboardModifiers(Qt.NoModifier)) qApp.sendEvent(self, pevent) - revent = QMouseEvent(QEvent.MouseButtonRelease, p, Qt.LeftButton, - Qt.MouseButtons(Qt.NoButton), Qt.KeyboardModifiers(Qt.NoModifier)) + revent = QMouseEvent( + QEvent.MouseButtonRelease, p, Qt.LeftButton, + Qt.MouseButtons(Qt.NoButton), + Qt.KeyboardModifiers(Qt.NoModifier)) qApp.sendEvent(self, revent) handled = True @@ -2017,7 +2089,8 @@ # Priority first goes to elements with accesskey attributes alreadyLabeled = [] for elementType in supportedElements: - result = self.page().mainFrame().findAllElements(elementType).toList() + result = self.page().mainFrame().findAllElements(elementType)\ + .toList() for element in result: geometry = element.geometry() if geometry.size().isEmpty() or \ @@ -2041,10 +2114,11 @@ self.__makeAccessLabel(accessKey, element) alreadyLabeled.append(element) - # Pick an access key first from the letters in the text and then from the - # list of unused access keys + # Pick an access key first from the letters in the text and then + # from the list of unused access keys for elementType in supportedElements: - result = self.page().mainFrame().findAllElements(elementType).toList() + result = self.page().mainFrame().findAllElements(elementType)\ + .toList() for element in result: geometry = element.geometry() if not unusedKeys or \ @@ -2091,15 +2165,16 @@ self.__accessKeyLabels.append(label) self.__accessKeyNodes[accessKey] = element - ############################################################################ + ########################################################################### ## Miscellaneous methods below - ############################################################################ + ########################################################################### def createWindow(self, windowType): """ Protected method called, when a new window should be created. @param windowType type of the requested window (QWebPage.WebWindowType) + @return reference to the created browser window (HelpBrowser) """ self.mw.newTab() return self.mw.currentBrowser() @@ -2114,9 +2189,9 @@ self.reload() - ############################################################################ + ########################################################################### ## RSS related methods below - ############################################################################ + ########################################################################### def checkRSS(self): """ @@ -2160,9 +2235,9 @@ """ return len(self.__rss) > 0 - ############################################################################ + ########################################################################### ## Clicked Frame slots - ############################################################################ + ########################################################################### def __loadClickedFrame(self): """ @@ -2199,8 +2274,9 @@ except AttributeError: E5MessageBox.critical(self, self.trUtf8("eric5 Web Browser"), - self.trUtf8("""<p>Printing is not available due to a bug in PyQt4.""" - """Please upgrade.</p>""")) + self.trUtf8( + """<p>Printing is not available due to a bug in""" + """ PyQt4. Please upgrade.</p>""")) def __printPreviewClickedFrame(self): """ @@ -2241,8 +2317,9 @@ except AttributeError: E5MessageBox.critical(self, self.trUtf8("eric5 Web Browser"), - self.trUtf8("""<p>Printing is not available due to a bug in PyQt4.""" - """Please upgrade.</p>""")) + self.trUtf8( + """<p>Printing is not available due to a bug in PyQt4.""" + """Please upgrade.</p>""")) return def __printPdfClickedFrame(self): @@ -2269,17 +2346,20 @@ except AttributeError: E5MessageBox.critical(self, self.trUtf8("eric5 Web Browser"), - self.trUtf8("""<p>Printing is not available due to a bug in PyQt4.""" - """Please upgrade.</p>""")) + self.trUtf8( + """<p>Printing is not available due to a bug in""" + """ PyQt4. Please upgrade.</p>""")) return def __zoomInClickedFrame(self): """ Private slot to zoom into the clicked frame. """ - index = self.__levelForZoom(int(self.__clickedFrame.zoomFactor() * 100)) + index = self.__levelForZoom( + int(self.__clickedFrame.zoomFactor() * 100)) if index < len(self.__zoomLevels) - 1: - self.__clickedFrame.setZoomFactor(self.__zoomLevels[index + 1] / 100) + self.__clickedFrame.setZoomFactor( + self.__zoomLevels[index + 1] / 100) def __zoomResetClickedFrame(self): """ @@ -2291,9 +2371,11 @@ """ Private slot to zoom out of the clicked frame. """ - index = self.__levelForZoom(int(self.__clickedFrame.zoomFactor() * 100)) + index = self.__levelForZoom( + int(self.__clickedFrame.zoomFactor() * 100)) if index > 0: - self.__clickedFrame.setZoomFactor(self.__zoomLevels[index - 1] / 100) + self.__clickedFrame.setZoomFactor( + self.__zoomLevels[index - 1] / 100) def __showClickedFrameSource(self): """ @@ -2311,6 +2393,7 @@ """ Module function to do some content sniffing to check, if the data is HTML. + @param data data block to sniff at (string) @return flag indicating HTML content (boolean) """ if data.contains("<!doctype") or \