Add dwb download keybindings.
This commit is contained in:
parent
9c26eba761
commit
6b12572fb0
18
TODO
18
TODO
@ -123,21 +123,6 @@ wo
|
||||
Open url in a new instance (command: winopen, aliases: wopen, w).
|
||||
|
||||
|
||||
downloads
|
||||
---------
|
||||
|
||||
;d
|
||||
Download via hints (command hints_download, aliases: dhints).
|
||||
|
||||
[n]ad
|
||||
Cancel the download with number n or the first download in the lists of running downloads if n is omitted. (command cancel_download).
|
||||
|
||||
gd
|
||||
Download the current site. (command download).
|
||||
|
||||
Sd
|
||||
Show download (command show_downloads, aliases: sdownloads).
|
||||
|
||||
Bookmarks/quickmarks
|
||||
--------------------
|
||||
|
||||
@ -223,6 +208,9 @@ Show settings (command show_settings, aliases: ssettings).
|
||||
eu
|
||||
Show and execute userscripts (command execute_userscript).
|
||||
|
||||
Sd
|
||||
Show download (command show_downloads, aliases: sdownloads).
|
||||
|
||||
|
||||
Other
|
||||
-----
|
||||
|
@ -653,6 +653,13 @@ class CommandDispatcher:
|
||||
else:
|
||||
cur.inspector.show()
|
||||
|
||||
@cmdutils.register(instance='mainwindow.tabs.cmd')
|
||||
def download_page(self):
|
||||
"""Download the current page."""
|
||||
widget = self._tabs.currentWidget()
|
||||
url = urlutils.urlstring(widget.url())
|
||||
QApplication.instance().downloadmanager.get(url)
|
||||
|
||||
@cmdutils.register(instance='mainwindow.tabs.cmd', modes=['insert'],
|
||||
hide=True)
|
||||
def open_editor(self):
|
||||
|
@ -24,15 +24,18 @@ import os.path
|
||||
from functools import partial
|
||||
from collections import deque
|
||||
|
||||
from PyQt5.QtCore import pyqtSlot, pyqtSignal, QObject
|
||||
from PyQt5.QtNetwork import QNetworkReply
|
||||
from PyQt5.QtCore import pyqtSlot, pyqtSignal, QObject, QCoreApplication
|
||||
from PyQt5.QtNetwork import QNetworkRequest, QNetworkReply
|
||||
|
||||
import qutebrowser.config.config as config
|
||||
import qutebrowser.utils.message as message
|
||||
import qutebrowser.utils.url as urlutils
|
||||
import qutebrowser.commands.utils as cmdutils
|
||||
from qutebrowser.utils.log import downloads as logger
|
||||
from qutebrowser.utils.usertypes import PromptMode, Question, Timer
|
||||
from qutebrowser.utils.misc import (interpolate_color, format_seconds,
|
||||
format_size, get_http_header)
|
||||
from qutebrowser.commands.exceptions import CommandError
|
||||
|
||||
|
||||
class DownloadItem(QObject):
|
||||
@ -334,6 +337,27 @@ class DownloadManager(QObject):
|
||||
filename = 'qutebrowser-download'
|
||||
return os.path.basename(filename)
|
||||
|
||||
def get(self, link):
|
||||
"""Start a download with a link URL.
|
||||
|
||||
Args:
|
||||
link: The link URL as a string.
|
||||
"""
|
||||
req = QNetworkRequest(urlutils.qurl(link))
|
||||
reply = QCoreApplication.instance().networkmanager.get(req)
|
||||
self.fetch(reply)
|
||||
|
||||
@cmdutils.register(instance='downloadmanager')
|
||||
def cancel_download(self, count=1):
|
||||
"""Cancel the first/[count]th download."""
|
||||
if count == 0:
|
||||
return
|
||||
try:
|
||||
download = self.downloads[count - 1]
|
||||
except IndexError:
|
||||
raise CommandError("There's no download {}!".format(count))
|
||||
download.cancel()
|
||||
|
||||
@pyqtSlot('QNetworkReply')
|
||||
def fetch(self, reply):
|
||||
"""Download a QNetworkReply to disk.
|
||||
|
@ -40,7 +40,7 @@ ElemTuple = namedtuple('ElemTuple', 'elem, label')
|
||||
|
||||
|
||||
Target = enum('normal', 'tab', 'tab_bg', 'yank', 'yank_primary', 'cmd',
|
||||
'cmd_tab', 'cmd_tab_bg', 'rapid')
|
||||
'cmd_tab', 'cmd_tab_bg', 'rapid', 'download')
|
||||
|
||||
|
||||
class HintContext:
|
||||
@ -56,6 +56,7 @@ class HintContext:
|
||||
yank/yank_primary: Yank to clipboard/primary selection
|
||||
cmd/cmd_tab/cmd_tab_bg: Enter link to commandline
|
||||
rapid: Rapid mode with background tabs
|
||||
download: Download the link.
|
||||
to_follow: The link to follow when enter is pressed.
|
||||
connected_frames: The QWebFrames which are connected to a signal.
|
||||
"""
|
||||
@ -115,6 +116,7 @@ class HintManager(QObject):
|
||||
Target.cmd_tab: "Set hint in commandline as new tab...",
|
||||
Target.cmd_tab_bg: "Set hint in commandline as background tab...",
|
||||
Target.rapid: "Follow hint (rapid mode)...",
|
||||
Target.download: "Download hint...",
|
||||
}
|
||||
|
||||
hint_strings_updated = pyqtSignal(list)
|
||||
@ -318,6 +320,14 @@ class HintManager(QObject):
|
||||
message.set_cmd_text(':{} {}'.format(commands[self._context.target],
|
||||
urlutils.urlstring(link)))
|
||||
|
||||
def _download(self, link):
|
||||
"""Download a hint URL.
|
||||
|
||||
Args:
|
||||
link: The link to download.
|
||||
"""
|
||||
QApplication.instance().downloadmanager.get(link)
|
||||
|
||||
def _resolve_link(self, elem, baseurl=None):
|
||||
"""Resolve a link and check if we want to keep it.
|
||||
|
||||
@ -505,6 +515,7 @@ class HintManager(QObject):
|
||||
Target.cmd: self._preset_cmd_text,
|
||||
Target.cmd_tab: self._preset_cmd_text,
|
||||
Target.cmd_tab_bg: self._preset_cmd_text,
|
||||
Target.download: self._download,
|
||||
}
|
||||
elem = self._context.elems[keystr].elem
|
||||
if self._context.target in elem_handlers:
|
||||
|
@ -624,6 +624,7 @@ DATA = OrderedDict([
|
||||
(';y', 'hint links yank'),
|
||||
(';Y', 'hint links yank-primary'),
|
||||
(';r', 'hint links rapid'),
|
||||
(';d', 'hint links download'),
|
||||
('h', 'scroll -50 0'),
|
||||
('j', 'scroll 0 50'),
|
||||
('k', 'scroll 0 -50'),
|
||||
@ -658,6 +659,8 @@ DATA = OrderedDict([
|
||||
('{{', 'prev-page-tab'),
|
||||
('}}', 'next-page-tab'),
|
||||
('wi', 'inspector'),
|
||||
('gd', 'download-page'),
|
||||
('ad', 'cancel-download'),
|
||||
('<Ctrl-Tab>', 'tab-focus-last'),
|
||||
('<Ctrl-V>', 'enter-mode passthrough'),
|
||||
('<Ctrl-Q>', 'quit'),
|
||||
|
Loading…
Reference in New Issue
Block a user