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.
This commit is contained in:
parent
6f07eb562f
commit
5a34fdfd0c
@ -771,7 +771,7 @@ class DownloadManager(QAbstractListModel):
|
|||||||
fileobj: The file object to write the answer to.
|
fileobj: The file object to write the answer to.
|
||||||
filename: A path to write the data to.
|
filename: A path to write the data to.
|
||||||
auto_remove: Whether to remove the download even if
|
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:
|
Return:
|
||||||
The created DownloadItem.
|
The created DownloadItem.
|
||||||
@ -790,9 +790,10 @@ class DownloadManager(QAbstractListModel):
|
|||||||
download = DownloadItem(reply, self._win_id, self)
|
download = DownloadItem(reply, self._win_id, self)
|
||||||
download.cancelled.connect(
|
download.cancelled.connect(
|
||||||
functools.partial(self.remove_item, download))
|
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(
|
download.finished.connect(
|
||||||
functools.partial(self.remove_item, download))
|
functools.partial(self.remove_item_delayed, download, delay))
|
||||||
download.data_changed.connect(
|
download.data_changed.connect(
|
||||||
functools.partial(self.on_data_changed, download))
|
functools.partial(self.on_data_changed, download))
|
||||||
download.error.connect(self.on_error)
|
download.error.connect(self.on_error)
|
||||||
@ -1011,6 +1012,12 @@ class DownloadManager(QAbstractListModel):
|
|||||||
if not self.downloads:
|
if not self.downloads:
|
||||||
self._update_timer.stop()
|
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):
|
def remove_items(self, downloads):
|
||||||
"""Remove an iterable of downloads."""
|
"""Remove an iterable of downloads."""
|
||||||
# On the first pass, we only generate the indices so we get the
|
# On the first pass, we only generate the indices so we get the
|
||||||
|
@ -291,8 +291,9 @@ def data(readonly=False):
|
|||||||
"Whether to enable smooth scrolling for webpages."),
|
"Whether to enable smooth scrolling for webpages."),
|
||||||
|
|
||||||
('remove-finished-downloads',
|
('remove-finished-downloads',
|
||||||
SettingValue(typ.Bool(), 'false'),
|
SettingValue(typ.Int(minval=-1), '-1'),
|
||||||
"Whether to remove finished downloads automatically."),
|
"Number of milliseconds to wait before removing finished "
|
||||||
|
"downloads. Will not be removed if value is -1."),
|
||||||
|
|
||||||
('hide-statusbar',
|
('hide-statusbar',
|
||||||
SettingValue(typ.Bool(), 'false'),
|
SettingValue(typ.Bool(), 'false'),
|
||||||
|
Loading…
Reference in New Issue
Block a user