From a1b53dc2b098184022ecb120385a0be544d3aa0b Mon Sep 17 00:00:00 2001 From: misyaguziya Date: Fri, 19 Jan 2024 01:27:41 +0900 Subject: [PATCH 01/10] =?UTF-8?q?[WIP/TEST]=20Controller=20:=20CTranslate2?= =?UTF-8?q?=E3=81=AE=E3=83=A2=E3=83=87=E3=83=AB=E5=A4=89=E6=9B=B4=E6=99=82?= =?UTF-8?q?=E5=87=A6=E7=90=86=E3=82=92=E5=AE=9F=E8=A3=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- controller.py | 10 ++++++---- view.py | 13 ++++++++++++- vrct_gui/_CreateDropdownMenuWindow.py | 6 ++++-- 3 files changed, 22 insertions(+), 7 deletions(-) diff --git a/controller.py b/controller.py index d65d010d..a01fc008 100644 --- a/controller.py +++ b/controller.py @@ -491,8 +491,8 @@ def callbackSetUseTranslationFeature(value): if model.checkCTranslatorCTranslate2ModelWeight(): model.changeTranslatorCTranslate2Model() else: - view.useTranslationFeatureProcess("Disable") - # CTranslate2 weight is not downloaded + view.showRestartButtonIfRequired() + view.useTranslationFeatureProcess("Restart") else: view.useTranslationFeatureProcess("Disable") @@ -502,9 +502,11 @@ def callbackSetCtranslate2WeightType(value): view.updateSelectedCtranslate2WeightType(config.WEIGHT_TYPE) if model.checkCTranslatorCTranslate2ModelWeight(): model.changeTranslatorCTranslate2Model() + view.showRestartButtonIfRequired() + view.useTranslationFeatureProcess("Normal") else: - view.useTranslationFeatureProcess("Disable") - # CTranslate2 weight is not downloaded + view.showRestartButtonIfRequired() + view.useTranslationFeatureProcess("Restart") def callbackSetDeeplAuthkey(value): print("callbackSetDeeplAuthkey", str(value)) diff --git a/view.py b/view.py index 52fb174c..02acb490 100644 --- a/view.py +++ b/view.py @@ -28,6 +28,8 @@ class View(): ui_scaling=config.UI_SCALING, font_family=config.FONT_FAMILY, ui_language=config.UI_LANGUAGE, + use_translation_feature=config.USE_TRANSLATION_FEATURE, + ctranslate2_weight_type=config.WEIGHT_TYPE, ) if config.ENABLE_SPEAKER2CHATBOX is False: @@ -891,6 +893,13 @@ class View(): vrct_gui.sls__box_translation_optionmenu_wrapper.grid_remove() vrct_gui.config_window.after(200, vrct_gui.config_window.lift) + elif state == "Restart": + view.setLatestCTranslate2WeightType() + view.setTranslationSwitchStatus("disabled", to_lock_state=True) + vrct_gui.sls__box_translation_optionmenu_wrapper.grid() + vrct_gui.config_window.after(200, vrct_gui.config_window.lift) + + # Open Webpage Functions def openWebPage_Booth(self): self.openWebPage(config.BOOTH_URL) @@ -984,7 +993,9 @@ class View(): self.restart_required_configs_pre_data.appearance_theme == config.APPEARANCE_THEME and self.restart_required_configs_pre_data.ui_scaling == config.UI_SCALING and self.restart_required_configs_pre_data.font_family == config.FONT_FAMILY and - self.restart_required_configs_pre_data.ui_language == config.UI_LANGUAGE + self.restart_required_configs_pre_data.ui_language == config.UI_LANGUAGE and + self.restart_required_configs_pre_data.use_translation_feature == config.USE_TRANSLATION_FEATURE and + self.restart_required_configs_pre_data.ctranslate2_weight_type == config.WEIGHT_TYPE ) if locale is None: diff --git a/vrct_gui/_CreateDropdownMenuWindow.py b/vrct_gui/_CreateDropdownMenuWindow.py index 5ca598e0..7bb233cb 100644 --- a/vrct_gui/_CreateDropdownMenuWindow.py +++ b/vrct_gui/_CreateDropdownMenuWindow.py @@ -326,9 +326,11 @@ class _CreateDropdownMenuWindow(CTkToplevel): def _withdraw(self, e=None): self.withdraw() - self.attach_widget.winfo_toplevel().unbind("", self.BIND_CONFIGURE_FUNC_ID) + if self.BIND_CONFIGURE_FUNC_ID in self.attach_widget.winfo_toplevel().bind(): + self.attach_widget.winfo_toplevel().unbind("", self.BIND_CONFIGURE_FUNC_ID) self.attach_widget.unbind("", self.BIND_UNMAP_FUNC_ID) - self.attach_widget.winfo_toplevel().unbind("", self.BIND_BUTTON_1_FUNC_ID) + if self.BIND_BUTTON_1_FUNC_ID in self.attach_widget.winfo_toplevel().bind(): + self.attach_widget.winfo_toplevel().unbind("", self.BIND_BUTTON_1_FUNC_ID) self.hide = True From f48581dcd8149e9966b51ffbd98f717c8689a440 Mon Sep 17 00:00:00 2001 From: misyaguziya Date: Fri, 19 Jan 2024 18:27:27 +0900 Subject: [PATCH 02/10] =?UTF-8?q?[WIP/TEST]=20Controller=20:=20=E3=83=A2?= =?UTF-8?q?=E3=83=87=E3=83=AB=E3=81=AE=E3=83=AD=E3=83=BC=E3=83=89=E5=87=A6?= =?UTF-8?q?=E7=90=86=E3=82=92=E3=82=B9=E3=83=AC=E3=83=83=E3=83=89=E3=81=AB?= =?UTF-8?q?=E5=A4=89=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ・モデルの切り替え時や翻訳機能有効時にリスタートボタンの表示タイミングが微妙な為改修の必要あり --- controller.py | 16 ++++++++++++---- vrct_gui/_CreateDropdownMenuWindow.py | 13 ++++++++++--- 2 files changed, 22 insertions(+), 7 deletions(-) diff --git a/controller.py b/controller.py index a01fc008..a528db3b 100644 --- a/controller.py +++ b/controller.py @@ -489,7 +489,11 @@ def callbackSetUseTranslationFeature(value): if config.USE_TRANSLATION_FEATURE is True: view.useTranslationFeatureProcess("Normal") if model.checkCTranslatorCTranslate2ModelWeight(): - model.changeTranslatorCTranslate2Model() + def callback(): + model.changeTranslatorCTranslate2Model() + th_callback = Thread(target=callback) + th_callback.daemon = True + th_callback.start() else: view.showRestartButtonIfRequired() view.useTranslationFeatureProcess("Restart") @@ -501,9 +505,13 @@ def callbackSetCtranslate2WeightType(value): config.WEIGHT_TYPE = str(value) view.updateSelectedCtranslate2WeightType(config.WEIGHT_TYPE) if model.checkCTranslatorCTranslate2ModelWeight(): - model.changeTranslatorCTranslate2Model() - view.showRestartButtonIfRequired() - view.useTranslationFeatureProcess("Normal") + def callback(): + model.changeTranslatorCTranslate2Model() + view.showRestartButtonIfRequired() + view.useTranslationFeatureProcess("Normal") + th_callback = Thread(target=callback) + th_callback.daemon = True + th_callback.start() else: view.showRestartButtonIfRequired() view.useTranslationFeatureProcess("Restart") diff --git a/vrct_gui/_CreateDropdownMenuWindow.py b/vrct_gui/_CreateDropdownMenuWindow.py index 7bb233cb..d6853b35 100644 --- a/vrct_gui/_CreateDropdownMenuWindow.py +++ b/vrct_gui/_CreateDropdownMenuWindow.py @@ -326,11 +326,18 @@ class _CreateDropdownMenuWindow(CTkToplevel): def _withdraw(self, e=None): self.withdraw() - if self.BIND_CONFIGURE_FUNC_ID in self.attach_widget.winfo_toplevel().bind(): + try: self.attach_widget.winfo_toplevel().unbind("", self.BIND_CONFIGURE_FUNC_ID) - self.attach_widget.unbind("", self.BIND_UNMAP_FUNC_ID) - if self.BIND_BUTTON_1_FUNC_ID in self.attach_widget.winfo_toplevel().bind(): + except Exception: + pass + try: + self.attach_widget.unbind("", self.BIND_UNMAP_FUNC_ID) + except Exception: + pass + try: self.attach_widget.winfo_toplevel().unbind("", self.BIND_BUTTON_1_FUNC_ID) + except Exception: + pass self.hide = True From 9dd10f14a8d9a518398f77fb1f3d5e53dc6f8443 Mon Sep 17 00:00:00 2001 From: Sakamoto Shiina <68018796+ShiinaSakamoto@users.noreply.github.com> Date: Sat, 20 Jan 2024 13:30:28 +0900 Subject: [PATCH 03/10] =?UTF-8?q?[bugfix]=20Use=20translation=20feature?= =?UTF-8?q?=E3=82=AA=E3=83=B3=E6=99=82=E3=80=81weight=E5=88=87=E6=9B=BF?= =?UTF-8?q?=E6=99=82=E3=81=AA=E3=81=A9=E3=81=AB=E3=83=A1=E3=82=A4=E3=83=B3?= =?UTF-8?q?=E7=94=BB=E9=9D=A2=E9=BB=92=E3=81=84=E3=82=AB=E3=83=90=E3=83=BC?= =?UTF-8?q?=E3=81=8C=E5=89=8D=E3=81=AB=E5=87=BA=E3=81=A6=E3=81=8D=E3=81=A6?= =?UTF-8?q?=E3=80=81=E3=81=9D=E3=81=93=E3=81=9D=E3=81=93=E9=95=B7=E3=81=84?= =?UTF-8?q?=E6=99=82=E9=96=93=E3=81=A8=E3=81=A9=E3=81=BE=E3=81=A3=E3=81=A6?= =?UTF-8?q?=E3=81=84=E3=81=9F=E3=81=AE=E3=82=92=E4=BF=AE=E6=AD=A3=E3=80=82?= =?UTF-8?q?=E5=AE=8C=E5=85=A8=E3=81=A7=E3=81=AF=E3=81=AA=E3=81=84=E3=81=8C?= =?UTF-8?q?=E5=A6=A5=E5=8D=94=E6=A1=88=E3=81=A7=E3=81=99=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- view.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/view.py b/view.py index 02acb490..91497027 100644 --- a/view.py +++ b/view.py @@ -885,19 +885,21 @@ 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) + vrct_gui.update() 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) + vrct_gui.update() elif state == "Restart": view.setLatestCTranslate2WeightType() view.setTranslationSwitchStatus("disabled", to_lock_state=True) vrct_gui.sls__box_translation_optionmenu_wrapper.grid() - vrct_gui.config_window.after(200, vrct_gui.config_window.lift) + + vrct_gui.update() + vrct_gui.config_window.lift() # Open Webpage Functions From 3fc3ae02bbca2b5817e6ea984a5b863ec638e81d Mon Sep 17 00:00:00 2001 From: misyaguziya Date: Sat, 20 Jan 2024 14:19:14 +0900 Subject: [PATCH 04/10] =?UTF-8?q?[WIP/TEST]=20Controller=20:=20Reset?= =?UTF-8?q?=E3=83=9C=E3=82=BF=E3=83=B3=E3=81=AE=E8=A1=A8=E7=A4=BA=E3=82=BF?= =?UTF-8?q?=E3=82=A4=E3=83=9F=E3=83=B3=E3=82=B0=E3=82=92=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config.py | 10 ++++++++++ controller.py | 8 ++++++++ view.py | 6 ++---- 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/config.py b/config.py index 54b057a5..c1af4611 100644 --- a/config.py +++ b/config.py @@ -197,6 +197,15 @@ class Config: if value in list(translation_lang.keys()): self._CHOICE_OUTPUT_TRANSLATOR = value + @property + def IS_RESET_BUTTON_DISPLAYED_FOR_TRANSLATION(self): + return self._IS_RESET_BUTTON_DISPLAYED_FOR_TRANSLATION + + @IS_RESET_BUTTON_DISPLAYED_FOR_TRANSLATION.setter + def IS_RESET_BUTTON_DISPLAYED_FOR_TRANSLATION(self, value): + if isinstance(value, bool): + self._IS_RESET_BUTTON_DISPLAYED_FOR_TRANSLATION = value + # Save Json Data ## Main Window @property @@ -761,6 +770,7 @@ class Config: self._SOURCE_COUNTRY = "Japan" self._TARGET_LANGUAGE = "English" self._TARGET_COUNTRY = "United States" + self._IS_RESET_BUTTON_DISPLAYED_FOR_TRANSLATION = False # Save Json Data ## Main Window diff --git a/controller.py b/controller.py index a528db3b..cf3aa39e 100644 --- a/controller.py +++ b/controller.py @@ -490,14 +490,19 @@ def callbackSetUseTranslationFeature(value): view.useTranslationFeatureProcess("Normal") if model.checkCTranslatorCTranslate2ModelWeight(): def callback(): + config.IS_RESET_BUTTON_DISPLAYED_FOR_TRANSLATION = False + view.showRestartButtonIfRequired() model.changeTranslatorCTranslate2Model() th_callback = Thread(target=callback) th_callback.daemon = True th_callback.start() else: + config.IS_RESET_BUTTON_DISPLAYED_FOR_TRANSLATION = True view.showRestartButtonIfRequired() view.useTranslationFeatureProcess("Restart") else: + config.IS_RESET_BUTTON_DISPLAYED_FOR_TRANSLATION = False + view.showRestartButtonIfRequired() view.useTranslationFeatureProcess("Disable") def callbackSetCtranslate2WeightType(value): @@ -506,6 +511,8 @@ def callbackSetCtranslate2WeightType(value): view.updateSelectedCtranslate2WeightType(config.WEIGHT_TYPE) if model.checkCTranslatorCTranslate2ModelWeight(): def callback(): + config.IS_RESET_BUTTON_DISPLAYED_FOR_TRANSLATION = False + view.showRestartButtonIfRequired() model.changeTranslatorCTranslate2Model() view.showRestartButtonIfRequired() view.useTranslationFeatureProcess("Normal") @@ -513,6 +520,7 @@ def callbackSetCtranslate2WeightType(value): th_callback.daemon = True th_callback.start() else: + config.IS_RESET_BUTTON_DISPLAYED_FOR_TRANSLATION = True view.showRestartButtonIfRequired() view.useTranslationFeatureProcess("Restart") diff --git a/view.py b/view.py index 02acb490..60365984 100644 --- a/view.py +++ b/view.py @@ -28,8 +28,7 @@ class View(): ui_scaling=config.UI_SCALING, font_family=config.FONT_FAMILY, ui_language=config.UI_LANGUAGE, - use_translation_feature=config.USE_TRANSLATION_FEATURE, - ctranslate2_weight_type=config.WEIGHT_TYPE, + is_reset_button_displayed_for_translation=config.IS_RESET_BUTTON_DISPLAYED_FOR_TRANSLATION, ) if config.ENABLE_SPEAKER2CHATBOX is False: @@ -994,8 +993,7 @@ class View(): self.restart_required_configs_pre_data.ui_scaling == config.UI_SCALING and self.restart_required_configs_pre_data.font_family == config.FONT_FAMILY and self.restart_required_configs_pre_data.ui_language == config.UI_LANGUAGE and - self.restart_required_configs_pre_data.use_translation_feature == config.USE_TRANSLATION_FEATURE and - self.restart_required_configs_pre_data.ctranslate2_weight_type == config.WEIGHT_TYPE + self.restart_required_configs_pre_data.is_reset_button_displayed_for_translation == config.IS_RESET_BUTTON_DISPLAYED_FOR_TRANSLATION ) if locale is None: From b0def64cf177848f7400ef26684d59ffb4ff5acc Mon Sep 17 00:00:00 2001 From: Sakamoto Shiina <68018796+ShiinaSakamoto@users.noreply.github.com> Date: Sat, 20 Jan 2024 18:13:18 +0900 Subject: [PATCH 05/10] =?UTF-8?q?[Update]=20Main=20Window=20Sidebar:=20?= =?UTF-8?q?=E7=BF=BB=E8=A8=B3=E6=A9=9F=E8=83=BD=E3=82=92=E4=BD=BF=E3=82=8F?= =?UTF-8?q?=E3=81=AA=E3=81=84=E6=99=82=E3=81=AF=E3=80=81=E3=81=9D=E3=82=82?= =?UTF-8?q?=E3=81=9D=E3=82=82=E7=BF=BB=E8=A8=B3=E6=A9=9F=E8=83=BD=E3=81=AE?= =?UTF-8?q?=E3=83=9C=E3=82=BF=E3=83=B3=E3=82=92=E8=A1=A8=E7=A4=BA=E3=81=97?= =?UTF-8?q?=E3=81=AA=E3=81=84=E3=82=88=E3=81=86=E3=81=AB=E3=80=82=20?= =?UTF-8?q?=E9=9F=B3=E5=A3=B0=E8=AA=8D=E8=AD=98=E5=87=A6=E7=90=86=E4=B8=AD?= =?UTF-8?q?=E3=81=AA=E3=81=A9=E3=81=AE=E3=83=9C=E3=82=BF=E3=83=B3disabled?= =?UTF-8?q?=E6=99=82=E3=80=81=E3=82=B9=E3=82=A4=E3=83=83=E3=83=81=E3=81=AE?= =?UTF-8?q?=E8=89=B2=E3=82=92=E3=82=82=E3=81=A3=E3=81=A8=E7=84=A1=E5=8A=B9?= =?UTF-8?q?=E6=84=9F=E3=81=8C=E3=81=A7=E3=82=8B=E3=82=88=E3=81=86=E3=81=AB?= =?UTF-8?q?=E5=A4=89=E6=9B=B4=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- view.py | 6 ++++++ vrct_gui/_changeMainWindowWidgetsStatus.py | 4 ++-- vrct_gui/ui_managers/Themes/_darkTheme.py | 1 + vrct_gui/ui_managers/Themes/_lightTheme.py | 1 + 4 files changed, 10 insertions(+), 2 deletions(-) diff --git a/view.py b/view.py index 7c7f0020..692692e0 100644 --- a/view.py +++ b/view.py @@ -884,18 +884,24 @@ class View(): self.openCtranslate2WeightTypeWidget() self.setTranslationSwitchStatus("normal", release_locked_state=True) vrct_gui.sls__box_translation_optionmenu_wrapper.grid() + vrct_gui.compact_mode_translation_frame.grid() + vrct_gui.translation_frame.grid() vrct_gui.update() elif state == "Disable": view.closeCtranslate2WeightTypeWidget() view.setTranslationSwitchStatus("disabled", to_lock_state=True) vrct_gui.sls__box_translation_optionmenu_wrapper.grid_remove() + vrct_gui.compact_mode_translation_frame.grid_remove() + vrct_gui.translation_frame.grid_remove() vrct_gui.update() elif state == "Restart": view.setLatestCTranslate2WeightType() view.setTranslationSwitchStatus("disabled", to_lock_state=True) vrct_gui.sls__box_translation_optionmenu_wrapper.grid() + vrct_gui.compact_mode_translation_frame.grid() + vrct_gui.translation_frame.grid() vrct_gui.update() vrct_gui.config_window.lift() diff --git a/vrct_gui/_changeMainWindowWidgetsStatus.py b/vrct_gui/_changeMainWindowWidgetsStatus.py index 3a77cb32..3b6eaf74 100644 --- a/vrct_gui/_changeMainWindowWidgetsStatus.py +++ b/vrct_gui/_changeMainWindowWidgetsStatus.py @@ -28,13 +28,13 @@ def _changeMainWindowWidgetsStatus(vrct_gui, settings, view_variable, status, ta if status == "disabled": widget_frame.configure(cursor="") widget_label.configure(text_color=settings.ctm.SF__TEXT_DISABLED_COLOR) - widget_switch_box.configure(state="disabled", progress_color=settings.ctm.SF__SWITCH_BOX_DISABLE_BG_COLOR) + widget_switch_box.configure(state="disabled", progress_color=settings.ctm.SF__SWITCH_BOX_DISABLE_BG_COLOR, button_color=settings.ctm.SF__SWITCH_BOX_BUTTON_DISABLED_COLOR) widget_selected_mark.configure(fg_color=settings.ctm.SF__SELECTED_MARK_DISABLE_BG_COLOR) icon_file = disabled_icon_name elif status == "normal": widget_frame.configure(cursor="hand2") widget_label.configure(text_color=settings.ctm.LABELS_TEXT_COLOR) - widget_switch_box.configure(state="normal", progress_color=settings.ctm.SF__SWITCH_BOX_ACTIVE_BG_COLOR) + widget_switch_box.configure(state="normal", progress_color=settings.ctm.SF__SWITCH_BOX_ACTIVE_BG_COLOR, button_color=settings.ctm.SF__SWITCH_BOX_BUTTON_COLOR) widget_selected_mark.configure(fg_color=settings.ctm.SF__SELECTED_MARK_ACTIVE_BG_COLOR) icon_file = icon_name diff --git a/vrct_gui/ui_managers/Themes/_darkTheme.py b/vrct_gui/ui_managers/Themes/_darkTheme.py index 15721fb8..8442b6bb 100644 --- a/vrct_gui/ui_managers/Themes/_darkTheme.py +++ b/vrct_gui/ui_managers/Themes/_darkTheme.py @@ -58,6 +58,7 @@ def _darkTheme(base_color): SF__SWITCH_BOX_DISABLE_BG_COLOR = base_color.PRIMARY_800_COLOR, SF__SWITCH_BOX_BUTTON_COLOR = base_color.DARK_400_COLOR, + SF__SWITCH_BOX_BUTTON_DISABLED_COLOR = base_color.DARK_600_COLOR, # It's not working because It overrode internally. SF__SWITCH_BOX_BUTTON_HOVERED_COLOR = base_color.DARK_350_COLOR, diff --git a/vrct_gui/ui_managers/Themes/_lightTheme.py b/vrct_gui/ui_managers/Themes/_lightTheme.py index 2261386e..8d2ff33b 100644 --- a/vrct_gui/ui_managers/Themes/_lightTheme.py +++ b/vrct_gui/ui_managers/Themes/_lightTheme.py @@ -58,6 +58,7 @@ def _lightTheme(base_color): SF__SWITCH_BOX_DISABLE_BG_COLOR = base_color.PRIMARY_200_COLOR, SF__SWITCH_BOX_BUTTON_COLOR = base_color.LIGHT_150_COLOR, + SF__SWITCH_BOX_BUTTON_DISABLED_COLOR = base_color.LIGHT_300_COLOR, # It's not working because It overrode internally. SF__SWITCH_BOX_BUTTON_HOVERED_COLOR = base_color.LIGHT_300_COLOR, From 9208bb3ac3b9fd6b9b651eed0086e0fbdacd15eb Mon Sep 17 00:00:00 2001 From: Sakamoto Shiina <68018796+ShiinaSakamoto@users.noreply.github.com> Date: Sun, 21 Jan 2024 13:00:16 +0900 Subject: [PATCH 06/10] =?UTF-8?q?[Chore]=20view.py=20gui=E3=81=AEupdate?= =?UTF-8?q?=E9=96=A2=E6=95=B0=E5=87=A6=E7=90=86=E3=81=8C=E8=A2=AB=E3=81=A3?= =?UTF-8?q?=E3=81=A6=E3=81=84=E3=81=9F=E3=81=AE=E3=82=92=E4=BF=AE=E6=AD=A3?= =?UTF-8?q?=E3=80=82=E2=80=BB=E6=B6=88=E3=81=97=E5=BF=98=E3=82=8C=E3=81=A7?= =?UTF-8?q?=E3=81=97=E3=81=9F=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- view.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/view.py b/view.py index 692692e0..20b9678e 100644 --- a/view.py +++ b/view.py @@ -886,7 +886,6 @@ class View(): vrct_gui.sls__box_translation_optionmenu_wrapper.grid() vrct_gui.compact_mode_translation_frame.grid() vrct_gui.translation_frame.grid() - vrct_gui.update() elif state == "Disable": view.closeCtranslate2WeightTypeWidget() @@ -894,7 +893,6 @@ class View(): vrct_gui.sls__box_translation_optionmenu_wrapper.grid_remove() vrct_gui.compact_mode_translation_frame.grid_remove() vrct_gui.translation_frame.grid_remove() - vrct_gui.update() elif state == "Restart": view.setLatestCTranslate2WeightType() From 59079def6a48e15112e8a7c4ca12bc807564219e Mon Sep 17 00:00:00 2001 From: Sakamoto Shiina <68018796+ShiinaSakamoto@users.noreply.github.com> Date: Sun, 21 Jan 2024 14:49:04 +0900 Subject: [PATCH 07/10] =?UTF-8?q?[bugfix]=20Config=20Window:=20=E5=86=8D?= =?UTF-8?q?=E8=B5=B7=E5=8B=95=E3=83=9C=E3=82=BF=E3=83=B3=E8=A1=A8=E7=A4=BA?= =?UTF-8?q?=E3=81=AE=E3=83=A9=E3=83=99=E3=83=AB=E3=81=8C=E8=A1=A8=E7=A4=BA?= =?UTF-8?q?=E3=81=95=E3=82=8C=E3=81=AA=E3=81=84=E5=A0=B4=E5=90=88=E3=81=8C?= =?UTF-8?q?=E3=81=82=E3=82=8B=E3=83=90=E3=82=B0=E4=BF=AE=E6=AD=A3=E3=80=82?= =?UTF-8?q?=20weight=20type=E5=A4=89=E6=9B=B4=E6=99=82=E3=81=AE=E3=81=BF?= =?UTF-8?q?=E7=99=BA=E7=94=9F=E3=81=97=E3=81=A6=E3=81=84=E3=81=9F=E3=80=82?= =?UTF-8?q?after=E9=96=A2=E6=95=B0=E3=82=92=E4=BD=BF=E3=81=84=E3=80=81?= =?UTF-8?q?=E8=A1=A8=E7=A4=BA=E3=82=92=E8=8B=A5=E5=B9=B2=E9=81=85=E3=82=89?= =?UTF-8?q?=E3=81=9B=E3=82=8B=E3=81=93=E3=81=A8=E3=81=A7=E5=AF=BE=E5=87=A6?= =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- view.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/view.py b/view.py index 20b9678e..093d5e60 100644 --- a/view.py +++ b/view.py @@ -1013,7 +1013,8 @@ class View(): def _showRestartButton(self, locale:Union[None,str]=None): self.view_variable.VAR_CONFIG_WINDOW_RESTART_BUTTON_LABEL.set(i18n.t("config_window.restart_message", locale=locale)) - vrct_gui.config_window.restart_button_container.grid() + # This .after() func is for fixing bug that it can't be shown the label widget after changing the weight type. + vrct_gui.config_window.after(100, vrct_gui.config_window.restart_button_container.grid) def _hideRestartButton(self): vrct_gui.config_window.restart_button_container.grid_remove() From 6ed71f1a4aad703e8f8edd638b38ee0eef2aad26 Mon Sep 17 00:00:00 2001 From: misyaguziya Date: Mon, 22 Jan 2024 01:45:18 +0900 Subject: [PATCH 08/10] =?UTF-8?q?=F0=9F=90=9B[bugfix]=20Controller=20:=20?= =?UTF-8?q?=E3=83=AA=E3=82=B9=E3=82=BF=E3=83=BC=E3=83=88=E3=83=9C=E3=82=BF?= =?UTF-8?q?=E3=83=B3=E3=81=AE=E8=A1=A8=E7=A4=BA=E3=82=BF=E3=82=A4=E3=83=9F?= =?UTF-8?q?=E3=83=B3=E3=82=B0=E3=82=92=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- controller.py | 12 ++++-------- view.py | 3 +-- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/controller.py b/controller.py index cf3aa39e..d8f9efac 100644 --- a/controller.py +++ b/controller.py @@ -489,40 +489,36 @@ def callbackSetUseTranslationFeature(value): if config.USE_TRANSLATION_FEATURE is True: view.useTranslationFeatureProcess("Normal") if model.checkCTranslatorCTranslate2ModelWeight(): + config.IS_RESET_BUTTON_DISPLAYED_FOR_TRANSLATION = False def callback(): - config.IS_RESET_BUTTON_DISPLAYED_FOR_TRANSLATION = False - view.showRestartButtonIfRequired() model.changeTranslatorCTranslate2Model() th_callback = Thread(target=callback) th_callback.daemon = True th_callback.start() else: config.IS_RESET_BUTTON_DISPLAYED_FOR_TRANSLATION = True - view.showRestartButtonIfRequired() view.useTranslationFeatureProcess("Restart") else: config.IS_RESET_BUTTON_DISPLAYED_FOR_TRANSLATION = False - view.showRestartButtonIfRequired() view.useTranslationFeatureProcess("Disable") + view.showRestartButtonIfRequired() def callbackSetCtranslate2WeightType(value): print("callbackSetCtranslate2WeightType", value) config.WEIGHT_TYPE = str(value) view.updateSelectedCtranslate2WeightType(config.WEIGHT_TYPE) if model.checkCTranslatorCTranslate2ModelWeight(): + config.IS_RESET_BUTTON_DISPLAYED_FOR_TRANSLATION = False def callback(): - config.IS_RESET_BUTTON_DISPLAYED_FOR_TRANSLATION = False - view.showRestartButtonIfRequired() model.changeTranslatorCTranslate2Model() - view.showRestartButtonIfRequired() view.useTranslationFeatureProcess("Normal") th_callback = Thread(target=callback) th_callback.daemon = True th_callback.start() else: config.IS_RESET_BUTTON_DISPLAYED_FOR_TRANSLATION = True - view.showRestartButtonIfRequired() view.useTranslationFeatureProcess("Restart") + view.showRestartButtonIfRequired() def callbackSetDeeplAuthkey(value): print("callbackSetDeeplAuthkey", str(value)) diff --git a/view.py b/view.py index 093d5e60..20b9678e 100644 --- a/view.py +++ b/view.py @@ -1013,8 +1013,7 @@ class View(): def _showRestartButton(self, locale:Union[None,str]=None): self.view_variable.VAR_CONFIG_WINDOW_RESTART_BUTTON_LABEL.set(i18n.t("config_window.restart_message", locale=locale)) - # This .after() func is for fixing bug that it can't be shown the label widget after changing the weight type. - vrct_gui.config_window.after(100, vrct_gui.config_window.restart_button_container.grid) + vrct_gui.config_window.restart_button_container.grid() def _hideRestartButton(self): vrct_gui.config_window.restart_button_container.grid_remove() From 46aafa4a4d2ecb9e9cd2e0fe65cc3afc489bfa9c Mon Sep 17 00:00:00 2001 From: Sakamoto Shiina <68018796+ShiinaSakamoto@users.noreply.github.com> Date: Mon, 22 Jan 2024 18:20:10 +0900 Subject: [PATCH 09/10] =?UTF-8?q?[Update/Refactor]=20Main=20Window:=20Use?= =?UTF-8?q?=20translation=20feature=20ON/OFF=E6=99=82=E3=81=AEwidget?= =?UTF-8?q?=E8=AA=BF=E6=95=B4=E3=80=82=20Translation=20Each=20Other?= =?UTF-8?q?=E8=A1=A8=E7=A4=BA=E3=81=AF=E3=80=81=E7=BF=BB=E8=A8=B3=E6=A9=9F?= =?UTF-8?q?=E8=83=BD=E4=BD=BF=E3=82=8F=E3=81=AA=E3=81=84=E5=A0=B4=E5=90=88?= =?UTF-8?q?=E3=81=AF=E5=BF=85=E8=A6=81=E3=81=AE=E3=81=AA=E3=81=84=E6=83=85?= =?UTF-8?q?=E5=A0=B1=E3=81=AA=E3=81=AE=E3=81=A7=E3=80=81=E3=81=9D=E3=81=AE?= =?UTF-8?q?=E6=99=82=E3=81=AFSwap=20Language=E8=A1=A8=E7=A4=BA=E3=81=AB?= =?UTF-8?q?=E5=9B=BA=E5=AE=9A=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- locales/en.yml | 2 +- locales/ja.yml | 2 +- locales/ko.yml | 2 +- view.py | 47 ++++++++++++++----- .../createSidebarLanguagesSettings.py | 12 ++--- 5 files changed, 41 insertions(+), 24 deletions(-) diff --git a/locales/en.yml b/locales/en.yml index 31406a23..24ac7cd7 100644 --- a/locales/en.yml +++ b/locales/en.yml @@ -6,7 +6,7 @@ main_window: language_settings: Language Settings your_language: Your Language - both_direction_desc: Translate Each Other + translate_each_other_label: Translate Each Other swap_button_label: Swap Languages target_language: Target Language translator: Translator diff --git a/locales/ja.yml b/locales/ja.yml index 2b3eb2a8..4d972a18 100644 --- a/locales/ja.yml +++ b/locales/ja.yml @@ -6,7 +6,7 @@ main_window: language_settings: 言語設定 your_language: あなたの言語 - both_direction_desc: 双方向に翻訳 + translate_each_other_label: 双方向に翻訳 swap_button_label: 言語を入れ替え target_language: 相手の言語 translator: 翻訳エンジン diff --git a/locales/ko.yml b/locales/ko.yml index 11e23fae..ff30399f 100644 --- a/locales/ko.yml +++ b/locales/ko.yml @@ -6,7 +6,7 @@ main_window: language_settings: 언어 설정 your_language: 당신의 언어 - both_direction_desc: 양방향으로 번역 + translate_each_other_label: 양방향으로 번역 swap_button_label: 언어 교체 target_language: 상대방의 언어 diff --git a/view.py b/view.py index 20b9678e..3ed71a23 100644 --- a/view.py +++ b/view.py @@ -162,9 +162,10 @@ class View(): IS_OPENED_SELECTABLE_YOUR_LANGUAGE_WINDOW=False, CALLBACK_SELECTED_YOUR_LANGUAGE=None, - VAR_LABEL_BOTH_DIRECTION_DESC=StringVar(value=i18n.t("main_window.both_direction_desc")), - VAR_LABEL_BOTH_DIRECTION_SWAP_BUTTON=StringVar(value=i18n.t("main_window.swap_button_label")), + VAR_LABEL_BOTH_DIRECTION_SWAP_BUTTON=StringVar(value=""), CALLBACK_SWAP_LANGUAGES=None, + CALLBACK_ENTERED_SWAP_LANGUAGES_BUTTON=self._enteredSwapLanguagesButton, + CALLBACK_LEAVED_SWAP_LANGUAGES_BUTTON=self._leavedSwapLanguagesButton, VAR_LABEL_TARGET_LANGUAGE=StringVar(value=i18n.t("main_window.target_language")), VAR_TARGET_LANGUAGE = StringVar(value=f"{config.TARGET_LANGUAGE}\n({config.TARGET_COUNTRY})"), @@ -651,7 +652,9 @@ class View(): if config.USE_TRANSLATION_FEATURE is True: self.useTranslationFeatureProcess("Normal") + self.view_variable.VAR_LABEL_BOTH_DIRECTION_SWAP_BUTTON.set(i18n.t("main_window.translate_each_other_label")) else: + self.view_variable.VAR_LABEL_BOTH_DIRECTION_SWAP_BUTTON.set(i18n.t("main_window.swap_button_label")) self.useTranslationFeatureProcess("Disable") if config.CHOICE_MIC_HOST == "NoHost": @@ -879,27 +882,34 @@ class View(): } def useTranslationFeatureProcess(self, state:str): + def changeWidget_UseTranslationFeature(): + vrct_gui.sls__box_translation_optionmenu_wrapper.grid() + vrct_gui.compact_mode_translation_frame.grid() + vrct_gui.translation_frame.grid() + self.view_variable.VAR_LABEL_BOTH_DIRECTION_SWAP_BUTTON.set(i18n.t("main_window.translate_each_other_label")) + + def changeWidget_DontUseTranslationFeature(): + vrct_gui.sls__box_translation_optionmenu_wrapper.grid_remove() + vrct_gui.compact_mode_translation_frame.grid_remove() + vrct_gui.translation_frame.grid_remove() + self.view_variable.VAR_LABEL_BOTH_DIRECTION_SWAP_BUTTON.set(i18n.t("main_window.swap_button_label")) + + if state == "Normal": self.setLatestCTranslate2WeightType() self.openCtranslate2WeightTypeWidget() self.setTranslationSwitchStatus("normal", release_locked_state=True) - vrct_gui.sls__box_translation_optionmenu_wrapper.grid() - vrct_gui.compact_mode_translation_frame.grid() - vrct_gui.translation_frame.grid() + changeWidget_UseTranslationFeature() elif state == "Disable": view.closeCtranslate2WeightTypeWidget() view.setTranslationSwitchStatus("disabled", to_lock_state=True) - vrct_gui.sls__box_translation_optionmenu_wrapper.grid_remove() - vrct_gui.compact_mode_translation_frame.grid_remove() - vrct_gui.translation_frame.grid_remove() + changeWidget_DontUseTranslationFeature() elif state == "Restart": view.setLatestCTranslate2WeightType() view.setTranslationSwitchStatus("disabled", to_lock_state=True) - vrct_gui.sls__box_translation_optionmenu_wrapper.grid() - vrct_gui.compact_mode_translation_frame.grid() - vrct_gui.translation_frame.grid() + changeWidget_UseTranslationFeature() vrct_gui.update() vrct_gui.config_window.lift() @@ -1221,7 +1231,7 @@ class View(): self._clearEntryBox(vrct_gui.config_window.sb__entry_mic_word_filter_list) -# Widget Control (Whole) +# Widget Control def foregroundOnIfForegroundEnabled(self): if config.ENABLE_FOREGROUND: self.foregroundOn() @@ -1279,6 +1289,19 @@ class View(): vrct_gui.main_send_message_button_container.grid() vrct_gui.config_window.after(200, vrct_gui.config_window.lift) + def _enteredSwapLanguagesButton(self): + self.view_variable.VAR_LABEL_BOTH_DIRECTION_SWAP_BUTTON.set(i18n.t("main_window.swap_button_label")) + vrct_gui.sls__both_direction_desc.configure( + text_color=self.settings.main.ctm.SLS__BOX_ARROWS_SWAP_BUTTON_TEXT_COLOR, + ) + + def _leavedSwapLanguagesButton(self): + if config.USE_TRANSLATION_FEATURE is True: + self.view_variable.VAR_LABEL_BOTH_DIRECTION_SWAP_BUTTON.set(i18n.t("main_window.translate_each_other_label")) + vrct_gui.sls__both_direction_desc.configure( + text_color=self.settings.main.ctm.SLS__BOX_ARROWS_TEXT_COLOR, + ) + # Function def _adjustUiSizeAndRestart(self): current_percentage = int(config.UI_SCALING.replace("%","")) diff --git a/vrct_gui/main_window/widgets/_create_sidebar/createSidebarLanguagesSettings.py b/vrct_gui/main_window/widgets/_create_sidebar/createSidebarLanguagesSettings.py index e85e084a..6678ffd3 100644 --- a/vrct_gui/main_window/widgets/_create_sidebar/createSidebarLanguagesSettings.py +++ b/vrct_gui/main_window/widgets/_create_sidebar/createSidebarLanguagesSettings.py @@ -250,7 +250,7 @@ def createSidebarLanguagesSettings(settings, main_window, view_variable): main_window.sls__both_direction_desc = CTkLabel( main_window.sls__arrow_direction_swap_box, - textvariable=view_variable.VAR_LABEL_BOTH_DIRECTION_DESC, + textvariable=view_variable.VAR_LABEL_BOTH_DIRECTION_SWAP_BUTTON, height=0, font=CTkFont(family=settings.FONT_FAMILY, size=settings.uism.SLS__BOX_ARROWS_DESC_FONT_SIZE, weight="normal"), text_color=settings.ctm.SLS__BOX_ARROWS_TEXT_COLOR, @@ -286,16 +286,10 @@ def createSidebarLanguagesSettings(settings, main_window, view_variable): def adjustedCommand_Entered(): - main_window.sls__both_direction_desc.configure( - textvariable=view_variable.VAR_LABEL_BOTH_DIRECTION_SWAP_BUTTON, - text_color=settings.ctm.SLS__BOX_ARROWS_SWAP_BUTTON_TEXT_COLOR, - ) + callFunctionIfCallable(view_variable.CALLBACK_ENTERED_SWAP_LANGUAGES_BUTTON) def adjustedCommand_Leaved(): - main_window.sls__both_direction_desc.configure( - textvariable=view_variable.VAR_LABEL_BOTH_DIRECTION_DESC, - text_color=settings.ctm.SLS__BOX_ARROWS_TEXT_COLOR, - ) + callFunctionIfCallable(view_variable.CALLBACK_LEAVED_SWAP_LANGUAGES_BUTTON) bindEnterAndLeaveFunction( target_widgets=[ From edaca7edc2d3fd62531443db1067fc7a2d4335b4 Mon Sep 17 00:00:00 2001 From: Sakamoto Shiina <68018796+ShiinaSakamoto@users.noreply.github.com> Date: Mon, 22 Jan 2024 20:33:50 +0900 Subject: [PATCH 10/10] =?UTF-8?q?[bugfix/refactor]=20weight=E3=82=BF?= =?UTF-8?q?=E3=82=A4=E3=83=97=E5=A4=89=E6=9B=B4=E5=87=A6=E7=90=86=E4=B8=AD?= =?UTF-8?q?=E3=81=AF=E3=80=81weight=E3=82=BF=E3=82=A4=E3=83=97=E5=A4=89?= =?UTF-8?q?=E6=9B=B4=E3=81=A8=E7=BF=BB=E8=A8=B3=E6=A9=9F=E8=83=BD=E3=82=AA?= =?UTF-8?q?=E3=83=B3=E3=82=AA=E3=83=95widget=E3=82=92disabled=E3=81=AB?= =?UTF-8?q?=E3=80=82=20=E7=90=86=E7=94=B1:=20weight=E3=82=BF=E3=82=A4?= =?UTF-8?q?=E3=83=97=E5=A4=89=E6=9B=B4=E5=87=A6=E7=90=86=E3=81=AF=E9=9D=9E?= =?UTF-8?q?=E5=90=8C=E6=9C=9F=E3=81=A7=E3=80=81=E5=A4=89=E6=9B=B4=E5=87=A6?= =?UTF-8?q?=E7=90=86=E4=B8=AD=E3=81=AB=E4=B8=8A=E8=A8=98widget=E3=82=92?= =?UTF-8?q?=E8=A7=A6=E3=82=8C=E3=82=8B=E3=81=A8UI=E3=81=B8=E3=81=AE?= =?UTF-8?q?=E5=A4=89=E6=9B=B4=E5=87=A6=E7=90=86=E9=A0=86=E3=81=8C=E6=84=8F?= =?UTF-8?q?=E5=9B=B3=E3=81=97=E3=81=9F=E9=A0=86=E7=95=AA=E3=81=A8=E5=A4=89?= =?UTF-8?q?=E3=82=8F=E3=81=A3=E3=81=A6=E3=81=97=E3=81=BE=E3=81=86=E3=81=9F?= =?UTF-8?q?=E3=82=81=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit その他リファクタリングあり。 --- controller.py | 3 ++ view.py | 22 ++++++++++ vrct_gui/_changeConfigWindowWidgetsStatus.py | 42 ++++++++++++++++++- .../_SettingBoxGenerator.py | 4 ++ vrct_gui/ui_managers/Themes/_darkTheme.py | 3 ++ vrct_gui/ui_managers/Themes/_lightTheme.py | 3 ++ vrct_gui/ui_utils/ui_utils.py | 11 ++++- 7 files changed, 84 insertions(+), 4 deletions(-) diff --git a/controller.py b/controller.py index d8f9efac..ade5dc0d 100644 --- a/controller.py +++ b/controller.py @@ -507,17 +507,20 @@ def callbackSetCtranslate2WeightType(value): print("callbackSetCtranslate2WeightType", value) config.WEIGHT_TYPE = str(value) view.updateSelectedCtranslate2WeightType(config.WEIGHT_TYPE) + view.setWidgetsStatus_changeWeightType_Pending() if model.checkCTranslatorCTranslate2ModelWeight(): config.IS_RESET_BUTTON_DISPLAYED_FOR_TRANSLATION = False def callback(): model.changeTranslatorCTranslate2Model() view.useTranslationFeatureProcess("Normal") + view.setWidgetsStatus_changeWeightType_Done() th_callback = Thread(target=callback) th_callback.daemon = True th_callback.start() else: config.IS_RESET_BUTTON_DISPLAYED_FOR_TRANSLATION = True view.useTranslationFeatureProcess("Restart") + view.setWidgetsStatus_changeWeightType_Done() view.showRestartButtonIfRequired() def callbackSetDeeplAuthkey(value): diff --git a/view.py b/view.py index 3ed71a23..fa748514 100644 --- a/view.py +++ b/view.py @@ -1038,6 +1038,28 @@ class View(): vrct_gui.config_window.setting_box_compact_mode_switch_box.configure(state="normal") + @staticmethod + def setWidgetsStatus_changeWeightType_Pending(): + vrct_gui.config_window.sb__switch_use_translation_feature.configure(state="disabled") + vrct_gui._changeConfigWindowWidgetsStatus( + status="disabled", + target_names=[ + "sb__switch_use_translation_feature", + "sb__optionmenu_ctranslate2_weight_type", + ] + ) + @staticmethod + def setWidgetsStatus_changeWeightType_Done(): + vrct_gui.config_window.sb__switch_use_translation_feature.configure(state="normal") + vrct_gui._changeConfigWindowWidgetsStatus( + status="normal", + target_names=[ + "sb__switch_use_translation_feature", + "sb__optionmenu_ctranslate2_weight_type", + ] + ) + + def updateSelectedCtranslate2WeightType(self, selected_weight_type:str): self.view_variable.VAR_CTRANSLATE2_WEIGHT_TYPE.set(self.getSelectableCtranslate2WeightTypeDict()[selected_weight_type]) diff --git a/vrct_gui/_changeConfigWindowWidgetsStatus.py b/vrct_gui/_changeConfigWindowWidgetsStatus.py index b9b0f9d8..02dddd42 100644 --- a/vrct_gui/_changeConfigWindowWidgetsStatus.py +++ b/vrct_gui/_changeConfigWindowWidgetsStatus.py @@ -10,37 +10,75 @@ def _changeConfigWindowWidgetsStatus(config_window, settings, view_variable, sta if target_widget.desc_widget is not None: target_widget.desc_widget.configure(text_color=settings.ctm.LABELS_TEXT_DISABLED_COLOR) + def normalLabelsWidgets(target_widget): + target_widget.label_widget.configure(text_color=settings.ctm.LABELS_TEXT_COLOR) + if target_widget.desc_widget is not None: + target_widget.desc_widget.configure(text_color=settings.ctm.LABELS_DESC_TEXT_COLOR) + + def disableOptionmenuWidget(target_widget): - disableLabelsWidgets(target_widget) target_widget.optionmenu_label_widget.configure(text_color=settings.ctm.LABELS_TEXT_DISABLED_COLOR) target_widget.optionmenu_img_widget.configure(image=CTkImage(settings.image_file.ARROW_LEFT_DISABLED.rotate(90), size=settings.uism.SB__OPTIONMENU_IMG_SIZE)) target_widget.optionmenu_box.unbindFunction() target_widget.optionmenu_box.configure(cursor="") + def normalOptionmenuWidget(target_widget): + target_widget.optionmenu_label_widget.configure(text_color=settings.ctm.LABELS_TEXT_COLOR) + target_widget.optionmenu_img_widget.configure(image=CTkImage(settings.image_file.ARROW_LEFT.rotate(90), size=settings.uism.SB__OPTIONMENU_IMG_SIZE)) + target_widget.optionmenu_box.bindFunction() + target_widget.optionmenu_box.configure(cursor="hand2") + for target_name in target_names: match target_name: case "sb__optionmenu_mic_host": if status == "disabled": target_widget = config_window.sb__widgets["sb__optionmenu_mic_host"] + disableLabelsWidgets(target_widget) disableOptionmenuWidget(target_widget) case "sb__optionmenu_mic_device": if status == "disabled": target_widget = config_window.sb__widgets["sb__optionmenu_mic_device"] + disableLabelsWidgets(target_widget) disableOptionmenuWidget(target_widget) case "sb__optionmenu_appearance_theme": if status == "disabled": target_widget = config_window.sb__widgets["sb__optionmenu_appearance_theme"] + disableLabelsWidgets(target_widget) disableOptionmenuWidget(target_widget) + case "sb__optionmenu_ctranslate2_weight_type": + target_widget = config_window.sb__widgets["sb__optionmenu_ctranslate2_weight_type"] + if status == "disabled": + disableOptionmenuWidget(target_widget) + elif status == "normal": + normalOptionmenuWidget(target_widget) + + + case "sb__switch_use_translation_feature": + target_widget = config_window.sb__widgets["sb__switch_use_translation_feature"] + if status == "disabled": + target_widget.switch_box.configure( + state="disabled", + fg_color=settings.ctm.SB__SWITCH_BOX_BG_DISABLED_COLOR, + progress_color=settings.ctm.SB__SWITCH_BOX_ACTIVE_BG_DISABLED_COLOR, + button_color=settings.ctm.SB__SWITCH_BOX_BUTTON_DISABLED_COLOR, + ) + elif status == "normal": + target_widget.switch_box.configure( + state="normal", + fg_color=settings.ctm.SB__SWITCH_BOX_BG_COLOR, + progress_color=settings.ctm.SB__SWITCH_BOX_ACTIVE_BG_COLOR, + button_color=settings.ctm.SB__SWITCH_BOX_BUTTON_COLOR, + ) case "sb__checkbox_enable_send_received_message_to_vrc": if status == "disabled": target_widget = config_window.sb__widgets["sb__checkbox_enable_send_received_message_to_vrc"] disableLabelsWidgets(target_widget) - config_window.sb__checkbox_enable_send_received_message_to_vrc.configure( + target_widget.checkbox.configure( state="disabled", border_color=settings.ctm.SB__CHECKBOX_BORDER_DISABLED_COLOR ) diff --git a/vrct_gui/config_window/widgets/createSideMenuAndSettingsBoxContainers/setting_box_containers/_SettingBoxGenerator.py b/vrct_gui/config_window/widgets/createSideMenuAndSettingsBoxContainers/setting_box_containers/_SettingBoxGenerator.py index 7d44a2bb..ade6913a 100644 --- a/vrct_gui/config_window/widgets/createSideMenuAndSettingsBoxContainers/setting_box_containers/_SettingBoxGenerator.py +++ b/vrct_gui/config_window/widgets/createSideMenuAndSettingsBoxContainers/setting_box_containers/_SettingBoxGenerator.py @@ -210,6 +210,8 @@ class _SettingBoxGenerator(): ) setattr(self.config_window, switch_attr_name, switch_widget) + self.config_window.sb__widgets[switch_attr_name].switch_box = switch_widget + switch_widget.grid(row=1, column=SETTING_BOX_COLUMN, sticky="e") return setting_box_frame @@ -245,6 +247,8 @@ class _SettingBoxGenerator(): ) setattr(self.config_window, checkbox_attr_name, checkbox_widget) + self.config_window.sb__widgets[checkbox_attr_name].checkbox = checkbox_widget + checkbox_widget.grid(row=1, column=SETTING_BOX_COLUMN, sticky="e") return setting_box_frame diff --git a/vrct_gui/ui_managers/Themes/_darkTheme.py b/vrct_gui/ui_managers/Themes/_darkTheme.py index 8442b6bb..46592b4f 100644 --- a/vrct_gui/ui_managers/Themes/_darkTheme.py +++ b/vrct_gui/ui_managers/Themes/_darkTheme.py @@ -216,8 +216,11 @@ def _darkTheme(base_color): SB__SLIDER_TOOLTIP_TEXT_COLOR = base_color.DARK_200_COLOR, SB__SWITCH_BOX_BG_COLOR = base_color.DARK_800_COLOR, + SB__SWITCH_BOX_BG_DISABLED_COLOR = base_color.DARK_900_COLOR, SB__SWITCH_BOX_ACTIVE_BG_COLOR = base_color.PRIMARY_500_COLOR, + SB__SWITCH_BOX_ACTIVE_BG_DISABLED_COLOR = base_color.PRIMARY_700_COLOR, SB__SWITCH_BOX_BUTTON_COLOR = base_color.DARK_400_COLOR, + SB__SWITCH_BOX_BUTTON_DISABLED_COLOR = base_color.DARK_700_COLOR, SB__SWITCH_BOX_BUTTON_HOVERED_COLOR = base_color.DARK_350_COLOR, SB__CHECKBOX_BORDER_COLOR = base_color.DARK_600_COLOR, diff --git a/vrct_gui/ui_managers/Themes/_lightTheme.py b/vrct_gui/ui_managers/Themes/_lightTheme.py index 8d2ff33b..08caeae1 100644 --- a/vrct_gui/ui_managers/Themes/_lightTheme.py +++ b/vrct_gui/ui_managers/Themes/_lightTheme.py @@ -209,8 +209,11 @@ def _lightTheme(base_color): SB__SLIDER_TOOLTIP_TEXT_COLOR = base_color.LIGHT_800_COLOR, SB__SWITCH_BOX_BG_COLOR = base_color.LIGHT_400_COLOR, + SB__SWITCH_BOX_BG_DISABLED_COLOR = base_color.LIGHT_200_COLOR, SB__SWITCH_BOX_ACTIVE_BG_COLOR = base_color.PRIMARY_300_COLOR, + SB__SWITCH_BOX_ACTIVE_BG_DISABLED_COLOR = base_color.PRIMARY_150_COLOR, SB__SWITCH_BOX_BUTTON_COLOR = base_color.LIGHT_300_COLOR, + SB__SWITCH_BOX_BUTTON_DISABLED_COLOR = base_color.LIGHT_150_COLOR, SB__SWITCH_BOX_BUTTON_HOVERED_COLOR = base_color.LIGHT_200_COLOR, SB__CHECKBOX_BORDER_COLOR = base_color.LIGHT_600_COLOR, diff --git a/vrct_gui/ui_utils/ui_utils.py b/vrct_gui/ui_utils/ui_utils.py index 3e6dcccf..ca75416b 100644 --- a/vrct_gui/ui_utils/ui_utils.py +++ b/vrct_gui/ui_utils/ui_utils.py @@ -205,10 +205,15 @@ def createLabelButton(parent_widget, label_button_bg_color, label_button_hovered bindButtonReleaseFunction([label_button_label_wrapper, label_button_box, label_button_label_widget], label_button_clicked_command) + def bindEventFromWidgets(): + bindButtonReleaseFunction([label_button_label_wrapper, label_button_box, label_button_label_widget], label_button_clicked_command) + bindEventFromWidgets() + def unbindEventFromWidgets(): unbindEnterLEaveButtonPressButtonReleaseFunction([label_button_label_wrapper, label_button_box, label_button_label_widget]) label_button_box.unbindFunction = unbindEventFromWidgets + label_button_box.bindFunction = bindEventFromWidgets return (label_button_box, label_button_label_widget) @@ -265,13 +270,15 @@ def createOptionMenuBox(parent_widget, optionmenu_bg_color, optionmenu_hovered_b bindButtonPressColor([optionmenu_label_wrapper, option_menu_box, optionmenu_label_widget, optionmenu_img_widget], optionmenu_clicked_bg_color, optionmenu_hovered_bg_color) - - bindButtonReleaseFunction([optionmenu_label_wrapper, option_menu_box, optionmenu_label_widget, optionmenu_img_widget], optionmenu_clicked_command) + def bindEventFromWidgets(): + bindButtonReleaseFunction([optionmenu_label_wrapper, option_menu_box, optionmenu_label_widget, optionmenu_img_widget], optionmenu_clicked_command) + bindEventFromWidgets() def unbindEventFromWidgets(): unbindEnterLEaveButtonPressButtonReleaseFunction([optionmenu_label_wrapper, option_menu_box, optionmenu_label_widget, optionmenu_img_widget]) option_menu_box.unbindFunction = unbindEventFromWidgets + option_menu_box.bindFunction = bindEventFromWidgets return (option_menu_box, optionmenu_label_widget, optionmenu_img_widget)