Add a YamlConfig._migrate_bool helper
This commit is contained in:
parent
7949335a2b
commit
b0325e17b7
@ -233,6 +233,14 @@ class YamlConfig(QObject):
|
|||||||
if errors:
|
if errors:
|
||||||
raise configexc.ConfigFileErrors('autoconfig.yml', errors)
|
raise configexc.ConfigFileErrors('autoconfig.yml', errors)
|
||||||
|
|
||||||
|
def _migrate_bool(self, settings, name, true_value, false_value):
|
||||||
|
"""Migrate a boolean in the settings."""
|
||||||
|
if name in settings:
|
||||||
|
for scope, val in settings[name].items():
|
||||||
|
if isinstance(val, bool):
|
||||||
|
settings[name][scope] = true_value if val else false_value
|
||||||
|
self._mark_changed()
|
||||||
|
|
||||||
def _handle_migrations(self, settings):
|
def _handle_migrations(self, settings):
|
||||||
"""Migrate older configs to the newest format."""
|
"""Migrate older configs to the newest format."""
|
||||||
# Simple renamed/deleted options
|
# Simple renamed/deleted options
|
||||||
@ -268,23 +276,9 @@ class YamlConfig(QObject):
|
|||||||
del settings['bindings.default']
|
del settings['bindings.default']
|
||||||
self._mark_changed()
|
self._mark_changed()
|
||||||
|
|
||||||
# Option to show favicons only for pinned tabs changed the type of
|
self._migrate_bool(settings, 'tabs.favicons.show', 'always', 'never')
|
||||||
# tabs.favicons.show from Bool to String
|
self._migrate_bool(settings, 'qt.force_software_rendering',
|
||||||
name = 'tabs.favicons.show'
|
'software-opengl', 'none')
|
||||||
if name in settings:
|
|
||||||
for scope, val in settings[name].items():
|
|
||||||
if isinstance(val, bool):
|
|
||||||
settings[name][scope] = 'always' if val else 'never'
|
|
||||||
self._mark_changed()
|
|
||||||
|
|
||||||
# qt.force_software_rendering isn't a boolean anymore
|
|
||||||
name = 'qt.force_software_rendering'
|
|
||||||
if name in settings:
|
|
||||||
for scope, val in settings[name].items():
|
|
||||||
if isinstance(val, bool):
|
|
||||||
settings[name][scope] = ('software-opengl' if val
|
|
||||||
else 'none')
|
|
||||||
self._mark_changed()
|
|
||||||
|
|
||||||
return settings
|
return settings
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user