From bf4971520905ae94fe162095e87b8873534f675c Mon Sep 17 00:00:00 2001 From: misyaguziya <53165965+misyaguziya@users.noreply.github.com> Date: Mon, 2 Dec 2024 11:15:10 +0900 Subject: [PATCH] =?UTF-8?q?=F0=9F=91=8D=EF=B8=8F[Update]=20Model=20:=20ove?= =?UTF-8?q?rlay=5Fshow=5Fonly=5Ftranslated=5Fmessages=E3=81=AEendpoint?= =?UTF-8?q?=E3=82=92=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src-python/config.py | 14 +++++++------- src-python/webui_controller.py | 22 ++++++++++++++++++---- src-python/webui_mainloop.py | 7 ++++++- 3 files changed, 31 insertions(+), 12 deletions(-) diff --git a/src-python/config.py b/src-python/config.py index a7049807..aa6af639 100644 --- a/src-python/config.py +++ b/src-python/config.py @@ -811,14 +811,14 @@ class Config: self.saveConfig(inspect.currentframe().f_code.co_name, self.OVERLAY_LARGE_LOG_SETTINGS) @property - @json_serializable('OVERLAY_SHOW_ONLY_TRANSLATED_MESSAGE') - def OVERLAY_SHOW_ONLY_TRANSLATED_MESSAGE(self): - return self._OVERLAY_SHOW_ONLY_TRANSLATED_MESSAGE + @json_serializable('OVERLAY_SHOW_ONLY_TRANSLATED_MESSAGES') + def OVERLAY_SHOW_ONLY_TRANSLATED_MESSAGES(self): + return self._OVERLAY_SHOW_ONLY_TRANSLATED_MESSAGES - @OVERLAY_SHOW_ONLY_TRANSLATED_MESSAGE.setter - def OVERLAY_SHOW_ONLY_TRANSLATED_MESSAGE(self, value): + @OVERLAY_SHOW_ONLY_TRANSLATED_MESSAGES.setter + def OVERLAY_SHOW_ONLY_TRANSLATED_MESSAGES(self, value): if isinstance(value, bool): - self._OVERLAY_SHOW_ONLY_TRANSLATED_MESSAGE = value + self._OVERLAY_SHOW_ONLY_TRANSLATED_MESSAGES = value self.saveConfig(inspect.currentframe().f_code.co_name, value) @property @@ -1119,7 +1119,7 @@ class Config: "ui_scaling": 1.0, "tracker": "LeftHand", } - self._OVERLAY_SHOW_ONLY_TRANSLATED_MESSAGE = False + self._OVERLAY_SHOW_ONLY_TRANSLATED_MESSAGES = False self._SEND_MESSAGE_TO_VRC = True self._SEND_RECEIVED_MESSAGE_TO_VRC = False self._LOGGER_FEATURE = False diff --git a/src-python/webui_controller.py b/src-python/webui_controller.py index f259adfb..b1eb943e 100644 --- a/src-python/webui_controller.py +++ b/src-python/webui_controller.py @@ -251,7 +251,7 @@ class Controller: model.logger.info(f"[SENT] {message}{translation}") if config.OVERLAY_LARGE_LOG is True and model.overlay.initialized is True: - if config.OVERLAY_SHOW_ONLY_TRANSLATED_MESSAGE is True and len(translation) > 0: + if config.OVERLAY_SHOW_ONLY_TRANSLATED_MESSAGES is True and len(translation) > 0: overlay_image = model.createOverlayImageLargeLog("send", translation[0], "") else: overlay_image = model.createOverlayImageLargeLog("send", message, translation[0] if len(translation) > 0 else "") @@ -293,14 +293,14 @@ class Controller: if config.ENABLE_TRANSCRIPTION_RECEIVE is True: if config.OVERLAY_SMALL_LOG is True and model.overlay.initialized is True: - if config.OVERLAY_SHOW_ONLY_TRANSLATED_MESSAGE is True and len(translation) > 0: + if config.OVERLAY_SHOW_ONLY_TRANSLATED_MESSAGES is True and len(translation) > 0: overlay_image = model.createOverlayImageSmallLog(translation[0], "") else: overlay_image = model.createOverlayImageSmallLog(message, translation[0] if len(translation) > 0 else "") model.updateOverlaySmallLog(overlay_image) if config.OVERLAY_LARGE_LOG is True and model.overlay.initialized is True: - if config.OVERLAY_SHOW_ONLY_TRANSLATED_MESSAGE is True and len(translation) > 0: + if config.OVERLAY_SHOW_ONLY_TRANSLATED_MESSAGES is True and len(translation) > 0: overlay_image = model.createOverlayImageLargeLog("receive", translation[0], "") else: overlay_image = model.createOverlayImageLargeLog("receive", message, translation[0] if len(translation) > 0 else "") @@ -370,7 +370,7 @@ class Controller: model.oscSendMessage(osc_message) if config.OVERLAY_LARGE_LOG is True: - if config.OVERLAY_SHOW_ONLY_TRANSLATED_MESSAGE is True and len(translation) > 0: + if config.OVERLAY_SHOW_ONLY_TRANSLATED_MESSAGES is True and len(translation) > 0: overlay_image = model.createOverlayImageLargeLog("send", translation[0], "") else: overlay_image = model.createOverlayImageLargeLog("send", message, translation[0] if len(translation) > 0 else "") @@ -1240,6 +1240,20 @@ class Controller: model.updateOverlayLargeLogSettings() return {"status":200, "result":config.OVERLAY_LARGE_LOG_SETTINGS} + @staticmethod + def getOverlayShowOnlyTranslatedMessages(*args, **kwargs) -> dict: + return {"status":200, "result":config.OVERLAY_SHOW_ONLY_TRANSLATED_MESSAGES} + + @staticmethod + def setEnableOverlayShowOnlyTranslatedMessages(*args, **kwargs) -> dict: + config.OVERLAY_SHOW_ONLY_TRANSLATED_MESSAGES = True + return {"status":200, "result":config.OVERLAY_SHOW_ONLY_TRANSLATED_MESSAGES} + + @staticmethod + def setDisableOverlayShowOnlyTranslatedMessages(*args, **kwargs) -> dict: + config.OVERLAY_SHOW_ONLY_TRANSLATED_MESSAGES = False + return {"status":200, "result":config.OVERLAY_SHOW_ONLY_TRANSLATED_MESSAGES} + @staticmethod def getSendMessageToVrc(*args, **kwargs) -> dict: return {"status":200, "result":config.SEND_MESSAGE_TO_VRC} diff --git a/src-python/webui_mainloop.py b/src-python/webui_mainloop.py index 80a26f62..5f2f6011 100644 --- a/src-python/webui_mainloop.py +++ b/src-python/webui_mainloop.py @@ -132,12 +132,13 @@ mapping = { "/get/data/main_window_geometry": {"status": True, "variable":controller.getMainWindowGeometry}, "/set/data/main_window_geometry": {"status": True, "variable":controller.setMainWindowGeometry}, - # Translation + # Compute device "/get/data/compute_mode": {"status": True, "variable":controller.getComputeMode}, "/get/data/translation_compute_device_list": {"status": True, "variable":controller.getComputeDeviceList}, "/get/data/selected_translation_compute_device": {"status": True, "variable":controller.getSelectedTranslationComputeDevice}, "/set/data/selected_translation_compute_device": {"status": True, "variable":controller.setSelectedTranslationComputeDevice}, + # Translation "/get/data/selectable_ctranslate2_weight_type_dict": {"status": True, "variable":controller.getSelectableCtranslate2WeightTypeDict}, "/get/data/ctranslate2_weight_type": {"status": True, "variable":controller.getCtranslate2WeightType}, @@ -263,6 +264,10 @@ mapping = { "/get/data/overlay_large_log_settings": {"status": True, "variable":controller.getOverlayLargeLogSettings}, "/set/data/overlay_large_log_settings": {"status": True, "variable":controller.setOverlayLargeLogSettings}, + "/get/data/overlay_show_only_translated_messages": {"status": True, "variable":controller.getOverlayShowOnlyTranslatedMessages}, + "/set/enable/overlay_show_only_translated_messages": {"status": True, "variable":controller.setEnableOverlayShowOnlyTranslatedMessages}, + "/set/disable/overlay_show_only_translated_messages": {"status": True, "variable":controller.setDisableOverlayShowOnlyTranslatedMessages}, + # Others "/get/data/auto_clear_message_box": {"status": True, "variable":controller.getAutoClearMessageBox}, "/set/enable/auto_clear_message_box": {"status": True, "variable":controller.setEnableAutoClearMessageBox},