Skip to content
Snippets Groups Projects
Commit 95d69594 authored by inso's avatar inso
Browse files

Fix parameters handling in non-default profiles

parent b4e8697f
No related branches found
No related tags found
No related merge requests found
......@@ -101,7 +101,7 @@ class Application(QObject):
:return:
"""
self.plugins_dir = PluginsDirectory.in_config_path(self.options.config_path, profile_name).load_or_init(self.options.with_plugin)
self.parameters = UserParametersFile.in_config_path(self.options.config_path, profile_name).load_or_init()
self.parameters = UserParametersFile.in_config_path(self.options.config_path, profile_name).load_or_init(profile_name)
self.db = SakiaDatabase.load_or_init(self.options, profile_name)
self.instanciate_services()
......
......@@ -31,7 +31,7 @@ class UserParametersFile:
json.dump(attr.asdict(user_parameters), outfile, indent=4)
return user_parameters
def load_or_init(self):
def load_or_init(self, profile_name):
"""
Update an existing user_parameters in the database
:param sakia.data.entities.UserParameters user_parameters: the user_parameters to update
......@@ -39,6 +39,7 @@ class UserParametersFile:
try:
with open(self._file, 'r') as json_data:
user_parameters = UserParameters(**json.load(json_data))
user_parameters.profile_name = profile_name
except OSError:
user_parameters = UserParameters()
user_parameters = UserParameters(profile_name=profile_name)
return user_parameters
......@@ -56,7 +56,8 @@ class PreferencesDialog(QDialog, Ui_PreferencesDialog):
self.edit_proxy_address.setEnabled(self.checkbox_proxy.isChecked())
def accept(self):
parameters = UserParameters(lang=self.combo_language.currentText(),
parameters = UserParameters(profile_name=self.app.parameters.profile_name,
lang=self.combo_language.currentText(),
referential=self.combo_referential.currentIndex(),
expert_mode=self.checkbox_expertmode.isChecked(),
maximized=self.checkbox_maximize.isChecked(),
......
......@@ -10,5 +10,5 @@ def test_init_save_load():
user_parameters_file = UserParametersFile(file)
user_parameters.proxy_address = "test.fr"
user_parameters_file.save(user_parameters)
user_parameters_2 = user_parameters_file.load_or_init()
user_parameters_2 = user_parameters_file.load_or_init("Default Profile")
assert user_parameters == user_parameters_2
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment