Merge branch 'change_ctranslate2_model' into develop
This commit is contained in:
76
view.py
76
view.py
@@ -28,6 +28,7 @@ class View():
|
||||
ui_scaling=config.UI_SCALING,
|
||||
font_family=config.FONT_FAMILY,
|
||||
ui_language=config.UI_LANGUAGE,
|
||||
is_reset_button_displayed_for_translation=config.IS_RESET_BUTTON_DISPLAYED_FOR_TRANSLATION,
|
||||
)
|
||||
|
||||
if config.ENABLE_SPEAKER2CHATBOX is False:
|
||||
@@ -161,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})"),
|
||||
@@ -650,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":
|
||||
@@ -878,18 +882,38 @@ 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.config_window.after(200, vrct_gui.config_window.lift)
|
||||
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.config_window.after(200, vrct_gui.config_window.lift)
|
||||
changeWidget_DontUseTranslationFeature()
|
||||
|
||||
elif state == "Restart":
|
||||
view.setLatestCTranslate2WeightType()
|
||||
view.setTranslationSwitchStatus("disabled", to_lock_state=True)
|
||||
changeWidget_UseTranslationFeature()
|
||||
|
||||
vrct_gui.update()
|
||||
vrct_gui.config_window.lift()
|
||||
|
||||
|
||||
# Open Webpage Functions
|
||||
def openWebPage_Booth(self):
|
||||
@@ -984,7 +1008,8 @@ 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.is_reset_button_displayed_for_translation == config.IS_RESET_BUTTON_DISPLAYED_FOR_TRANSLATION
|
||||
)
|
||||
|
||||
if locale is None:
|
||||
@@ -1013,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])
|
||||
|
||||
@@ -1206,7 +1253,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()
|
||||
@@ -1264,6 +1311,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("%",""))
|
||||
|
||||
Reference in New Issue
Block a user