[WIP/TEST] Controller : Resetボタンの表示タイミングを修正

This commit is contained in:
misyaguziya
2024-01-20 14:19:14 +09:00
parent f48581dcd8
commit 3fc3ae02bb
3 changed files with 20 additions and 4 deletions

View File

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

View File

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

View File

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