From b014b1f3cc9a659b550ffe0ccff79ca61a39d751 Mon Sep 17 00:00:00 2001 From: misyaguziya Date: Mon, 4 Sep 2023 05:04:37 +0900 Subject: [PATCH] =?UTF-8?q?[Update]=20model=E3=81=A7config=E3=81=AB?= =?UTF-8?q?=E3=82=BB=E3=83=83=E3=83=88=E3=81=97=E3=81=A6=E3=81=84=E3=81=9F?= =?UTF-8?q?=E9=83=A8=E5=88=86=E3=82=92callback=E3=81=A8=E3=81=97=E3=81=A6m?= =?UTF-8?q?ain=E3=81=A7=E3=82=BB=E3=83=83=E3=83=88=E3=81=99=E3=82=8B?= =?UTF-8?q?=E3=82=88=E3=81=86=E3=81=AB=E5=A4=89=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.py | 17 +++++++++++++---- model.py | 12 ++++++------ 2 files changed, 19 insertions(+), 10 deletions(-) diff --git a/main.py b/main.py index b0c22381..1ed44b42 100644 --- a/main.py +++ b/main.py @@ -143,6 +143,15 @@ def callbackSelectedLanguagePresetTab(selected_tab_no): config.TARGET_COUNTRY = country config.CHOICE_TRANSLATOR = model.findTranslationEngine(config.SOURCE_LANGUAGE, config.TARGET_LANGUAGE) +def callbackSetAuthKeys(keys): + config.AUTH_KEYS = keys + +def callbackChangeStatusOSC(value): + config.ENABLE_OSC = value + +def callbackChangeStatusSoftwareUpdated(value): + config.UPDATE_FLAG = value + # command func def callbackToggleTranslation(is_turned_on): config.ENABLE_TRANSLATION = is_turned_on @@ -230,7 +239,7 @@ def callbackSetDeeplAuthkey(value): print("callbackSetDeeplAuthkey", str(value)) # config.AUTH_KEYS["DeepL(auth)"] = str(value) # if len(value) > 0: - # if model.authenticationTranslator(choice_translator="DeepL(auth)", auth_key=value) is True: + # if model.authenticationTranslator(callbackSetAuthKeys, choice_translator="DeepL(auth)", auth_key=value) is True: # print_textbox(self.parent.textbox_message_log, "Auth key update completed", "INFO") # print_textbox(self.parent.textbox_message_system_log, "Auth key update completed", "INFO") # else: @@ -352,7 +361,7 @@ def callbackSetOscPort(value): view.createGUI() # init config -if model.authenticationTranslator() is False: +if model.authenticationTranslator(callbackSetAuthKeys) is False: # error update Auth key view.printToTextbox_AuthenticationError() @@ -360,10 +369,10 @@ if model.authenticationTranslator() is False: model.addKeywords() # check OSC started -model.checkOSCStarted() +model.checkOSCStarted(callbackChangeStatusOSC) # check Software Updated -model.checkSoftwareUpdated() +model.checkSoftwareUpdated(callbackChangeStatusSoftwareUpdated) # init logger if config.ENABLE_LOGGER is True: diff --git a/model.py b/model.py index f2c63a25..48735c3d 100644 --- a/model.py +++ b/model.py @@ -68,7 +68,7 @@ class Model: del self.translator self.keyword_processor = KeywordProcessor() - def authenticationTranslator(self, choice_translator=None, auth_key=None): + def authenticationTranslator(self, fnc, choice_translator=None, auth_key=None): if choice_translator == None: choice_translator = config.CHOICE_TRANSLATOR if auth_key == None: @@ -78,7 +78,7 @@ class Model: if result: auth_keys = config.AUTH_KEYS auth_keys[choice_translator] = auth_key - config.AUTH_KEYS = auth_keys + fnc(auth_key) return result def startLogger(self): @@ -165,10 +165,10 @@ class Model: sendMessage(message, config.OSC_IP_ADDRESS, config.OSC_PORT) @staticmethod - def checkOSCStarted(): + def checkOSCStarted(fnc): def checkOscReceive(address, osc_arguments): if config.ENABLE_OSC is False: - config.ENABLE_OSC = True + fnc(True) # start receive osc th_receive_osc_parameters = Thread(target=receiveOscParameters, args=(checkOscReceive,)) @@ -179,12 +179,12 @@ class Model: sendTestAction() @staticmethod - def checkSoftwareUpdated(): + def checkSoftwareUpdated(fnc): # check update response = requests_get(config.GITHUB_URL) tag_name = response.json()["tag_name"] if tag_name != config.VERSION: - config.UPDATE_FLAG = True + fnc(True) @staticmethod def getListInputHost():