inlines fix, menu fix, settings upgrade

This commit is contained in:
ingvar1995 2016-04-24 23:24:48 +03:00
parent ee15359c19
commit 9b02089bff
3 changed files with 34 additions and 13 deletions

View file

@ -15,6 +15,7 @@ class Settings(Singleton, dict):
with open(self.path) as fl:
data = fl.read()
super(self.__class__, self).__init__(json.loads(data))
self.upgrade()
else:
super(self.__class__, self).__init__(Settings.get_default_settings())
self.save()
@ -37,7 +38,7 @@ class Settings(Singleton, dict):
p = Settings.get_default_path() + 'toxygen.json'
data = json.dumps({'path': unicode(path.decode(locale.getpreferredencoding())), 'name': unicode(name)})
with open(p, 'w') as fl:
fl.write(data)
fl.write(data)
@staticmethod
def get_default_settings():
@ -62,7 +63,8 @@ class Settings(Singleton, dict):
'auto_accept_from_friends': [],
'friends_aliases': [],
'typing_notifications': True,
'calls_sound': True
'calls_sound': True,
'blocked': []
}
@staticmethod
@ -73,6 +75,13 @@ class Settings(Singleton, dict):
('French', 'fr_FR')
]
def upgrade(self):
default = Settings.get_default_settings()
for key in default:
if key not in self:
self[key] = default[key]
self.save()
def save(self):
text = json.dumps(self)
with open(self.path, 'w') as fl: