From 6e64edb1c698f252774c1300a8f4ca869c8df831 Mon Sep 17 00:00:00 2001 From: Sakamoto Shiina <68018796+ShiinaSakamoto@users.noreply.github.com> Date: Wed, 17 Jan 2024 16:52:44 +0900 Subject: [PATCH 1/3] =?UTF-8?q?[Update]=20=E8=A8=AD=E5=AE=9A=E7=94=BB?= =?UTF-8?q?=E9=9D=A2=E3=81=AB=E3=81=A6=E3=80=8C=E7=BF=BB=E8=A8=B3=E6=A9=9F?= =?UTF-8?q?=E8=83=BD=E3=82=92=E4=BD=BF=E7=94=A8=E3=81=99=E3=82=8B=E3=80=8D?= =?UTF-8?q?=E3=82=92=E3=82=AA=E3=83=95=E3=81=AB=E3=81=97=E3=81=9F=E6=99=82?= =?UTF-8?q?=E3=81=AB=E3=80=81=E3=83=A1=E3=82=A4=E3=83=B3=E7=94=BB=E9=9D=A2?= =?UTF-8?q?=E3=81=AE=E7=BF=BB=E8=A8=B3=E6=A9=9F=E8=83=BD=E3=82=92Disabled?= =?UTF-8?q?=E3=81=A8=E3=81=97=E3=81=A6=E3=81=95=E3=82=8F=E3=82=8C=E3=81=AA?= =?UTF-8?q?=E3=81=84=E3=82=88=E3=81=86=E3=81=AB=E3=81=99=E3=82=8B=E5=87=A6?= =?UTF-8?q?=E7=90=86=E8=BF=BD=E5=8A=A0=E3=80=82=EF=BC=88=E3=81=9D=E3=81=AE?= =?UTF-8?q?=E9=80=86=E3=82=82=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- controller.py | 2 ++ view.py | 6 +++++- vrct_gui/_changeMainWindowWidgetsStatus.py | 18 +++++++++++------- vrct_gui/vrct_gui.py | 5 +++-- 4 files changed, 21 insertions(+), 10 deletions(-) diff --git a/controller.py b/controller.py index 0c6d368f..b7ed3c2a 100644 --- a/controller.py +++ b/controller.py @@ -489,8 +489,10 @@ def callbackSetUseTranslationFeature(value): if config.USE_TRANSLATION_FEATURE is True: view.setLatestCTranslate2WeightType() view.openCtranslate2WeightTypeWidget() + view.setTranslationSwitchStatus("normal", release_locked_state=True) else: view.closeCtranslate2WeightTypeWidget() + view.setTranslationSwitchStatus("disabled", to_lock_state=True) def callbackSetCtranslate2WeightType(value): print("callbackSetCtranslate2WeightType", value) diff --git a/view.py b/view.py index a3c7c166..8159120b 100644 --- a/view.py +++ b/view.py @@ -652,6 +652,7 @@ class View(): if config.USE_TRANSLATION_FEATURE is True: self.openCtranslate2WeightTypeWidget() else: + self.setTranslationSwitchStatus("disabled", to_lock_state=True) self.closeCtranslate2WeightTypeWidget() if config.CHOICE_MIC_HOST == "NoHost": @@ -916,6 +917,9 @@ class View(): def setMainWindowAllWidgetsStatusToDisabled(): vrct_gui._changeMainWindowWidgetsStatus("disabled", "All") + @staticmethod + def setTranslationSwitchStatus(status:str, to_lock_state:bool=False, release_locked_state:bool=False): + vrct_gui._changeMainWindowWidgetsStatus(status, ["translation_switch"], to_lock_state, release_locked_state) def enableMainWindowSidebarCompactMode(self): self.view_variable.IS_MAIN_WINDOW_SIDEBAR_COMPACT_MODE = True @@ -1263,7 +1267,7 @@ class View(): # vrct_gui.translation_frame.markToggleManually(False) # # disable translation feature. - # vrct_gui._changeMainWindowWidgetsStatus("disabled", ["translation_switch"], to_hold_state=True) + # vrct_gui._changeMainWindowWidgetsStatus("disabled", ["translation_switch"], to_lock_state=True) # # print system message that mention to stopped translation feature. # view.printToTextbox_TranslationEngineLimitError() diff --git a/vrct_gui/_changeMainWindowWidgetsStatus.py b/vrct_gui/_changeMainWindowWidgetsStatus.py index 95fc38dc..3a77cb32 100644 --- a/vrct_gui/_changeMainWindowWidgetsStatus.py +++ b/vrct_gui/_changeMainWindowWidgetsStatus.py @@ -1,12 +1,16 @@ from customtkinter import CTkImage -hold_state_list=[] -def _changeMainWindowWidgetsStatus(vrct_gui, settings, view_variable, status, target_names:list, to_hold_state:bool=False): - global hold_state_list +lock_state_list=[] +def _changeMainWindowWidgetsStatus(vrct_gui, settings, view_variable, status, target_names:list, to_lock_state:bool=False, release_locked_state:bool=False): + global lock_state_list if target_names == "All": target_names = ["translation_switch", "transcription_send_switch", "transcription_receive_switch", "foreground_switch", "quick_language_settings", "config_button", "minimize_sidebar_button", "entry_message_box", "send_message_button"] + if release_locked_state is True: + for item in target_names: + if item in lock_state_list: + lock_state_list.remove(item) - for item in hold_state_list: + for item in lock_state_list: if item in target_names: target_names.remove(item) @@ -158,9 +162,9 @@ def _changeMainWindowWidgetsStatus(vrct_gui, settings, view_variable, status, ta raise ValueError(f"No matching case for target_name: {target_name}") - if to_hold_state is True: + if to_lock_state is True: for item in target_names: - if item not in hold_state_list: - hold_state_list.append(item) + if item not in lock_state_list: + lock_state_list.append(item) vrct_gui.update() \ No newline at end of file diff --git a/vrct_gui/vrct_gui.py b/vrct_gui/vrct_gui.py index e59b332d..25369a6a 100644 --- a/vrct_gui/vrct_gui.py +++ b/vrct_gui/vrct_gui.py @@ -250,14 +250,15 @@ class VRCT_GUI(CTk): - def _changeMainWindowWidgetsStatus(self, status, target_names, to_hold_state:bool=False): + def _changeMainWindowWidgetsStatus(self, status, target_names, to_lock_state:bool=False, release_locked_state:bool=False): _changeMainWindowWidgetsStatus( vrct_gui=self, settings=self.settings.main, view_variable=self._view_variable, status=status, target_names=target_names, - to_hold_state=to_hold_state, + to_lock_state=to_lock_state, + release_locked_state=release_locked_state, ) def _changeConfigWindowWidgetsStatus(self, status, target_names): From a067bfa733840c88e88268ed1dfba209cd6faae1 Mon Sep 17 00:00:00 2001 From: Sakamoto Shiina <68018796+ShiinaSakamoto@users.noreply.github.com> Date: Wed, 17 Jan 2024 18:17:46 +0900 Subject: [PATCH 2/3] =?UTF-8?q?[Update/Refactor]=20=E8=A8=AD=E5=AE=9A?= =?UTF-8?q?=E7=94=BB=E9=9D=A2=E3=81=AB=E3=81=A6=E3=80=8C=E7=BF=BB=E8=A8=B3?= =?UTF-8?q?=E6=A9=9F=E8=83=BD=E3=82=92=E4=BD=BF=E7=94=A8=E3=81=99=E3=82=8B?= =?UTF-8?q?=E3=80=8D=E3=81=AE=E3=82=AA=E3=83=B3=E3=82=AA=E3=83=95=E3=81=A7?= =?UTF-8?q?=E3=80=81=E3=83=A1=E3=82=A4=E3=83=B3=E7=94=BB=E9=9D=A2=E7=BF=BB?= =?UTF-8?q?=E8=A8=B3=E3=82=A8=E3=83=B3=E3=82=B8=E3=83=B3=E9=81=B8=E6=8A=9E?= =?UTF-8?q?Widget=E3=81=AE=E8=A1=A8=E7=A4=BA=E9=9D=9E=E8=A1=A8=E7=A4=BA?= =?UTF-8?q?=E3=82=92=E5=88=87=E3=82=8A=E6=9B=BF=E3=81=88=E3=80=82=20?= =?UTF-8?q?=E3=80=8C=E7=BF=BB=E8=A8=B3=E6=A9=9F=E8=83=BD=E3=82=92=E4=BD=BF?= =?UTF-8?q?=E7=94=A8=E3=81=99=E3=82=8B=E3=80=8D=E3=82=AA=E3=83=B3=E3=82=AA?= =?UTF-8?q?=E3=83=95=E3=82=92process=E3=81=A8=E3=81=97=E3=81=A6=E5=88=87?= =?UTF-8?q?=E3=82=8A=E5=87=BA=E3=81=97=E3=81=A6view=E3=81=A7=E7=AE=A1?= =?UTF-8?q?=E7=90=86=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- controller.py | 7 ++----- view.py | 16 +++++++++++++--- .../createSidebarLanguagesSettings.py | 12 ++++++------ 3 files changed, 21 insertions(+), 14 deletions(-) diff --git a/controller.py b/controller.py index b7ed3c2a..90ebf0ac 100644 --- a/controller.py +++ b/controller.py @@ -487,12 +487,9 @@ def callbackSetUseTranslationFeature(value): print("callbackSetUseTranslationFeature", value) config.USE_TRANSLATION_FEATURE = value if config.USE_TRANSLATION_FEATURE is True: - view.setLatestCTranslate2WeightType() - view.openCtranslate2WeightTypeWidget() - view.setTranslationSwitchStatus("normal", release_locked_state=True) + view.useTranslationFeatureProcess("Normal") else: - view.closeCtranslate2WeightTypeWidget() - view.setTranslationSwitchStatus("disabled", to_lock_state=True) + view.useTranslationFeatureProcess("Disable") def callbackSetCtranslate2WeightType(value): print("callbackSetCtranslate2WeightType", value) diff --git a/view.py b/view.py index 8159120b..d2a5a47f 100644 --- a/view.py +++ b/view.py @@ -650,10 +650,9 @@ class View(): self.setMainWindowMessageBoxRatio(config.MESSAGE_BOX_RATIO) if config.USE_TRANSLATION_FEATURE is True: - self.openCtranslate2WeightTypeWidget() + self.useTranslationFeatureProcess("Normal") else: - self.setTranslationSwitchStatus("disabled", to_lock_state=True) - self.closeCtranslate2WeightTypeWidget() + self.useTranslationFeatureProcess("Disable") if config.CHOICE_MIC_HOST == "NoHost": self.view_variable.VAR_MIC_HOST.set("No Mic Host Detected") @@ -879,6 +878,17 @@ class View(): config._SELECTABLE_CTRANSLATE2_WEIGHT_TYPE_DICT["Large"]: i18n.t("config_window.ctranslate2_weight_type.large", capacity="1.2GB"), } + def useTranslationFeatureProcess(self, state:str): + if state == "Normal": + self.setLatestCTranslate2WeightType() + self.openCtranslate2WeightTypeWidget() + self.setTranslationSwitchStatus("normal", release_locked_state=True) + vrct_gui.sls__box_translation_optionmenu_wrapper.grid() + elif state == "Disable": + view.closeCtranslate2WeightTypeWidget() + view.setTranslationSwitchStatus("disabled", to_lock_state=True) + vrct_gui.sls__box_translation_optionmenu_wrapper.grid_remove() + # Open Webpage Functions def openWebPage_Booth(self): self.openWebPage(config.BOOTH_URL) diff --git a/vrct_gui/main_window/widgets/_create_sidebar/createSidebarLanguagesSettings.py b/vrct_gui/main_window/widgets/_create_sidebar/createSidebarLanguagesSettings.py index f529898f..e85e084a 100644 --- a/vrct_gui/main_window/widgets/_create_sidebar/createSidebarLanguagesSettings.py +++ b/vrct_gui/main_window/widgets/_create_sidebar/createSidebarLanguagesSettings.py @@ -344,11 +344,11 @@ def createSidebarLanguagesSettings(settings, main_window, view_variable): - sls__box_translation_optionmenu_wrapper = CTkFrame(main_window.sls__box_frame, corner_radius=0, fg_color=settings.ctm.SLS__BG_COLOR, width=0, height=0) - sls__box_translation_optionmenu_wrapper.grid(row=5, column=0, pady=settings.uism.SLS__SELECTABLE_TRANSLATION_PADY, sticky="ew") + main_window.sls__box_translation_optionmenu_wrapper = CTkFrame(main_window.sls__box_frame, corner_radius=0, fg_color=settings.ctm.SLS__BG_COLOR, width=0, height=0) + main_window.sls__box_translation_optionmenu_wrapper.grid(row=5, column=0, pady=settings.uism.SLS__SELECTABLE_TRANSLATION_PADY, sticky="ew") - sls__box_translation_optionmenu_wrapper.grid_columnconfigure((0,2), weight=0, minsize=settings.uism.SLS__SELECTABLE_TRANSLATION_MIN_PADX) - sls__box_translation_optionmenu_wrapper.grid_columnconfigure(1, weight=1) + main_window.sls__box_translation_optionmenu_wrapper.grid_columnconfigure((0,2), weight=0, minsize=settings.uism.SLS__SELECTABLE_TRANSLATION_MIN_PADX) + main_window.sls__box_translation_optionmenu_wrapper.grid_columnconfigure(1, weight=1) @@ -361,12 +361,12 @@ def createSidebarLanguagesSettings(settings, main_window, view_variable): dropdown_menu_values=[], command=adjustedCommand, wrapper_widget=main_window, - attach_widget=sls__box_translation_optionmenu_wrapper, + attach_widget=main_window.sls__box_translation_optionmenu_wrapper, dropdown_menu_min_width=settings.uism.SIDEBAR_MIN_WIDTH, ) (sls__selected_translation_engine_box, label_button_label_widget) = createLabelButton( - parent_widget=sls__box_translation_optionmenu_wrapper, + parent_widget=main_window.sls__box_translation_optionmenu_wrapper, label_button_bg_color=settings.ctm.SLS__BG_COLOR, label_button_hovered_bg_color=settings.ctm.SLS__OPTIONMENU_HOVERED_BG_COLOR, label_button_clicked_bg_color=settings.ctm.SLS__OPTIONMENU_CLICKED_BG_COLOR, From d0a9be1b79a2e77db35d9fcce90e6172d1fd13e6 Mon Sep 17 00:00:00 2001 From: Sakamoto Shiina <68018796+ShiinaSakamoto@users.noreply.github.com> Date: Wed, 17 Jan 2024 18:45:19 +0900 Subject: [PATCH 3/3] =?UTF-8?q?[bugfix]=20=E8=A8=AD=E5=AE=9A=E7=94=BB?= =?UTF-8?q?=E9=9D=A2=E3=80=8C=E7=BF=BB=E8=A8=B3=E6=A9=9F=E8=83=BD=E3=82=92?= =?UTF-8?q?=E4=BD=BF=E7=94=A8=E3=81=99=E3=82=8B=E3=80=8D=E5=88=87=E6=9B=BF?= =?UTF-8?q?=E6=99=82=E3=81=AB=E3=80=81=E3=83=A1=E3=82=A4=E3=83=B3=E7=94=BB?= =?UTF-8?q?=E9=9D=A2=E3=82=AB=E3=83=90=E3=83=BC=E3=81=8C=E5=89=8D=E3=81=AB?= =?UTF-8?q?=E5=87=BA=E3=81=A6=E3=81=8D=E3=81=A6=E3=81=97=E3=81=BE=E3=81=86?= =?UTF-8?q?=E3=81=AE=E3=82=92=E7=84=A1=E7=90=86=E3=82=84=E3=82=8A=E4=BF=AE?= =?UTF-8?q?=E6=AD=A3=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit config.WEIGHT_TYPEがm2m100_418mの時に、view.py側で"Small"と解釈するように一時的な処理をいれています。 --- view.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/view.py b/view.py index d2a5a47f..ae487ccc 100644 --- a/view.py +++ b/view.py @@ -884,10 +884,13 @@ class View(): self.openCtranslate2WeightTypeWidget() self.setTranslationSwitchStatus("normal", release_locked_state=True) vrct_gui.sls__box_translation_optionmenu_wrapper.grid() + vrct_gui.config_window.after(200, vrct_gui.config_window.lift) + elif state == "Disable": view.closeCtranslate2WeightTypeWidget() view.setTranslationSwitchStatus("disabled", to_lock_state=True) vrct_gui.sls__box_translation_optionmenu_wrapper.grid_remove() + vrct_gui.config_window.after(200, vrct_gui.config_window.lift) # Open Webpage Functions def openWebPage_Booth(self): @@ -1010,7 +1013,9 @@ class View(): self.view_variable.VAR_CTRANSLATE2_WEIGHT_TYPE.set(self.getSelectableCtranslate2WeightTypeDict()[selected_weight_type]) def setLatestCTranslate2WeightType(self): - selected_weight_type = self.getSelectableCtranslate2WeightTypeDict()[config.WEIGHT_TYPE] + if config.WEIGHT_TYPE == "m2m100_418m": + WEIGHT_TYPE = "Small" + selected_weight_type = self.getSelectableCtranslate2WeightTypeDict()[WEIGHT_TYPE] self.view_variable.VAR_CTRANSLATE2_WEIGHT_TYPE.set(selected_weight_type)