Implement :download/hints via QtNetwork
This commit is contained in:
parent
5bc3914f24
commit
ce1b675a1e
@ -1294,8 +1294,7 @@ class CommandDispatcher:
|
|||||||
except inspector.WebInspectorError as e:
|
except inspector.WebInspectorError as e:
|
||||||
raise cmdexc.CommandError(e)
|
raise cmdexc.CommandError(e)
|
||||||
|
|
||||||
@cmdutils.register(instance='command-dispatcher', scope='window',
|
@cmdutils.register(instance='command-dispatcher', scope='window')
|
||||||
backend=usertypes.Backend.QtWebKit)
|
|
||||||
@cmdutils.argument('dest_old', hide=True)
|
@cmdutils.argument('dest_old', hide=True)
|
||||||
def download(self, url=None, dest_old=None, *, mhtml_=False, dest=None):
|
def download(self, url=None, dest_old=None, *, mhtml_=False, dest=None):
|
||||||
"""Download a given URL, or current page if no URL given.
|
"""Download a given URL, or current page if no URL given.
|
||||||
@ -1335,10 +1334,16 @@ class CommandDispatcher:
|
|||||||
self._download_mhtml(dest)
|
self._download_mhtml(dest)
|
||||||
else:
|
else:
|
||||||
tab = self._current_widget()
|
tab = self._current_widget()
|
||||||
|
|
||||||
# FIXME:qtwebengine have a proper API for this
|
# FIXME:qtwebengine have a proper API for this
|
||||||
# pylint: disable=protected-access
|
# pylint: disable=protected-access
|
||||||
qnam = tab._widget.page().networkAccessManager()
|
try:
|
||||||
|
qnam = tab._widget.page().networkAccessManager()
|
||||||
|
except AttributeError:
|
||||||
|
# QtWebEngine
|
||||||
|
qnam = None
|
||||||
# pylint: enable=protected-access
|
# pylint: enable=protected-access
|
||||||
|
|
||||||
if dest is None:
|
if dest is None:
|
||||||
target = None
|
target = None
|
||||||
else:
|
else:
|
||||||
@ -1352,6 +1357,10 @@ class CommandDispatcher:
|
|||||||
dest: The file path to write the download to.
|
dest: The file path to write the download to.
|
||||||
"""
|
"""
|
||||||
tab = self._current_widget()
|
tab = self._current_widget()
|
||||||
|
if tab.backend == usertypes.Backend.QtWebEngine:
|
||||||
|
raise cmdexc.CommandError("Download --mhtml is not implemented "
|
||||||
|
"with QtWebEngine yet")
|
||||||
|
|
||||||
if dest is None:
|
if dest is None:
|
||||||
suggested_fn = self._current_title() + ".mht"
|
suggested_fn = self._current_title() + ".mht"
|
||||||
suggested_fn = utils.sanitize_filename(suggested_fn)
|
suggested_fn = utils.sanitize_filename(suggested_fn)
|
||||||
|
@ -285,7 +285,11 @@ class HintActions:
|
|||||||
|
|
||||||
# FIXME:qtwebengine get a proper API for this
|
# FIXME:qtwebengine get a proper API for this
|
||||||
# pylint: disable=protected-access
|
# pylint: disable=protected-access
|
||||||
qnam = elem._elem.webFrame().page().networkAccessManager()
|
try:
|
||||||
|
qnam = elem._elem.webFrame().page().networkAccessManager()
|
||||||
|
except AttributeError:
|
||||||
|
# QtWebEngine
|
||||||
|
qnam = None
|
||||||
# pylint: enable=protected-access
|
# pylint: enable=protected-access
|
||||||
|
|
||||||
# FIXME:qtwebengine do this with QtWebEngine downloads?
|
# FIXME:qtwebengine do this with QtWebEngine downloads?
|
||||||
@ -663,11 +667,6 @@ class HintManager(QObject):
|
|||||||
tab = tabbed_browser.currentWidget()
|
tab = tabbed_browser.currentWidget()
|
||||||
if tab is None:
|
if tab is None:
|
||||||
raise cmdexc.CommandError("No WebView available yet!")
|
raise cmdexc.CommandError("No WebView available yet!")
|
||||||
if (tab.backend == usertypes.Backend.QtWebEngine and
|
|
||||||
target == Target.download):
|
|
||||||
message.error("The download target is not available yet with "
|
|
||||||
"QtWebEngine.")
|
|
||||||
return
|
|
||||||
|
|
||||||
mode_manager = objreg.get('mode-manager', scope='window',
|
mode_manager = objreg.get('mode-manager', scope='window',
|
||||||
window=self._win_id)
|
window=self._win_id)
|
||||||
|
@ -25,10 +25,6 @@ import pytest_bdd as bdd
|
|||||||
bdd.scenarios('downloads.feature')
|
bdd.scenarios('downloads.feature')
|
||||||
|
|
||||||
|
|
||||||
pytestmark = pytest.mark.qtwebengine_todo("Downloads not implemented yet",
|
|
||||||
run=False)
|
|
||||||
|
|
||||||
|
|
||||||
PROMPT_MSG = ("Asking question <qutebrowser.utils.usertypes.Question "
|
PROMPT_MSG = ("Asking question <qutebrowser.utils.usertypes.Question "
|
||||||
"default={!r} mode=<PromptMode.download: 5> text=* "
|
"default={!r} mode=<PromptMode.download: 5> text=* "
|
||||||
"title='Save file to:'>, *")
|
"title='Save file to:'>, *")
|
||||||
|
Loading…
Reference in New Issue
Block a user