From 5a34fdfd0cc9c278775f8ccce2327817b8167c77 Mon Sep 17 00:00:00 2001 From: skinnay Date: Thu, 29 Oct 2015 13:40:14 -0400 Subject: [PATCH 1/6] Changed the functionality of "remove-finished-downloads" setting. Instead of being a boolean value indicating whether or not to instantly remove downloads when they finish, it's now an integer value representing the number of milliseconds to wait before removing downloads when they finish. The default value, -1, means that the downloads will not be removed when they finished. This is the same behavior as the previous default value of false. --- qutebrowser/browser/downloads.py | 13 ++++++++++--- qutebrowser/config/configdata.py | 5 +++-- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/qutebrowser/browser/downloads.py b/qutebrowser/browser/downloads.py index b6bf651ed..12d00547a 100644 --- a/qutebrowser/browser/downloads.py +++ b/qutebrowser/browser/downloads.py @@ -771,7 +771,7 @@ class DownloadManager(QAbstractListModel): fileobj: The file object to write the answer to. filename: A path to write the data to. auto_remove: Whether to remove the download even if - ui -> remove-finished-downloads is set to false. + ui -> remove-finished-downloads is set to -1. Return: The created DownloadItem. @@ -790,9 +790,10 @@ class DownloadManager(QAbstractListModel): download = DownloadItem(reply, self._win_id, self) download.cancelled.connect( functools.partial(self.remove_item, download)) - if config.get('ui', 'remove-finished-downloads') or auto_remove: + delay = config.get('ui', 'remove-finished-downloads') + if delay > -1 or auto_remove: download.finished.connect( - functools.partial(self.remove_item, download)) + functools.partial(self.remove_item_delayed, download, delay)) download.data_changed.connect( functools.partial(self.on_data_changed, download)) download.error.connect(self.on_error) @@ -1011,6 +1012,12 @@ class DownloadManager(QAbstractListModel): if not self.downloads: self._update_timer.stop() + + def remove_item_delayed(self, download, delay): + """Remove a given download after a short delay.""" + QTimer.singleShot(delay, functools.partial(self.remove_item, download)) + + def remove_items(self, downloads): """Remove an iterable of downloads.""" # On the first pass, we only generate the indices so we get the diff --git a/qutebrowser/config/configdata.py b/qutebrowser/config/configdata.py index f4fe2b1a1..a5d4c00b8 100644 --- a/qutebrowser/config/configdata.py +++ b/qutebrowser/config/configdata.py @@ -291,8 +291,9 @@ def data(readonly=False): "Whether to enable smooth scrolling for webpages."), ('remove-finished-downloads', - SettingValue(typ.Bool(), 'false'), - "Whether to remove finished downloads automatically."), + SettingValue(typ.Int(minval=-1), '-1'), + "Number of milliseconds to wait before removing finished " + "downloads. Will not be removed if value is -1."), ('hide-statusbar', SettingValue(typ.Bool(), 'false'), From af70e783b63da15068ca5b38876459b89c347974 Mon Sep 17 00:00:00 2001 From: skinnay Date: Thu, 29 Oct 2015 14:49:16 -0400 Subject: [PATCH 2/6] removed extra whitespace --- qutebrowser/browser/downloads.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/qutebrowser/browser/downloads.py b/qutebrowser/browser/downloads.py index 12d00547a..187e23e1c 100644 --- a/qutebrowser/browser/downloads.py +++ b/qutebrowser/browser/downloads.py @@ -1012,12 +1012,10 @@ class DownloadManager(QAbstractListModel): if not self.downloads: self._update_timer.stop() - def remove_item_delayed(self, download, delay): """Remove a given download after a short delay.""" QTimer.singleShot(delay, functools.partial(self.remove_item, download)) - def remove_items(self, downloads): """Remove an iterable of downloads.""" # On the first pass, we only generate the indices so we get the From 6125e51de3df34b29f8ecf1a2810fa085bd71509 Mon Sep 17 00:00:00 2001 From: skinnay Date: Thu, 29 Oct 2015 14:54:54 -0400 Subject: [PATCH 3/6] removed whitespace --- qutebrowser/browser/downloads.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/qutebrowser/browser/downloads.py b/qutebrowser/browser/downloads.py index 12d00547a..187e23e1c 100644 --- a/qutebrowser/browser/downloads.py +++ b/qutebrowser/browser/downloads.py @@ -1012,12 +1012,10 @@ class DownloadManager(QAbstractListModel): if not self.downloads: self._update_timer.stop() - def remove_item_delayed(self, download, delay): """Remove a given download after a short delay.""" QTimer.singleShot(delay, functools.partial(self.remove_item, download)) - def remove_items(self, downloads): """Remove an iterable of downloads.""" # On the first pass, we only generate the indices so we get the From 11e5774f46bf29d8869bef20d1b786c285e39923 Mon Sep 17 00:00:00 2001 From: skinnay Date: Fri, 30 Oct 2015 19:37:43 -0400 Subject: [PATCH 4/6] Changed _get_value_transformer function to take a dictionary mapping old values to new values as input. Added entry for changing remove-finished-downloads setting to new int value. --- qutebrowser/config/config.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/qutebrowser/config/config.py b/qutebrowser/config/config.py index 9dbcaf4cf..b3471b2fb 100644 --- a/qutebrowser/config/config.py +++ b/qutebrowser/config/config.py @@ -255,21 +255,20 @@ def init(parent=None): _init_misc() -def _get_value_transformer(old, new): +def _get_value_transformer(mapping): """Get a function which transforms a value for CHANGED_OPTIONS. Args: - old: The old value - if the supplied value doesn't match this, it's - returned untransformed. - new: The new value. + mapping: A dictionary mapping old values to new values. Value is not + transformed if the supplied value doesn't match the old value. Return: A function which takes a value and transforms it. """ def transformer(val): - if val == old: - return new - else: + try: + return mapping[val] + except KeyError: return val return transformer @@ -352,9 +351,11 @@ class ConfigManager(QObject): ] CHANGED_OPTIONS = { ('content', 'cookies-accept'): - _get_value_transformer('default', 'no-3rdparty'), + _get_value_transformer({'default': 'no-3rdparty'}), ('tabs', 'position'): _transform_position, ('ui', 'downloads-position'): _transform_position, + ('ui', 'remove-finished-downloads'): + _get_value_transformer({'false': '-1', 'true': '2000'}) } changed = pyqtSignal(str, str) From d9af27670bbf4179406e4c96d210ee4d1b2463b2 Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Mon, 2 Nov 2015 17:58:08 +0100 Subject: [PATCH 5/6] Transform remove-finished-downloads=true to 1s. 2s seems rather long. --- qutebrowser/config/config.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qutebrowser/config/config.py b/qutebrowser/config/config.py index b3471b2fb..55502c5da 100644 --- a/qutebrowser/config/config.py +++ b/qutebrowser/config/config.py @@ -355,7 +355,7 @@ class ConfigManager(QObject): ('tabs', 'position'): _transform_position, ('ui', 'downloads-position'): _transform_position, ('ui', 'remove-finished-downloads'): - _get_value_transformer({'false': '-1', 'true': '2000'}) + _get_value_transformer({'false': '-1', 'true': '1000'}) } changed = pyqtSignal(str, str) From 4da2bdfaa7327027a8e78100eae616ea3bbe7021 Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Mon, 2 Nov 2015 17:59:43 +0100 Subject: [PATCH 6/6] Update docs. --- CHANGELOG.asciidoc | 3 +++ README.asciidoc | 1 + doc/help/settings.asciidoc | 11 +++-------- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.asciidoc b/CHANGELOG.asciidoc index 9b005368e..0167c9607 100644 --- a/CHANGELOG.asciidoc +++ b/CHANGELOG.asciidoc @@ -59,6 +59,9 @@ Changed - New design for error pages - Link filtering for hints now checks if the text is contained anywhere in the link, and matches case-insensitively. +- The `ui -> remove-finished-downloads` option got changed to an integer and + now takes a time (in milliseconds) to keep the download around after it's + finished. When set to `-1`, downloads are never removed. Fixed ~~~~~ diff --git a/README.asciidoc b/README.asciidoc index 2054c1dab..a28b089cc 100644 --- a/README.asciidoc +++ b/README.asciidoc @@ -155,6 +155,7 @@ Contributors, sorted by the number of commits in descending order: * Peter Vilim * Jonas Schürmann * Jimmy +* skinnay * Zach-Button * rikn00 * Patric Schmitz diff --git a/doc/help/settings.asciidoc b/doc/help/settings.asciidoc index 5209baf47..24536dbf5 100644 --- a/doc/help/settings.asciidoc +++ b/doc/help/settings.asciidoc @@ -42,7 +42,7 @@ |<>|User stylesheet to use (absolute filename, filename relative to the config directory or CSS string). Will expand environment variables. |<>|Set the CSS media type. |<>|Whether to enable smooth scrolling for webpages. -|<>|Whether to remove finished downloads automatically. +|<>|Number of milliseconds to wait before removing finished downloads. Will not be removed if value is -1. |<>|Whether to hide the statusbar unless a message is shown. |<>|Padding for statusbar (top, bottom, left, right). |<>|The format to use for the window title. The following placeholders are defined: @@ -593,14 +593,9 @@ Default: +pass:[false]+ [[ui-remove-finished-downloads]] === remove-finished-downloads -Whether to remove finished downloads automatically. +Number of milliseconds to wait before removing finished downloads. Will not be removed if value is -1. -Valid values: - - * +true+ - * +false+ - -Default: +pass:[false]+ +Default: +pass:[-1]+ [[ui-hide-statusbar]] === hide-statusbar