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.
This commit is contained in:
parent
88ba4831a8
commit
11e5774f46
@ -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': '2000'})
|
||||||
}
|
}
|
||||||
|
|
||||||
changed = pyqtSignal(str, str)
|
changed = pyqtSignal(str, str)
|
||||||
|
Loading…
Reference in New Issue
Block a user