From 6f89ab628b4cef607e07bd3cfb20dee07fa65f9a Mon Sep 17 00:00:00 2001 From: Joel Torstensson Date: Sun, 8 Feb 2015 22:03:29 +0100 Subject: [PATCH] More command actions on downloads. --- qutebrowser/browser/downloads.py | 21 +++++++++++++++++---- qutebrowser/config/configdata.py | 2 +- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/qutebrowser/browser/downloads.py b/qutebrowser/browser/downloads.py index eef840dea..1677ac4e8 100644 --- a/qutebrowser/browser/downloads.py +++ b/qutebrowser/browser/downloads.py @@ -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) diff --git a/qutebrowser/config/configdata.py b/qutebrowser/config/configdata.py index ac7e4770c..a4d4d2da6 100644 --- a/qutebrowser/config/configdata.py +++ b/qutebrowser/config/configdata.py @@ -1029,7 +1029,7 @@ KEY_DATA = collections.OrderedDict([ ('navigate decrement', ['']), ('inspector', ['wi']), ('download-page', ['gd']), - ('cancel-download', ['ad']), + ('download-cancel', ['ad']), ('view-source', ['gf']), ('tab-focus last', ['']), ('enter-mode passthrough', ['']),