From 6fbc2ede3a942f58cfc6282d2922ce6fc49809f6 Mon Sep 17 00:00:00 2001 From: Sakamoto Shiina <68018796+ShiinaSakamoto@users.noreply.github.com> Date: Thu, 1 Feb 2024 15:54:22 +0900 Subject: [PATCH 1/2] =?UTF-8?q?[Update]=20Main=20Window:=20Message=20box.?= =?UTF-8?q?=20=E9=80=81=E4=BF=A1=E3=81=97=E3=81=9F=E3=83=A1=E3=83=83?= =?UTF-8?q?=E3=82=BB=E3=83=BC=E3=82=B8=E3=82=92=E3=80=81=E3=82=AD=E3=83=BC?= =?UTF-8?q?=E3=83=9C=E3=83=BC=E3=83=89=E7=9F=A2=E5=8D=B0=E3=82=AD=E3=83=BC?= =?UTF-8?q?=E4=B8=8A=E4=B8=8B=E3=81=A7=E5=91=BC=E3=81=B3=E5=87=BA=E3=81=9B?= =?UTF-8?q?=E3=82=8B=E3=82=88=E3=81=86=E3=81=AB=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config.py | 20 ++++++++++++++++ controller.py | 23 +++++++++++++++++++ view.py | 13 +++++++++++ .../widgets/create_entry_message_box.py | 8 +++++++ 4 files changed, 64 insertions(+) diff --git a/config.py b/config.py index 371ec121..9a7c4e83 100644 --- a/config.py +++ b/config.py @@ -197,6 +197,24 @@ class Config: if value in list(translation_lang.keys()): self._CHOICE_OUTPUT_TRANSLATOR = value + @property + def SENT_MESSAGES_LOG(self): + return self._SENT_MESSAGES_LOG + + @SENT_MESSAGES_LOG.setter + def SENT_MESSAGES_LOG(self, value): + if isinstance(value, list): + self._SENT_MESSAGES_LOG = value + + @property + def CURRENT_SENT_MESSAGES_LOG_INDEX(self): + return self._CURRENT_SENT_MESSAGES_LOG_INDEX + + @CURRENT_SENT_MESSAGES_LOG_INDEX.setter + def CURRENT_SENT_MESSAGES_LOG_INDEX(self, value): + if isinstance(value, int): + self._CURRENT_SENT_MESSAGES_LOG_INDEX = value + @property def IS_RESET_BUTTON_DISPLAYED_FOR_TRANSLATION(self): return self._IS_RESET_BUTTON_DISPLAYED_FOR_TRANSLATION @@ -770,6 +788,8 @@ class Config: self._SOURCE_COUNTRY = "Japan" self._TARGET_LANGUAGE = "English" self._TARGET_COUNTRY = "United States" + self._SENT_MESSAGES_LOG = [] + self._CURRENT_SENT_MESSAGES_LOG_INDEX = 0 self._IS_RESET_BUTTON_DISPLAYED_FOR_TRANSLATION = False # Save Json Data diff --git a/controller.py b/controller.py index f9e9a5b3..f7b3f635 100644 --- a/controller.py +++ b/controller.py @@ -200,6 +200,8 @@ def stopThreadingTranscriptionReceiveMessageOnOpenConfigWindow(): # func message box def sendChatMessage(message): if len(message) > 0: + config.SENT_MESSAGES_LOG.append(view.getTextFromMessageBox()) + config.CURRENT_SENT_MESSAGES_LOG_INDEX = len(config.SENT_MESSAGES_LOG) translation = "" if config.ENABLE_TRANSLATION is False: pass @@ -249,6 +251,25 @@ def messageBoxFocusOut(e): if config.ENABLE_SEND_MESSAGE_TO_VRC is True: model.oscStopSendTyping() +def updateMessageBox(index_offset): + if len(config.SENT_MESSAGES_LOG) == 0: + return + try: + new_index = config.CURRENT_SENT_MESSAGES_LOG_INDEX + index_offset + target_message_text = config.SENT_MESSAGES_LOG[new_index] + view.replaceMessageBox(target_message_text) + config.CURRENT_SENT_MESSAGES_LOG_INDEX = new_index + except IndexError: + pass + +def messageBoxUpKeyPress(): + if config.CURRENT_SENT_MESSAGES_LOG_INDEX > 0: + updateMessageBox(-1) + +def messageBoxDownKeyPress(): + if config.CURRENT_SENT_MESSAGES_LOG_INDEX < len(config.SENT_MESSAGES_LOG) - 1: + updateMessageBox(1) + def updateTranslationEngineAndEngineList(): engine = config.CHOICE_INPUT_TRANSLATOR engines = model.findTranslationEngines(config.SOURCE_LANGUAGE, config.TARGET_LANGUAGE) @@ -949,6 +970,8 @@ def createMainWindow(splash): "message_box_bind_Any_KeyPress": messageBoxPressKeyAny, "message_box_bind_FocusIn": messageBoxFocusIn, "message_box_bind_FocusOut": messageBoxFocusOut, + "message_box_bind_Up_KeyPress": messageBoxUpKeyPress, + "message_box_bind_Down_KeyPress": messageBoxDownKeyPress, }, config_window_registers={ diff --git a/view.py b/view.py index 34711688..720648ce 100644 --- a/view.py +++ b/view.py @@ -184,6 +184,8 @@ class View(): VAR_UPDATE_AVAILABLE=StringVar(value=i18n.t("main_window.update_available")), + CALLBACK_MESSAGE_BOX_BIND_KEYSYM__UP=None, + CALLBACK_MESSAGE_BOX_BIND_KEYSYM__DOWN=None, # Main Window Cover VAR_LABEL_MAIN_WINDOW_COVER_MESSAGE=StringVar(value=""), @@ -562,6 +564,10 @@ class View(): self.view_variable.CALLBACK_CLICKED_SEND_MESSAGE_BUTTON = pressedSendMessageButtonFunction + self.view_variable.CALLBACK_MESSAGE_BOX_BIND_KEYSYM__UP=main_window_registers.get("message_box_bind_Up_KeyPress") + self.view_variable.CALLBACK_MESSAGE_BOX_BIND_KEYSYM__DOWN=main_window_registers.get("message_box_bind_Down_KeyPress") + + entry_message_box.bind("", main_window_registers.get("message_box_bind_FocusIn")) entry_message_box.bind("", main_window_registers.get("message_box_bind_FocusOut")) @@ -1637,6 +1643,13 @@ class View(): def clearMessageBox(self): self._clearTextBox(vrct_gui.entry_message_box) + @staticmethod + def insertMessageBox(text): + vrct_gui.entry_message_box.insert("end", text) + + def replaceMessageBox(self, text): + self.clearMessageBox() + self.insertMessageBox(text) diff --git a/vrct_gui/main_window/widgets/create_entry_message_box.py b/vrct_gui/main_window/widgets/create_entry_message_box.py index efc8284f..0d01d030 100644 --- a/vrct_gui/main_window/widgets/create_entry_message_box.py +++ b/vrct_gui/main_window/widgets/create_entry_message_box.py @@ -31,6 +31,14 @@ def createEntryMessageBox(settings, main_window, view_variable): "Delete", "Select", "Up", "Down", "Next", "End", "Print", "Prior","Insert","Home", "Left", "Clear", "Right", "Linefeed" ] + if e.keysym == "Up": + callFunctionIfCallable(view_variable.CALLBACK_MESSAGE_BOX_BIND_KEYSYM__UP) + return "break" + + if e.keysym == "Down": + callFunctionIfCallable(view_variable.CALLBACK_MESSAGE_BOX_BIND_KEYSYM__DOWN) + return "break" + if e.keysym != "??": if len(e.char) != 0 and e.keysym in BREAK_KEYSYM_LIST: main_window.entry_message_box.insert("end", e.char) From 6d949858b8c9a633c6d6e2154ff3d34d2539bccf Mon Sep 17 00:00:00 2001 From: Sakamoto Shiina <68018796+ShiinaSakamoto@users.noreply.github.com> Date: Thu, 1 Feb 2024 16:16:09 +0900 Subject: [PATCH 2/2] =?UTF-8?q?[Update/Refactor]=20Main=20Window:=20?= =?UTF-8?q?=E9=80=81=E4=BF=A1=E6=B8=88=E3=83=A1=E3=83=83=E3=82=BB=E3=83=BC?= =?UTF-8?q?=E3=82=B8=E3=81=AE=E3=83=AD=E3=83=BC=E3=83=AB=E3=83=90=E3=83=83?= =?UTF-8?q?=E3=82=AF=E6=A9=9F=E8=83=BD=E8=AA=BF=E6=95=B4(=E3=83=AD?= =?UTF-8?q?=E3=83=BC=E3=83=AB=E3=83=90=E3=83=83=E3=82=AF=E5=8F=AF=E8=83=BD?= =?UTF-8?q?=E3=81=AA=E3=83=A1=E3=83=83=E3=82=BB=E3=83=BC=E3=82=B8=E3=81=AB?= =?UTF-8?q?=E3=80=81=E3=83=9E=E3=82=A4=E3=82=AF=E3=81=8B=E3=82=89=E3=81=AE?= =?UTF-8?q?=E5=85=A5=E5=8A=9B=E6=99=82=E3=82=92=E8=BF=BD=E5=8A=A0)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Redo Undoの履歴保存サイズを設定。理由は、上記の機能使用時もRedo Undoの保存タイミングになるので、使用の際膨大な数になる可能性があるため上限を設定。設定値は今後変更する可能性は全然ある。 --- controller.py | 8 ++++++-- vrct_gui/main_window/widgets/create_entry_message_box.py | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/controller.py b/controller.py index f7b3f635..5a80c98f 100644 --- a/controller.py +++ b/controller.py @@ -64,6 +64,7 @@ def changeToCTranslate2Process(): # func transcription send message def sendMicMessage(message): if len(message) > 0: + addSentMessageLog(message) translation = "" if model.checkKeywords(message): view.printToTextbox_DetectedByWordFilter(detected_message=message) @@ -200,8 +201,7 @@ def stopThreadingTranscriptionReceiveMessageOnOpenConfigWindow(): # func message box def sendChatMessage(message): if len(message) > 0: - config.SENT_MESSAGES_LOG.append(view.getTextFromMessageBox()) - config.CURRENT_SENT_MESSAGES_LOG_INDEX = len(config.SENT_MESSAGES_LOG) + addSentMessageLog(message) translation = "" if config.ENABLE_TRANSLATION is False: pass @@ -251,6 +251,10 @@ def messageBoxFocusOut(e): if config.ENABLE_SEND_MESSAGE_TO_VRC is True: model.oscStopSendTyping() +def addSentMessageLog(sent_message): + config.SENT_MESSAGES_LOG.append(sent_message) + config.CURRENT_SENT_MESSAGES_LOG_INDEX = len(config.SENT_MESSAGES_LOG) + def updateMessageBox(index_offset): if len(config.SENT_MESSAGES_LOG) == 0: return diff --git a/vrct_gui/main_window/widgets/create_entry_message_box.py b/vrct_gui/main_window/widgets/create_entry_message_box.py index 0d01d030..d153749e 100644 --- a/vrct_gui/main_window/widgets/create_entry_message_box.py +++ b/vrct_gui/main_window/widgets/create_entry_message_box.py @@ -21,7 +21,7 @@ def createEntryMessageBox(settings, main_window, view_variable): font=CTkFont(family=settings.FONT_FAMILY, size=settings.uism.TEXTBOX_ENTRY_FONT_SIZE, weight="normal"), undo=True, autoseparators=True, - maxundo=0, + maxundo=64, ) main_window.entry_message_box.grid(row=0, column=0, padx=settings.uism.TEXTBOX_ENTRY_PADX, pady=settings.uism.TEXTBOX_ENTRY_PADY, sticky="nsew")