[Update/Refactor] Main Window: Use translation feature ON/OFF時のwidget調整。

Translation Each Other表示は、翻訳機能使わない場合は必要のない情報なので、その時はSwap Language表示に固定。
This commit is contained in:
Sakamoto Shiina
2024-01-22 18:20:10 +09:00
parent 6ed71f1a4a
commit 46aafa4a4d
5 changed files with 41 additions and 24 deletions

View File

@@ -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

View File

@@ -6,7 +6,7 @@ main_window:
language_settings: 言語設定
your_language: あなたの言語
both_direction_desc: 双方向に翻訳
translate_each_other_label: 双方向に翻訳
swap_button_label: 言語を入れ替え
target_language: 相手の言語
translator: 翻訳エンジン

View File

@@ -6,7 +6,7 @@ main_window:
language_settings: 언어 설정
your_language: 당신의 언어
both_direction_desc: 양방향으로 번역
translate_each_other_label: 양방향으로 번역
swap_button_label: 언어 교체
target_language: 상대방의 언어

47
view.py
View File

@@ -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("%",""))

View File

@@ -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=[