From 8c1bb148f36b1fb225cc4d84b9809e4fdcbf99a1 Mon Sep 17 00:00:00 2001 From: John van de Wetering Date: Tue, 16 Jul 2024 21:22:05 -0300 Subject: [PATCH] Fixed breaking bug with boolean set values --- zxlive/common.py | 6 ++++-- zxlive/settings_dialog.py | 1 + 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/zxlive/common.py b/zxlive/common.py index d45c3c6..2cb0465 100644 --- a/zxlive/common.py +++ b/zxlive/common.py @@ -17,17 +17,19 @@ T = TypeVar('T') - def get_data(path: str) -> str: return os.path.join(os.environ.get("_MEIPASS", _ROOT), path) def get_settings_value(arg: str, _type: Type[T], default: T | None = None, settings: QSettings | None = None) -> T: _settings = settings or QSettings("zxlive", "zxlive") + if _type == bool: + val = _settings.value(arg, default) + return str(val) == "True" or str(val) == "true" if not isinstance(val := _settings.value(arg, default), _type): if default is not None: return default - raise ValueError(f"Unexpected type for {val}: expected {_type}, got {type(val)}") + raise ValueError(f"Unexpected type for {arg} ({val}): expected {_type}, got {type(val)}") return val def get_custom_rules_path() -> str: diff --git a/zxlive/settings_dialog.py b/zxlive/settings_dialog.py index de12a9f..14ca83a 100644 --- a/zxlive/settings_dialog.py +++ b/zxlive/settings_dialog.py @@ -279,6 +279,7 @@ def update_global_settings(self) -> None: self.settings.setValue(name, widget.currentData()) elif isinstance(widget, QCheckBox): self.settings.setValue(name, widget.isChecked()) + self.settings.sync() display_setting.update() def apply_global_settings(self) -> None: