Repository: qutebrowser/qutebrowser

Issue:
Add a :download-clear
It seems `:download-remove --all` is hard to figure out, so we should add a `:download-clear` command.



Discussion:
This would be useless if qutebrowser provided a page similar to `qute:log` for downloads such as `qute:downloads`.  An alias `:downloads` could simply be`:open -t qute:downloads`.

With this in place each entry in the `qute:downloads` page could be removed with links at the top to remove all.

Doing `:downloads` and clicking/hinting a button is a lot more work than doing `:downloads-clear` though :wink:

This is in reference to https://github.com/The-Compiler/qutebrowser/issues/1059


Resolving patch:
diff --git a/qutebrowser/browser/downloads.py b/qutebrowser/browser/downloads.py
--- a/qutebrowser/browser/downloads.py
+++ b/qutebrowser/browser/downloads.py
@@ -964,18 +964,25 @@ def can_clear(self):
         """Check if there are finished downloads to clear."""
         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',
                        count='count')
     def download_remove(self, all_=False, count=0):
         """Remove the last/[count]th download from the list.
 
         Args:
-            all_: If given removes all finished downloads.
+            all_: Deprecated argument for removing all finished downloads.
             count: The index of the download to cancel.
         """
         if all_:
-            finished_items = [d for d in self.downloads if d.done]
-            self.remove_items(finished_items)
+            message.warning(self._win_id, ":download-remove --all is "
+                            "deprecated - use :download-clear instead!")
+            self.download_clear()
         else:
             try:
                 download = self.downloads[count - 1]
diff --git a/qutebrowser/config/configdata.py b/qutebrowser/config/configdata.py
--- a/qutebrowser/config/configdata.py
+++ b/qutebrowser/config/configdata.py
@@ -1373,7 +1373,7 @@ def data(readonly=False):
         ('inspector', ['wi']),
         ('download', ['gd']),
         ('download-cancel', ['ad']),
-        ('download-remove --all', ['cd']),
+        ('download-clear', ['cd']),
         ('view-source', ['gf']),
         ('tab-focus last', ['<Ctrl-Tab>']),
         ('enter-mode passthrough', ['<Ctrl-V>']),
@@ -1497,4 +1497,6 @@ def data(readonly=False):
 
     (re.compile(r'^search *;; *clear-keychain$'), r'clear-keychain ;; search'),
     (re.compile(r'^leave-mode$'), r'clear-keychain ;; leave-mode'),
+
+    (re.compile(r'^download-remove --all$'), r'download-clear'),
 ]


Test patch:
diff --git a/tests/unit/config/test_config.py b/tests/unit/config/test_config.py
--- a/tests/unit/config/test_config.py
+++ b/tests/unit/config/test_config.py
@@ -251,6 +251,8 @@ def test_default_config_no_deprecated(self, rgx):
             ('search;;foo', None),
             ('leave-mode', 'clear-keychain ;; leave-mode'),
             ('leave-mode ;; foo', None),
+
+            ('download-remove --all', 'download-clear'),
         ]
     )
     def test_migrations(self, old, new_expected):