[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.)

This commit is contained in:
Sakamoto Shiina
2025-06-15 18:11:07 +09:00
parent d96c9a5151
commit cbfce55c16
6 changed files with 30 additions and 54 deletions

View File

@@ -407,6 +407,18 @@ class Config:
self._MESSAGE_BOX_RATIO = value self._MESSAGE_BOX_RATIO = value
self.saveConfig(inspect.currentframe().f_code.co_name, value, immediate_save=True) 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 @property
@json_serializable('SHOW_RESEND_BUTTON') @json_serializable('SHOW_RESEND_BUTTON')
def SHOW_RESEND_BUTTON(self): def SHOW_RESEND_BUTTON(self):
@@ -815,18 +827,6 @@ class Config:
self._SEND_ONLY_TRANSLATED_MESSAGES = value self._SEND_ONLY_TRANSLATED_MESSAGES = value
self.saveConfig(inspect.currentframe().f_code.co_name, 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 @property
@json_serializable('OVERLAY_SMALL_LOG') @json_serializable('OVERLAY_SMALL_LOG')
def OVERLAY_SMALL_LOG(self): def OVERLAY_SMALL_LOG(self):
@@ -1101,6 +1101,7 @@ class Config:
self._UI_SCALING = 100 self._UI_SCALING = 100
self._TEXTBOX_UI_SCALING = 100 self._TEXTBOX_UI_SCALING = 100
self._MESSAGE_BOX_RATIO = 10 self._MESSAGE_BOX_RATIO = 10
self._SEND_MESSAGE_BUTTON_TYPE = "show"
self._SHOW_RESEND_BUTTON = False self._SHOW_RESEND_BUTTON = False
self._FONT_FAMILY = "Yu Gothic UI" self._FONT_FAMILY = "Yu Gothic UI"
self._UI_LANGUAGE = "en" self._UI_LANGUAGE = "en"
@@ -1149,7 +1150,6 @@ class Config:
self._WHISPER_WEIGHT_TYPE = "base" self._WHISPER_WEIGHT_TYPE = "base"
self._AUTO_CLEAR_MESSAGE_BOX = True self._AUTO_CLEAR_MESSAGE_BOX = True
self._SEND_ONLY_TRANSLATED_MESSAGES = False self._SEND_ONLY_TRANSLATED_MESSAGES = False
self._SEND_MESSAGE_BUTTON_TYPE = "show"
self._OVERLAY_SMALL_LOG = False self._OVERLAY_SMALL_LOG = False
self._OVERLAY_SMALL_LOG_SETTINGS = { self._OVERLAY_SMALL_LOG_SETTINGS = {
"x_pos": 0.0, "x_pos": 0.0,

View File

@@ -832,6 +832,15 @@ class Controller:
config.MESSAGE_BOX_RATIO = data config.MESSAGE_BOX_RATIO = data
return {"status":200, "result":config.MESSAGE_BOX_RATIO} 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 @staticmethod
def getShowResendButton(*args, **kwargs) -> dict: def getShowResendButton(*args, **kwargs) -> dict:
return {"status":200, "result":config.SHOW_RESEND_BUTTON} return {"status":200, "result":config.SHOW_RESEND_BUTTON}
@@ -1420,15 +1429,6 @@ class Controller:
config.SEND_ONLY_TRANSLATED_MESSAGES = False config.SEND_ONLY_TRANSLATED_MESSAGES = False
return {"status":200, "result":config.SEND_ONLY_TRANSLATED_MESSAGES} 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 @staticmethod
def getOverlaySmallLog(*args, **kwargs) -> dict: def getOverlaySmallLog(*args, **kwargs) -> dict:
return {"status":200, "result":config.OVERLAY_SMALL_LOG} return {"status":200, "result":config.OVERLAY_SMALL_LOG}

View File

@@ -131,6 +131,9 @@ mapping = {
"/get/data/message_box_ratio": {"status": True, "variable":controller.getMessageBoxRatio}, "/get/data/message_box_ratio": {"status": True, "variable":controller.getMessageBoxRatio},
"/set/data/message_box_ratio": {"status": True, "variable":controller.setMessageBoxRatio}, "/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}, "/get/data/show_resend_button": {"status": True, "variable":controller.getShowResendButton},
"/set/enable/show_resend_button": {"status": True, "variable":controller.setEnableShowResendButton}, "/set/enable/show_resend_button": {"status": True, "variable":controller.setEnableShowResendButton},
"/set/disable/show_resend_button": {"status": True, "variable":controller.setDisableShowResendButton}, "/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/enable/send_only_translated_messages": {"status": True, "variable":controller.setEnableSendOnlyTranslatedMessages},
"/set/disable/send_only_translated_messages": {"status": True, "variable":controller.setDisableSendOnlyTranslatedMessages}, "/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}, "/get/data/logger_feature": {"status": True, "variable":controller.getLoggerFeature},
"/set/enable/logger_feature": {"status": True, "variable":controller.setEnableLoggerFeature}, "/set/enable/logger_feature": {"status": True, "variable":controller.setEnableLoggerFeature},
"/set/disable/logger_feature": {"status": True, "variable":controller.setDisableLoggerFeature}, "/set/disable/logger_feature": {"status": True, "variable":controller.setDisableLoggerFeature},
@@ -539,6 +539,8 @@ if __name__ == "__main__":
data = 1.5 data = 1.5
case "/set/data/message_box_ratio": case "/set/data/message_box_ratio":
data = 0.5 data = 0.5
case "/set/data/send_message_button_type":
data = "show"
case "/set/data/font_family": case "/set/data/font_family":
data = "Yu Gothic UI" data = "Yu Gothic UI"
case "/set/data/ui_language": case "/set/data/ui_language":
@@ -589,8 +591,6 @@ if __name__ == "__main__":
"display_duration": 5, "display_duration": 5,
"fadeout_duration": 0.5, "fadeout_duration": 0.5,
} }
case "/set/data/send_message_button_type":
data = "show"
case "/set/data/send_message_format": case "/set/data/send_message_format":
data = "[message]" data = "[message]"
case "/set/data/send_message_format_with_t": case "/set/data/send_message_format_with_t":

View File

@@ -10,9 +10,9 @@ export const useSendMessageButtonType = () => {
asyncStdoutToPython("/get/data/send_message_button_type"); asyncStdoutToPython("/get/data/send_message_button_type");
}; };
const setSendMessageButtonType = (selected_type) => { const setSendMessageButtonType = (send_message_button_type) => {
pendingSendMessageButtonType(); pendingSendMessageButtonType();
asyncStdoutToPython("/set/data/send_message_button_type", selected_type); asyncStdoutToPython("/set/data/send_message_button_type", send_message_button_type);
}; };
return { return {

View File

@@ -3,7 +3,7 @@ export { useDevice } from "./device/useDevice";
export { useMessageLogUiScaling } from "./appearance/useMessageLogUiScaling"; export { useMessageLogUiScaling } from "./appearance/useMessageLogUiScaling";
export { useSelectedFontFamily } from "./appearance/useSelectedFontFamily"; export { useSelectedFontFamily } from "./appearance/useSelectedFontFamily";
export { useTransparency } from "./appearance/useTransparency"; export { useTransparency } from "./appearance/useTransparency";
export { useSendMessageButtonType } from "./others/useSendMessageButtonType"; export { useSendMessageButtonType } from "./appearance/useSendMessageButtonType";
export { useShowResendButton } from "./appearance/useShowResendButton"; export { useShowResendButton } from "./appearance/useShowResendButton";
export { useUiLanguage } from "./appearance/useUiLanguage"; export { useUiLanguage } from "./appearance/useUiLanguage";
export { useUiScaling } from "./appearance/useUiScaling"; export { useUiScaling } from "./appearance/useUiScaling";

View File

@@ -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,
};
};