Merge branch 'skinnay-master'

This commit is contained in:
Florian Bruhin 2015-11-02 17:59:49 +01:00
commit 144acc9f91
6 changed files with 27 additions and 21 deletions

View File

@ -59,6 +59,9 @@ Changed
- New design for error pages - New design for error pages
- Link filtering for hints now checks if the text is contained anywhere in - Link filtering for hints now checks if the text is contained anywhere in
the link, and matches case-insensitively. 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 Fixed
~~~~~ ~~~~~

View File

@ -155,6 +155,7 @@ Contributors, sorted by the number of commits in descending order:
* Peter Vilim * Peter Vilim
* Jonas Schürmann * Jonas Schürmann
* Jimmy * Jimmy
* skinnay
* Zach-Button * Zach-Button
* rikn00 * rikn00
* Patric Schmitz * Patric Schmitz

View File

@ -42,7 +42,7 @@
|<<ui-user-stylesheet,user-stylesheet>>|User stylesheet to use (absolute filename, filename relative to the config directory or CSS string). Will expand environment variables. |<<ui-user-stylesheet,user-stylesheet>>|User stylesheet to use (absolute filename, filename relative to the config directory or CSS string). Will expand environment variables.
|<<ui-css-media-type,css-media-type>>|Set the CSS media type. |<<ui-css-media-type,css-media-type>>|Set the CSS media type.
|<<ui-smooth-scrolling,smooth-scrolling>>|Whether to enable smooth scrolling for webpages. |<<ui-smooth-scrolling,smooth-scrolling>>|Whether to enable smooth scrolling for webpages.
|<<ui-remove-finished-downloads,remove-finished-downloads>>|Whether to remove finished downloads automatically. |<<ui-remove-finished-downloads,remove-finished-downloads>>|Number of milliseconds to wait before removing finished downloads. Will not be removed if value is -1.
|<<ui-hide-statusbar,hide-statusbar>>|Whether to hide the statusbar unless a message is shown. |<<ui-hide-statusbar,hide-statusbar>>|Whether to hide the statusbar unless a message is shown.
|<<ui-statusbar-padding,statusbar-padding>>|Padding for statusbar (top, bottom, left, right). |<<ui-statusbar-padding,statusbar-padding>>|Padding for statusbar (top, bottom, left, right).
|<<ui-window-title-format,window-title-format>>|The format to use for the window title. The following placeholders are defined: |<<ui-window-title-format,window-title-format>>|The format to use for the window title. The following placeholders are defined:
@ -593,14 +593,9 @@ Default: +pass:[false]+
[[ui-remove-finished-downloads]] [[ui-remove-finished-downloads]]
=== 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: Default: +pass:[-1]+
* +true+
* +false+
Default: +pass:[false]+
[[ui-hide-statusbar]] [[ui-hide-statusbar]]
=== hide-statusbar === hide-statusbar

View File

@ -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,10 @@ 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

View File

@ -255,21 +255,20 @@ def init(parent=None):
_init_misc() _init_misc()
def _get_value_transformer(old, new): def _get_value_transformer(mapping):
"""Get a function which transforms a value for CHANGED_OPTIONS. """Get a function which transforms a value for CHANGED_OPTIONS.
Args: Args:
old: The old value - if the supplied value doesn't match this, it's mapping: A dictionary mapping old values to new values. Value is not
returned untransformed. transformed if the supplied value doesn't match the old value.
new: The new value.
Return: Return:
A function which takes a value and transforms it. A function which takes a value and transforms it.
""" """
def transformer(val): def transformer(val):
if val == old: try:
return new return mapping[val]
else: except KeyError:
return val return val
return transformer return transformer
@ -352,9 +351,11 @@ class ConfigManager(QObject):
] ]
CHANGED_OPTIONS = { CHANGED_OPTIONS = {
('content', 'cookies-accept'): ('content', 'cookies-accept'):
_get_value_transformer('default', 'no-3rdparty'), _get_value_transformer({'default': 'no-3rdparty'}),
('tabs', 'position'): _transform_position, ('tabs', 'position'): _transform_position,
('ui', 'downloads-position'): _transform_position, ('ui', 'downloads-position'): _transform_position,
('ui', 'remove-finished-downloads'):
_get_value_transformer({'false': '-1', 'true': '1000'})
} }
changed = pyqtSignal(str, str) changed = pyqtSignal(str, str)

View File

@ -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'),