From fb6e758607ce3c0f023e30c1691eafdd6bc91215 Mon Sep 17 00:00:00 2001 From: misyaguziya <53165965+misyaguziya@users.noreply.github.com> Date: Wed, 11 Dec 2024 01:08:30 +0900 Subject: [PATCH] =?UTF-8?q?=F0=9F=91=8D=EF=B8=8F[Update]=20Config=20:=20?= =?UTF-8?q?=E4=B8=80=E9=83=A8config=E3=82=92=E5=8D=B3=E6=99=82=E3=81=AB?= =?UTF-8?q?=E4=BF=9D=E5=AD=98=E3=81=99=E3=82=8B=E3=82=88=E3=81=86=E3=81=AB?= =?UTF-8?q?=E5=A4=89=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src-python/config.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src-python/config.py b/src-python/config.py index 94881d75..f6358472 100644 --- a/src-python/config.py +++ b/src-python/config.py @@ -35,14 +35,18 @@ class Config: with open(self.PATH_CONFIG, "w", encoding="utf-8") as fp: json_dump(self._config_data, fp, indent=4, ensure_ascii=False) - def saveConfig(self, key, value): + def saveConfig(self, key, value, immediate_save=False): self._config_data[key] = value if isinstance(self._timer, threading.Timer) and self._timer.is_alive(): self._timer.cancel() - self._timer = threading.Timer(self._debounce_time, self.saveConfigToFile) - self._timer.daemon = True - self._timer.start() + + if immediate_save: + self.saveConfigToFile() + else: + self._timer = threading.Timer(self._debounce_time, self.saveConfigToFile) + self._timer.daemon = True + self._timer.start() # Read Only @property @@ -381,7 +385,7 @@ class Config: def MESSAGE_BOX_RATIO(self, value): if isinstance(value, (int, float)): self._MESSAGE_BOX_RATIO = value - self.saveConfig(inspect.currentframe().f_code.co_name, value) + self.saveConfig(inspect.currentframe().f_code.co_name, value, immediate_save=True) @property @json_serializable('FONT_FAMILY') @@ -417,7 +421,7 @@ class Config: for key, value in value.items(): if isinstance(value, int): self._MAIN_WINDOW_GEOMETRY[key] = value - self.saveConfig(inspect.currentframe().f_code.co_name, self.MAIN_WINDOW_GEOMETRY) + self.saveConfig(inspect.currentframe().f_code.co_name, self.MAIN_WINDOW_GEOMETRY, immediate_save=True) @property @json_serializable('AUTO_MIC_SELECT')