Skip to content

Commit

Permalink
Fixed breaking bug with boolean set values
Browse files Browse the repository at this point in the history
  • Loading branch information
jvdwetering committed Jul 17, 2024
1 parent 6d99563 commit 8c1bb14
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
6 changes: 4 additions & 2 deletions zxlive/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
1 change: 1 addition & 0 deletions zxlive/settings_dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 8c1bb14

Please sign in to comment.