More command actions on downloads.
This commit is contained in:
parent
31e71ed6d9
commit
6f89ab628b
@ -745,20 +745,31 @@ class DownloadManager(QAbstractListModel):
|
||||
return download
|
||||
|
||||
@cmdutils.register(instance='download-manager', scope='window')
|
||||
def cancel_download(self, count: {'special': 'count'}=1):
|
||||
"""Cancel the first/[count]th download.
|
||||
def download_cancel(self, count: {'special': 'count'}=0):
|
||||
"""Cancel the last/[count]th download.
|
||||
|
||||
Args:
|
||||
count: The index of the download to cancel.
|
||||
"""
|
||||
if count == 0:
|
||||
return
|
||||
try:
|
||||
download = self.downloads[count - 1]
|
||||
except IndexError:
|
||||
raise cmdexc.CommandError("There's no download {}!".format(count))
|
||||
download.cancel()
|
||||
|
||||
@cmdutils.register(instance='download-manager', scope='window')
|
||||
def download_open(self, count: {'special': 'count'}=0):
|
||||
"""Open the last/[count]th download.
|
||||
|
||||
Args:
|
||||
count: The index of the download to cancel.
|
||||
"""
|
||||
try:
|
||||
download = self.downloads[count - 1]
|
||||
except IndexError:
|
||||
raise cmdexc.CommandError("There's no download {}!".format(count))
|
||||
download.open_file()
|
||||
|
||||
@pyqtSlot(QNetworkRequest, QNetworkReply)
|
||||
def on_redirect(self, download, request, reply):
|
||||
"""Handle a HTTP redirect of a download.
|
||||
@ -820,6 +831,8 @@ class DownloadManager(QAbstractListModel):
|
||||
else:
|
||||
return False
|
||||
|
||||
@cmdutils.register(instance='download-manager', name='downloads-clear',
|
||||
scope='window')
|
||||
def clear(self):
|
||||
"""Remove all finished downloads."""
|
||||
self.remove_items(d for d in self.downloads if d.done)
|
||||
|
@ -1029,7 +1029,7 @@ KEY_DATA = collections.OrderedDict([
|
||||
('navigate decrement', ['<Ctrl-X>']),
|
||||
('inspector', ['wi']),
|
||||
('download-page', ['gd']),
|
||||
('cancel-download', ['ad']),
|
||||
('download-cancel', ['ad']),
|
||||
('view-source', ['gf']),
|
||||
('tab-focus last', ['<Ctrl-Tab>']),
|
||||
('enter-mode passthrough', ['<Ctrl-V>']),
|
||||
|
Loading…
Reference in New Issue
Block a user