From 69cba3460d9381cf0d4585ac49c8c54db361cd40 Mon Sep 17 00:00:00 2001 From: aclist <92275929+aclist@users.noreply.github.com> Date: Sun, 16 Aug 2026 12:45:26 +0900 Subject: [PATCH] feat: simplify API udpate signals --- dzgui/controllers/emitter.py | 4 ++++ dzgui/controllers/mc.py | 4 ++-- dzgui/managers/config.py | 11 ++++++----- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/dzgui/controllers/emitter.py b/dzgui/controllers/emitter.py index ba7ef10..28016ca 100644 --- a/dzgui/controllers/emitter.py +++ b/dzgui/controllers/emitter.py @@ -145,6 +145,10 @@ class Emitter(GObject.GObject): def api_change_failed(self) -> None: pass + @GObject.Signal(flags=GObject.SignalFlags.RUN_LAST, arg_types=()) + def api_change_successful(self) -> None: + pass + @GObject.Signal(flags=GObject.SignalFlags.RUN_LAST, arg_types=()) def already_saved_server(self) -> None: pass diff --git a/dzgui/controllers/mc.py b/dzgui/controllers/mc.py index 2a611e1..b8b69fc 100644 --- a/dzgui/controllers/mc.py +++ b/dzgui/controllers/mc.py @@ -301,8 +301,8 @@ class Controller(GObject.GObject): dialog = ExceptionDialog(self, str(e)) dialog.run() - def update_api_key(self, key: Preferences, text: str) -> None: - self.config_man.update_api_key(key, text) + def update_steam_api_key(self, text: str) -> None: + self.config_man.update_steam_api_key(text) def set_resolution(self, window: "OuterWindow") -> None: self.config_man.set_resolution(window) diff --git a/dzgui/managers/config.py b/dzgui/managers/config.py index 2e81f28..ac559b2 100644 --- a/dzgui/managers/config.py +++ b/dzgui/managers/config.py @@ -98,12 +98,13 @@ class ConfigManager: logger.critical(e) raise e - @call_on_thread(dialogs.checking_api) - def update_api_key(self, key: Preferences, text: str) -> None: - if key is Preferences.STEAM: - res = test_steam_api(text) + @call_on_thread(dialogs.checking_api, show_dialog=False) + def update_steam_api_key(self, text: str) -> None: + res = test_steam_api(text) if res is True: - self.update_config(key, text) + self.update_config(Preferences.STEAM, text) + func = StoredFunc(lambda: self.emitter.emit("api_change_successful")) + self.thread_man.set_cleanup_func(func) else: self.thread_man.set_cleanup_func( StoredFunc(lambda: self.emitter.emit("api_change_failed"))