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] =?UTF-8?q?[Update]=20Main=20Window:=20Message=20box.=20?= =?UTF-8?q?=E9=80=81=E4=BF=A1=E3=81=97=E3=81=9F=E3=83=A1=E3=83=83=E3=82=BB?= =?UTF-8?q?=E3=83=BC=E3=82=B8=E3=82=92=E3=80=81=E3=82=AD=E3=83=BC=E3=83=9C?= =?UTF-8?q?=E3=83=BC=E3=83=89=E7=9F=A2=E5=8D=B0=E3=82=AD=E3=83=BC=E4=B8=8A?= =?UTF-8?q?=E4=B8=8B=E3=81=A7=E5=91=BC=E3=81=B3=E5=87=BA=E3=81=9B=E3=82=8B?= =?UTF-8?q?=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)