Skip to content

Commit 3ed6324

Browse files
committed
settings: dont duplicate the active plugin config per setting
and use a more understandable key
1 parent 4b4178c commit 3ed6324

File tree

2 files changed

+11
-17
lines changed

2 files changed

+11
-17
lines changed

safeeyes/ui/settings_dialog.py

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -421,21 +421,21 @@ def __init__(self, application, config):
421421
self.__load_int_item(
422422
setting["label"],
423423
setting["id"],
424-
setting["safeeyes_config"],
424+
config["active_plugin_config"],
425425
setting.get("min", 0),
426426
setting.get("max", 120),
427427
)
428428
)
429429
elif setting["type"].upper() == "TEXT":
430430
box_settings.append(
431431
self.__load_text_item(
432-
setting["label"], setting["id"], setting["safeeyes_config"]
432+
setting["label"], setting["id"], config["active_plugin_config"]
433433
)
434434
)
435435
elif setting["type"].upper() == "BOOL":
436436
box_settings.append(
437437
self.__load_bool_item(
438-
setting["label"], setting["id"], setting["safeeyes_config"]
438+
setting["label"], setting["id"], config["active_plugin_config"]
439439
)
440440
)
441441

@@ -450,9 +450,7 @@ def __load_int_item(self, name, key, settings, min_value, max_value):
450450
spin_value.set_value(settings[key])
451451
box = builder.get_object("box")
452452
box.set_visible(True)
453-
self.property_controls.append(
454-
{"key": key, "settings": settings, "value": spin_value.get_value}
455-
)
453+
self.property_controls.append({"key": key, "value": spin_value.get_value})
456454
return box
457455

458456
def __load_text_item(self, name, key, settings):
@@ -463,9 +461,7 @@ def __load_text_item(self, name, key, settings):
463461
txt_value.set_text(settings[key])
464462
box = builder.get_object("box")
465463
box.set_visible(True)
466-
self.property_controls.append(
467-
{"key": key, "settings": settings, "value": txt_value.get_text}
468-
)
464+
self.property_controls.append({"key": key, "value": txt_value.get_text})
469465
return box
470466

471467
def __load_bool_item(self, name, key, settings):
@@ -476,17 +472,15 @@ def __load_bool_item(self, name, key, settings):
476472
switch_value.set_active(settings[key])
477473
box = builder.get_object("box")
478474
box.set_visible(True)
479-
self.property_controls.append(
480-
{"key": key, "settings": settings, "value": switch_value.get_active}
481-
)
475+
self.property_controls.append({"key": key, "value": switch_value.get_active})
482476
return box
483477

484478
def on_window_delete(self, *args):
485479
"""Event handler for Properties dialog close action."""
486480
for property_control in self.property_controls:
487-
property_control["settings"][property_control["key"]] = property_control[
488-
"value"
489-
]()
481+
self.config["active_plugin_config"][property_control["key"]] = (
482+
property_control["value"]()
483+
)
490484
self.window.destroy()
491485

492486
def show(self):

safeeyes/utility.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -259,8 +259,8 @@ def load_plugins_config(safeeyes_config):
259259
config["id"] = plugin["id"]
260260
config["icon"] = icon
261261
config["enabled"] = plugin["enabled"]
262-
for setting in config["settings"]:
263-
setting["safeeyes_config"] = plugin["settings"]
262+
config["active_plugin_config"] = plugin.get("settings")
263+
264264
configs.append(config)
265265
return configs
266266

0 commit comments

Comments
 (0)