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