gui_settings.py: Handle saving values of None

This commit is contained in:
Mykola Grymalyuk
2024-10-05 12:21:34 -06:00
parent a8f76af6bc
commit 6a58ef1dab
2 changed files with 12 additions and 6 deletions

View File

@@ -430,6 +430,10 @@ class GenerateDefaults:
continue
constants_key = key.replace("GUI:", "")
if plist[key] == "PYTHON_NONE_VALUE":
plist[key] = None
if hasattr(self.constants, constants_key):
logging.info(f"Setting {constants_key} to {plist[key]}")
setattr(self.constants, constants_key, plist[key])

View File

@@ -1106,12 +1106,14 @@ Hardware Information:
def _update_setting(self, variable, value):
logging.info(f"Updating Local Setting: {variable} = {value}")
setattr(self.constants, variable, value)
global_settings.GlobalEnviromentSettings().write_property(f"GUI:{variable}", value)
tmp_value = value or "PYTHON_NONE_VALUE"
global_settings.GlobalEnviromentSettings().write_property(f"GUI:{variable}", tmp_value)
def _update_global_settings(self, variable, value, global_setting = None):
logging.info(f"Updating Global Setting: {variable} = {value}")
global_settings.GlobalEnviromentSettings().write_property(variable, value)
tmp_value = value or "PYTHON_NONE_VALUE"
global_settings.GlobalEnviromentSettings().write_property(variable, tmp_value)
if global_setting is not None:
self._update_setting(global_setting, value)
@@ -1161,12 +1163,12 @@ Hardware Information:
if hex(self.sip_value) == "0x0":
self.constants.custom_sip_value = None
self.constants.sip_status = True
global_settings.GlobalEnviromentSettings().write_property("GUI:custom_sip_value", None)
global_settings.GlobalEnviromentSettings().write_property("GUI:custom_sip_value", "PYTHON_NONE_VALUE")
global_settings.GlobalEnviromentSettings().write_property("GUI:sip_status", True)
elif hex(self.sip_value) == "0x803":
self.constants.custom_sip_value = None
self.constants.sip_status = False
global_settings.GlobalEnviromentSettings().write_property("GUI:custom_sip_value", None)
global_settings.GlobalEnviromentSettings().write_property("GUI:custom_sip_value", "PYTHON_NONE_VALUE")
global_settings.GlobalEnviromentSettings().write_property("GUI:sip_status", False)
else:
self.constants.custom_sip_value = hex(self.sip_value)
@@ -1228,7 +1230,7 @@ Hardware Information:
self.constants.fu_status = True
self.constants.fu_arguments = None
global_settings.GlobalEnviromentSettings().write_property("GUI:fu_status", True)
global_settings.GlobalEnviromentSettings().write_property("GUI:fu_arguments", "")
global_settings.GlobalEnviromentSettings().write_property("GUI:fu_arguments", "PYTHON_NONE_VALUE")
return
if value == "Partial":
@@ -1243,7 +1245,7 @@ Hardware Information:
self.constants.fu_status = False
self.constants.fu_arguments = None
global_settings.GlobalEnviromentSettings().write_property("GUI:fu_status", False)
global_settings.GlobalEnviromentSettings().write_property("GUI:fu_arguments", "")
global_settings.GlobalEnviromentSettings().write_property("GUI:fu_arguments", "PYTHON_NONE_VALUE")
def _populate_graphics_override(self, panel: wx.Panel) -> None: