From d96c9a5151663161576944e2c7b028b623219b3a Mon Sep 17 00:00:00 2001 From: Sakamoto Shiina <68018796+ShiinaSakamoto@users.noreply.github.com> Date: Sun, 15 Jun 2025 17:53:41 +0900 Subject: [PATCH 1/2] [Chore] Fix typo in test code. '/set/data/mic_word_filter' --- src-python/mainloop.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src-python/mainloop.py b/src-python/mainloop.py index fa1b0da9..126330e1 100644 --- a/src-python/mainloop.py +++ b/src-python/mainloop.py @@ -559,7 +559,7 @@ if __name__ == "__main__": data = 5 case "/set/data/mic_max_phrases": data = 5 - case "/set//data/mic_word_filter": + case "/set/data/mic_word_filter": data = "test0, test1, test2" case "/set/data/selected_speaker_device": data = "スピーカー (Realtek High Definition Audio)" From cbfce55c169943795bb808b2098d37c92eed419a Mon Sep 17 00:00:00 2001 From: Sakamoto Shiina <68018796+ShiinaSakamoto@users.noreply.github.com> Date: Sun, 15 Jun 2025 18:11:07 +0900 Subject: [PATCH 2/2] [Refactor] Move the code that is related with Send Message Button Type. (It was remained at Others section but it should've move to Appearance section so.) --- src-python/config.py | 26 +++++++++---------- src-python/controller.py | 18 ++++++------- src-python/mainloop.py | 10 +++---- .../appearance/useSendMessageButtonType.js | 4 +-- src-ui/logics/configs/index.js | 2 +- .../others/useSendMessageButtonType.js | 24 ----------------- 6 files changed, 30 insertions(+), 54 deletions(-) delete mode 100644 src-ui/logics/configs/others/useSendMessageButtonType.js diff --git a/src-python/config.py b/src-python/config.py index e7df74e5..f177ca9f 100644 --- a/src-python/config.py +++ b/src-python/config.py @@ -407,6 +407,18 @@ class Config: self._MESSAGE_BOX_RATIO = value self.saveConfig(inspect.currentframe().f_code.co_name, value, immediate_save=True) + @property + @json_serializable('SEND_MESSAGE_BUTTON_TYPE') + def SEND_MESSAGE_BUTTON_TYPE(self): + return self._SEND_MESSAGE_BUTTON_TYPE + + @SEND_MESSAGE_BUTTON_TYPE.setter + def SEND_MESSAGE_BUTTON_TYPE(self, value): + if isinstance(value, str): + if value in self.SEND_MESSAGE_BUTTON_TYPE_LIST: + self._SEND_MESSAGE_BUTTON_TYPE = value + self.saveConfig(inspect.currentframe().f_code.co_name, value) + @property @json_serializable('SHOW_RESEND_BUTTON') def SHOW_RESEND_BUTTON(self): @@ -815,18 +827,6 @@ class Config: self._SEND_ONLY_TRANSLATED_MESSAGES = value self.saveConfig(inspect.currentframe().f_code.co_name, value) - @property - @json_serializable('SEND_MESSAGE_BUTTON_TYPE') - def SEND_MESSAGE_BUTTON_TYPE(self): - return self._SEND_MESSAGE_BUTTON_TYPE - - @SEND_MESSAGE_BUTTON_TYPE.setter - def SEND_MESSAGE_BUTTON_TYPE(self, value): - if isinstance(value, str): - if value in self.SEND_MESSAGE_BUTTON_TYPE_LIST: - self._SEND_MESSAGE_BUTTON_TYPE = value - self.saveConfig(inspect.currentframe().f_code.co_name, value) - @property @json_serializable('OVERLAY_SMALL_LOG') def OVERLAY_SMALL_LOG(self): @@ -1101,6 +1101,7 @@ class Config: self._UI_SCALING = 100 self._TEXTBOX_UI_SCALING = 100 self._MESSAGE_BOX_RATIO = 10 + self._SEND_MESSAGE_BUTTON_TYPE = "show" self._SHOW_RESEND_BUTTON = False self._FONT_FAMILY = "Yu Gothic UI" self._UI_LANGUAGE = "en" @@ -1149,7 +1150,6 @@ class Config: self._WHISPER_WEIGHT_TYPE = "base" self._AUTO_CLEAR_MESSAGE_BOX = True self._SEND_ONLY_TRANSLATED_MESSAGES = False - self._SEND_MESSAGE_BUTTON_TYPE = "show" self._OVERLAY_SMALL_LOG = False self._OVERLAY_SMALL_LOG_SETTINGS = { "x_pos": 0.0, diff --git a/src-python/controller.py b/src-python/controller.py index 760166f1..a90d8b40 100644 --- a/src-python/controller.py +++ b/src-python/controller.py @@ -832,6 +832,15 @@ class Controller: config.MESSAGE_BOX_RATIO = data return {"status":200, "result":config.MESSAGE_BOX_RATIO} + @staticmethod + def getSendMessageButtonType(*args, **kwargs) -> dict: + return {"status":200, "result":config.SEND_MESSAGE_BUTTON_TYPE} + + @staticmethod + def setSendMessageButtonType(data, *args, **kwargs) -> dict: + config.SEND_MESSAGE_BUTTON_TYPE = data + return {"status":200, "result":config.SEND_MESSAGE_BUTTON_TYPE} + @staticmethod def getShowResendButton(*args, **kwargs) -> dict: return {"status":200, "result":config.SHOW_RESEND_BUTTON} @@ -1420,15 +1429,6 @@ class Controller: config.SEND_ONLY_TRANSLATED_MESSAGES = False return {"status":200, "result":config.SEND_ONLY_TRANSLATED_MESSAGES} - @staticmethod - def getSendMessageButtonType(*args, **kwargs) -> dict: - return {"status":200, "result":config.SEND_MESSAGE_BUTTON_TYPE} - - @staticmethod - def setSendMessageButtonType(data, *args, **kwargs) -> dict: - config.SEND_MESSAGE_BUTTON_TYPE = data - return {"status":200, "result":config.SEND_MESSAGE_BUTTON_TYPE} - @staticmethod def getOverlaySmallLog(*args, **kwargs) -> dict: return {"status":200, "result":config.OVERLAY_SMALL_LOG} diff --git a/src-python/mainloop.py b/src-python/mainloop.py index 126330e1..61040535 100644 --- a/src-python/mainloop.py +++ b/src-python/mainloop.py @@ -131,6 +131,9 @@ mapping = { "/get/data/message_box_ratio": {"status": True, "variable":controller.getMessageBoxRatio}, "/set/data/message_box_ratio": {"status": True, "variable":controller.setMessageBoxRatio}, + "/get/data/send_message_button_type": {"status": True, "variable":controller.getSendMessageButtonType}, + "/set/data/send_message_button_type": {"status": True, "variable":controller.setSendMessageButtonType}, + "/get/data/show_resend_button": {"status": True, "variable":controller.getShowResendButton}, "/set/enable/show_resend_button": {"status": True, "variable":controller.setEnableShowResendButton}, "/set/disable/show_resend_button": {"status": True, "variable":controller.setDisableShowResendButton}, @@ -290,9 +293,6 @@ mapping = { "/set/enable/send_only_translated_messages": {"status": True, "variable":controller.setEnableSendOnlyTranslatedMessages}, "/set/disable/send_only_translated_messages": {"status": True, "variable":controller.setDisableSendOnlyTranslatedMessages}, - "/get/data/send_message_button_type": {"status": True, "variable":controller.getSendMessageButtonType}, - "/set/data/send_message_button_type": {"status": True, "variable":controller.setSendMessageButtonType}, - "/get/data/logger_feature": {"status": True, "variable":controller.getLoggerFeature}, "/set/enable/logger_feature": {"status": True, "variable":controller.setEnableLoggerFeature}, "/set/disable/logger_feature": {"status": True, "variable":controller.setDisableLoggerFeature}, @@ -539,6 +539,8 @@ if __name__ == "__main__": data = 1.5 case "/set/data/message_box_ratio": data = 0.5 + case "/set/data/send_message_button_type": + data = "show" case "/set/data/font_family": data = "Yu Gothic UI" case "/set/data/ui_language": @@ -589,8 +591,6 @@ if __name__ == "__main__": "display_duration": 5, "fadeout_duration": 0.5, } - case "/set/data/send_message_button_type": - data = "show" case "/set/data/send_message_format": data = "[message]" case "/set/data/send_message_format_with_t": diff --git a/src-ui/logics/configs/appearance/useSendMessageButtonType.js b/src-ui/logics/configs/appearance/useSendMessageButtonType.js index e92c9b21..621c7dbc 100644 --- a/src-ui/logics/configs/appearance/useSendMessageButtonType.js +++ b/src-ui/logics/configs/appearance/useSendMessageButtonType.js @@ -10,9 +10,9 @@ export const useSendMessageButtonType = () => { asyncStdoutToPython("/get/data/send_message_button_type"); }; - const setSendMessageButtonType = (selected_type) => { + const setSendMessageButtonType = (send_message_button_type) => { pendingSendMessageButtonType(); - asyncStdoutToPython("/set/data/send_message_button_type", selected_type); + asyncStdoutToPython("/set/data/send_message_button_type", send_message_button_type); }; return { diff --git a/src-ui/logics/configs/index.js b/src-ui/logics/configs/index.js index f2552bd4..9ffc7145 100644 --- a/src-ui/logics/configs/index.js +++ b/src-ui/logics/configs/index.js @@ -3,7 +3,7 @@ export { useDevice } from "./device/useDevice"; export { useMessageLogUiScaling } from "./appearance/useMessageLogUiScaling"; export { useSelectedFontFamily } from "./appearance/useSelectedFontFamily"; export { useTransparency } from "./appearance/useTransparency"; -export { useSendMessageButtonType } from "./others/useSendMessageButtonType"; +export { useSendMessageButtonType } from "./appearance/useSendMessageButtonType"; export { useShowResendButton } from "./appearance/useShowResendButton"; export { useUiLanguage } from "./appearance/useUiLanguage"; export { useUiScaling } from "./appearance/useUiScaling"; diff --git a/src-ui/logics/configs/others/useSendMessageButtonType.js b/src-ui/logics/configs/others/useSendMessageButtonType.js deleted file mode 100644 index 621c7dbc..00000000 --- a/src-ui/logics/configs/others/useSendMessageButtonType.js +++ /dev/null @@ -1,24 +0,0 @@ -import { useStore_SendMessageButtonType } from "@store"; -import { useStdoutToPython } from "@useStdoutToPython"; - -export const useSendMessageButtonType = () => { - const { asyncStdoutToPython } = useStdoutToPython(); - const { currentSendMessageButtonType, updateSendMessageButtonType, pendingSendMessageButtonType } = useStore_SendMessageButtonType(); - - const getSendMessageButtonType = () => { - pendingSendMessageButtonType(); - asyncStdoutToPython("/get/data/send_message_button_type"); - }; - - const setSendMessageButtonType = (send_message_button_type) => { - pendingSendMessageButtonType(); - asyncStdoutToPython("/set/data/send_message_button_type", send_message_button_type); - }; - - return { - currentSendMessageButtonType, - getSendMessageButtonType, - setSendMessageButtonType, - updateSendMessageButtonType, - }; -}; \ No newline at end of file