Merge branch 'master' of https://github.com/forkbong/qutebrowser into forkbong-master

This commit is contained in:
Florian Bruhin 2015-11-04 07:12:32 +01:00
commit 6c20190473
4 changed files with 20 additions and 4 deletions

View File

@ -14,6 +14,7 @@
|<<close,close>>|Close the current window. |<<close,close>>|Close the current window.
|<<download,download>>|Download a given URL, or current page if no URL given. |<<download,download>>|Download a given URL, or current page if no URL given.
|<<download-cancel,download-cancel>>|Cancel the last/[count]th download. |<<download-cancel,download-cancel>>|Cancel the last/[count]th download.
|<<download-clear,download-clear>>|Remove all finished downloads from the list.
|<<download-delete,download-delete>>|Delete the last/[count]th download from disk. |<<download-delete,download-delete>>|Delete the last/[count]th download from disk.
|<<download-open,download-open>>|Open the last/[count]th download. |<<download-open,download-open>>|Open the last/[count]th download.
|<<download-remove,download-remove>>|Remove the last/[count]th download from the list. |<<download-remove,download-remove>>|Remove the last/[count]th download from the list.
@ -158,6 +159,10 @@ Cancel the last/[count]th download.
==== count ==== count
The index of the download to cancel. The index of the download to cancel.
[[download-clear]]
=== download-clear
Remove all finished downloads from the list.
[[download-delete]] [[download-delete]]
=== download-delete === download-delete
Delete the last/[count]th download from disk. Delete the last/[count]th download from disk.

View File

@ -964,18 +964,25 @@ class DownloadManager(QAbstractListModel):
"""Check if there are finished downloads to clear.""" """Check if there are finished downloads to clear."""
return any(download.done for download in self.downloads) return any(download.done for download in self.downloads)
@cmdutils.register(instance='download-manager', scope='window')
def download_clear(self):
"""Remove all finished downloads from the list."""
finished_items = [d for d in self.downloads if d.done]
self.remove_items(finished_items)
@cmdutils.register(instance='download-manager', scope='window', @cmdutils.register(instance='download-manager', scope='window',
count='count') count='count')
def download_remove(self, all_=False, count=0): def download_remove(self, all_=False, count=0):
"""Remove the last/[count]th download from the list. """Remove the last/[count]th download from the list.
Args: Args:
all_: If given removes all finished downloads. all_: Deprecated argument for removing all finished downloads.
count: The index of the download to cancel. count: The index of the download to cancel.
""" """
if all_: if all_:
finished_items = [d for d in self.downloads if d.done] message.warning(self._win_id, ":download-remove --all is "
self.remove_items(finished_items) "deprecated - use :download-clear instead!")
self.download_clear()
else: else:
try: try:
download = self.downloads[count - 1] download = self.downloads[count - 1]

View File

@ -1373,7 +1373,7 @@ KEY_DATA = collections.OrderedDict([
('inspector', ['wi']), ('inspector', ['wi']),
('download', ['gd']), ('download', ['gd']),
('download-cancel', ['ad']), ('download-cancel', ['ad']),
('download-remove --all', ['cd']), ('download-clear', ['cd']),
('view-source', ['gf']), ('view-source', ['gf']),
('tab-focus last', ['<Ctrl-Tab>']), ('tab-focus last', ['<Ctrl-Tab>']),
('enter-mode passthrough', ['<Ctrl-V>']), ('enter-mode passthrough', ['<Ctrl-V>']),
@ -1497,4 +1497,6 @@ CHANGED_KEY_COMMANDS = [
(re.compile(r'^search *;; *clear-keychain$'), r'clear-keychain ;; search'), (re.compile(r'^search *;; *clear-keychain$'), r'clear-keychain ;; search'),
(re.compile(r'^leave-mode$'), r'clear-keychain ;; leave-mode'), (re.compile(r'^leave-mode$'), r'clear-keychain ;; leave-mode'),
(re.compile(r'^download-remove --all$'), r'download-clear'),
] ]

View File

@ -251,6 +251,8 @@ class TestKeyConfigParser:
('search;;foo', None), ('search;;foo', None),
('leave-mode', 'clear-keychain ;; leave-mode'), ('leave-mode', 'clear-keychain ;; leave-mode'),
('leave-mode ;; foo', None), ('leave-mode ;; foo', None),
('download-remove --all', 'download-clear'),
] ]
) )
def test_migrations(self, old, new_expected): def test_migrations(self, old, new_expected):