[bugfix/refactor] weightタイプ変更処理中は、weightタイプ変更と翻訳機能オンオフwidgetをdisabledに。
理由: weightタイプ変更処理は非同期で、変更処理中に上記widgetを触れるとUIへの変更処理順が意図した順番と変わってしまうため。 その他リファクタリングあり。
This commit is contained in:
@@ -507,17 +507,20 @@ def callbackSetCtranslate2WeightType(value):
|
|||||||
print("callbackSetCtranslate2WeightType", value)
|
print("callbackSetCtranslate2WeightType", value)
|
||||||
config.WEIGHT_TYPE = str(value)
|
config.WEIGHT_TYPE = str(value)
|
||||||
view.updateSelectedCtranslate2WeightType(config.WEIGHT_TYPE)
|
view.updateSelectedCtranslate2WeightType(config.WEIGHT_TYPE)
|
||||||
|
view.setWidgetsStatus_changeWeightType_Pending()
|
||||||
if model.checkCTranslatorCTranslate2ModelWeight():
|
if model.checkCTranslatorCTranslate2ModelWeight():
|
||||||
config.IS_RESET_BUTTON_DISPLAYED_FOR_TRANSLATION = False
|
config.IS_RESET_BUTTON_DISPLAYED_FOR_TRANSLATION = False
|
||||||
def callback():
|
def callback():
|
||||||
model.changeTranslatorCTranslate2Model()
|
model.changeTranslatorCTranslate2Model()
|
||||||
view.useTranslationFeatureProcess("Normal")
|
view.useTranslationFeatureProcess("Normal")
|
||||||
|
view.setWidgetsStatus_changeWeightType_Done()
|
||||||
th_callback = Thread(target=callback)
|
th_callback = Thread(target=callback)
|
||||||
th_callback.daemon = True
|
th_callback.daemon = True
|
||||||
th_callback.start()
|
th_callback.start()
|
||||||
else:
|
else:
|
||||||
config.IS_RESET_BUTTON_DISPLAYED_FOR_TRANSLATION = True
|
config.IS_RESET_BUTTON_DISPLAYED_FOR_TRANSLATION = True
|
||||||
view.useTranslationFeatureProcess("Restart")
|
view.useTranslationFeatureProcess("Restart")
|
||||||
|
view.setWidgetsStatus_changeWeightType_Done()
|
||||||
view.showRestartButtonIfRequired()
|
view.showRestartButtonIfRequired()
|
||||||
|
|
||||||
def callbackSetDeeplAuthkey(value):
|
def callbackSetDeeplAuthkey(value):
|
||||||
|
|||||||
22
view.py
22
view.py
@@ -1038,6 +1038,28 @@ class View():
|
|||||||
vrct_gui.config_window.setting_box_compact_mode_switch_box.configure(state="normal")
|
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):
|
def updateSelectedCtranslate2WeightType(self, selected_weight_type:str):
|
||||||
self.view_variable.VAR_CTRANSLATE2_WEIGHT_TYPE.set(self.getSelectableCtranslate2WeightTypeDict()[selected_weight_type])
|
self.view_variable.VAR_CTRANSLATE2_WEIGHT_TYPE.set(self.getSelectableCtranslate2WeightTypeDict()[selected_weight_type])
|
||||||
|
|
||||||
|
|||||||
@@ -10,37 +10,75 @@ def _changeConfigWindowWidgetsStatus(config_window, settings, view_variable, sta
|
|||||||
if target_widget.desc_widget is not None:
|
if target_widget.desc_widget is not None:
|
||||||
target_widget.desc_widget.configure(text_color=settings.ctm.LABELS_TEXT_DISABLED_COLOR)
|
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):
|
def disableOptionmenuWidget(target_widget):
|
||||||
disableLabelsWidgets(target_widget)
|
|
||||||
target_widget.optionmenu_label_widget.configure(text_color=settings.ctm.LABELS_TEXT_DISABLED_COLOR)
|
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_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.unbindFunction()
|
||||||
target_widget.optionmenu_box.configure(cursor="")
|
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:
|
for target_name in target_names:
|
||||||
match target_name:
|
match target_name:
|
||||||
case "sb__optionmenu_mic_host":
|
case "sb__optionmenu_mic_host":
|
||||||
if status == "disabled":
|
if status == "disabled":
|
||||||
target_widget = config_window.sb__widgets["sb__optionmenu_mic_host"]
|
target_widget = config_window.sb__widgets["sb__optionmenu_mic_host"]
|
||||||
|
disableLabelsWidgets(target_widget)
|
||||||
disableOptionmenuWidget(target_widget)
|
disableOptionmenuWidget(target_widget)
|
||||||
|
|
||||||
case "sb__optionmenu_mic_device":
|
case "sb__optionmenu_mic_device":
|
||||||
if status == "disabled":
|
if status == "disabled":
|
||||||
target_widget = config_window.sb__widgets["sb__optionmenu_mic_device"]
|
target_widget = config_window.sb__widgets["sb__optionmenu_mic_device"]
|
||||||
|
disableLabelsWidgets(target_widget)
|
||||||
disableOptionmenuWidget(target_widget)
|
disableOptionmenuWidget(target_widget)
|
||||||
|
|
||||||
case "sb__optionmenu_appearance_theme":
|
case "sb__optionmenu_appearance_theme":
|
||||||
if status == "disabled":
|
if status == "disabled":
|
||||||
target_widget = config_window.sb__widgets["sb__optionmenu_appearance_theme"]
|
target_widget = config_window.sb__widgets["sb__optionmenu_appearance_theme"]
|
||||||
|
disableLabelsWidgets(target_widget)
|
||||||
disableOptionmenuWidget(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":
|
case "sb__checkbox_enable_send_received_message_to_vrc":
|
||||||
if status == "disabled":
|
if status == "disabled":
|
||||||
target_widget = config_window.sb__widgets["sb__checkbox_enable_send_received_message_to_vrc"]
|
target_widget = config_window.sb__widgets["sb__checkbox_enable_send_received_message_to_vrc"]
|
||||||
disableLabelsWidgets(target_widget)
|
disableLabelsWidgets(target_widget)
|
||||||
config_window.sb__checkbox_enable_send_received_message_to_vrc.configure(
|
target_widget.checkbox.configure(
|
||||||
state="disabled",
|
state="disabled",
|
||||||
border_color=settings.ctm.SB__CHECKBOX_BORDER_DISABLED_COLOR
|
border_color=settings.ctm.SB__CHECKBOX_BORDER_DISABLED_COLOR
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -210,6 +210,8 @@ class _SettingBoxGenerator():
|
|||||||
)
|
)
|
||||||
setattr(self.config_window, switch_attr_name, switch_widget)
|
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")
|
switch_widget.grid(row=1, column=SETTING_BOX_COLUMN, sticky="e")
|
||||||
|
|
||||||
return setting_box_frame
|
return setting_box_frame
|
||||||
@@ -245,6 +247,8 @@ class _SettingBoxGenerator():
|
|||||||
)
|
)
|
||||||
setattr(self.config_window, checkbox_attr_name, checkbox_widget)
|
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")
|
checkbox_widget.grid(row=1, column=SETTING_BOX_COLUMN, sticky="e")
|
||||||
|
|
||||||
return setting_box_frame
|
return setting_box_frame
|
||||||
|
|||||||
@@ -216,8 +216,11 @@ def _darkTheme(base_color):
|
|||||||
SB__SLIDER_TOOLTIP_TEXT_COLOR = base_color.DARK_200_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_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_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_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__SWITCH_BOX_BUTTON_HOVERED_COLOR = base_color.DARK_350_COLOR,
|
||||||
|
|
||||||
SB__CHECKBOX_BORDER_COLOR = base_color.DARK_600_COLOR,
|
SB__CHECKBOX_BORDER_COLOR = base_color.DARK_600_COLOR,
|
||||||
|
|||||||
@@ -209,8 +209,11 @@ def _lightTheme(base_color):
|
|||||||
SB__SLIDER_TOOLTIP_TEXT_COLOR = base_color.LIGHT_800_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_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_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_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__SWITCH_BOX_BUTTON_HOVERED_COLOR = base_color.LIGHT_200_COLOR,
|
||||||
|
|
||||||
SB__CHECKBOX_BORDER_COLOR = base_color.LIGHT_600_COLOR,
|
SB__CHECKBOX_BORDER_COLOR = base_color.LIGHT_600_COLOR,
|
||||||
|
|||||||
@@ -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)
|
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():
|
def unbindEventFromWidgets():
|
||||||
unbindEnterLEaveButtonPressButtonReleaseFunction([label_button_label_wrapper, label_button_box, label_button_label_widget])
|
unbindEnterLEaveButtonPressButtonReleaseFunction([label_button_label_wrapper, label_button_box, label_button_label_widget])
|
||||||
|
|
||||||
label_button_box.unbindFunction = unbindEventFromWidgets
|
label_button_box.unbindFunction = unbindEventFromWidgets
|
||||||
|
label_button_box.bindFunction = bindEventFromWidgets
|
||||||
|
|
||||||
|
|
||||||
return (label_button_box, label_button_label_widget)
|
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)
|
bindButtonPressColor([optionmenu_label_wrapper, option_menu_box, optionmenu_label_widget, optionmenu_img_widget], optionmenu_clicked_bg_color, optionmenu_hovered_bg_color)
|
||||||
|
|
||||||
|
|
||||||
|
def bindEventFromWidgets():
|
||||||
bindButtonReleaseFunction([optionmenu_label_wrapper, option_menu_box, optionmenu_label_widget, optionmenu_img_widget], optionmenu_clicked_command)
|
bindButtonReleaseFunction([optionmenu_label_wrapper, option_menu_box, optionmenu_label_widget, optionmenu_img_widget], optionmenu_clicked_command)
|
||||||
|
bindEventFromWidgets()
|
||||||
|
|
||||||
def unbindEventFromWidgets():
|
def unbindEventFromWidgets():
|
||||||
unbindEnterLEaveButtonPressButtonReleaseFunction([optionmenu_label_wrapper, option_menu_box, optionmenu_label_widget, optionmenu_img_widget])
|
unbindEnterLEaveButtonPressButtonReleaseFunction([optionmenu_label_wrapper, option_menu_box, optionmenu_label_widget, optionmenu_img_widget])
|
||||||
|
|
||||||
option_menu_box.unbindFunction = unbindEventFromWidgets
|
option_menu_box.unbindFunction = unbindEventFromWidgets
|
||||||
|
option_menu_box.bindFunction = bindEventFromWidgets
|
||||||
|
|
||||||
|
|
||||||
return (option_menu_box, optionmenu_label_widget, optionmenu_img_widget)
|
return (option_menu_box, optionmenu_label_widget, optionmenu_img_widget)
|
||||||
|
|||||||
Reference in New Issue
Block a user