From 038bc8c0eff4b2663cd896cf343e4581bfe07294 Mon Sep 17 00:00:00 2001 From: jupfi Date: Wed, 13 Mar 2024 12:02:52 +0100 Subject: [PATCH] Only emit settings changed signal when it really has been changed. --- src/nqrduck_spectrometer/settings.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/nqrduck_spectrometer/settings.py b/src/nqrduck_spectrometer/settings.py index eb0c26b..5b62571 100644 --- a/src/nqrduck_spectrometer/settings.py +++ b/src/nqrduck_spectrometer/settings.py @@ -146,11 +146,10 @@ class IntSetting(Setting): def value(self, value): try: self._value = int(value) + self.settings_changed.emit() except ValueError: raise ValueError("Value must be an int") - self.settings_changed.emit() - - + class BooleanSetting(Setting): """A setting that is a Boolean.""" @@ -168,9 +167,10 @@ class BooleanSetting(Setting): def value(self, value): try: self._value = bool(value) + self.settings_changed.emit() except ValueError: raise ValueError("Value must be a bool") - self.settings_changed.emit() + def get_widget(self): """Return a widget for the setting. @@ -212,14 +212,14 @@ class SelectionSetting(Setting): try: if value in self.options: self._value = value + self.settings_changed.emit() else: raise ValueError("Value must be one of the options") # This fixes a bug when creating the widget when the options are not yet set except AttributeError: self._value = value self.options = [value] - - self.settings_changed.emit() + self.settings_changed.emit() def get_widget(self): """Return a widget for the setting. @@ -272,7 +272,8 @@ class StringSetting(Setting): def value(self, value): try: self._value = str(value) + self.settings_changed.emit() except ValueError: raise ValueError("Value must be a string") - self.settings_changed.emit() +