Clean up overriding of javaScriptPrompt.

This commit is contained in:
Florian Bruhin 2014-10-08 05:20:56 +02:00
parent d41fd85a87
commit 86f08a8536

View File

@ -63,26 +63,20 @@ class BrowserPage(QWebPage):
self.downloadRequested.connect(self.on_download_requested) self.downloadRequested.connect(self.on_download_requested)
self.unsupportedContent.connect(self.on_unsupported_content) self.unsupportedContent.connect(self.on_unsupported_content)
if PYQT_VERSION > 0x050300: if PYQT_VERSION > 0x050300:
# WORKAROUND (remove this when we bump the requirements to 5.3.1) # WORKAROUND (remove this when we bump the requirements to 5.3.1)
# See http://www.riverbankcomputing.com/pipermail/pyqt/2014-June/034385.html # We can't override javaScriptPrompt with older PyQt-versions because
# pylint: disable=invalid-name # of a bug in PyQt.
self.javaScriptPrompt = self._javascript_prompt # See http://www.riverbankcomputing.com/pipermail/pyqt/2014-June/034385.html
def _javascript_prompt(self, _frame, msg, default): def javaScriptPrompt(self, _frame, msg, default):
"""Override javaScriptPrompt to use the statusbar. """Override javaScriptPrompt to use the statusbar."""
answer = message.ask(self._win_id, "js: {}".format(msg),
We use this approach and override the method conditionally in __init__ usertypes.PromptMode.text, default)
because overriding javaScriptPrompt was broken in 5.3.0. if answer is None:
return (False, "")
http://www.riverbankcomputing.com/pipermail/pyqt/2014-June/034385.html else:
""" return (True, answer)
answer = message.ask(self._win_id, "js: {}".format(msg),
usertypes.PromptMode.text, default)
if answer is None:
return (False, "")
else:
return (True, answer)
def _handle_errorpage(self, opt, out): def _handle_errorpage(self, opt, out):
"""Display an error page if needed. """Display an error page if needed.