[Update] Config Window: showRestartButton関数の調整。前回の設定と同じで、再起動が必要なければ再起動ボタンを表示しないように。選択中の言語での表示も対応。

This commit is contained in:
Sakamoto Shiina
2023-10-16 20:49:39 +09:00
parent 29b30bba92
commit 6714833b0f
2 changed files with 31 additions and 6 deletions

View File

@@ -340,26 +340,26 @@ def callbackSetTransparency(value):
def callbackSetAppearance(value):
print("callbackSetAppearance", value)
config.APPEARANCE_THEME = value
view.showRestartButton()
view.showRestartButtonIfRequired()
def callbackSetUiScaling(value):
print("callbackSetUiScaling", value)
config.UI_SCALING = value
new_scaling_float = int(value.replace("%", "")) / 100
print("callbackSetUiScaling_new_scaling_float", new_scaling_float)
view.showRestartButton()
view.showRestartButtonIfRequired()
def callbackSetFontFamily(value):
print("callbackSetFontFamily", value)
config.FONT_FAMILY = value
view.showRestartButton()
view.showRestartButtonIfRequired()
def callbackSetUiLanguage(value):
print("callbackSetUiLanguage", value)
value = get_key_by_value(selectable_languages, value)
print("callbackSetUiLanguage__after_get_key_by_value", value)
config.UI_LANGUAGE = value
view.showRestartButton(locale=config.UI_LANGUAGE)
view.showRestartButtonIfRequired(locale=config.UI_LANGUAGE)
# Transcription Tab (Mic)
def callbackSetMicHost(value):

29
view.py
View File

@@ -30,6 +30,14 @@ class View():
i18n.set("locale", config.UI_LANGUAGE)
self.restart_required_configs_pre_data = SimpleNamespace(
appearance_theme=config.APPEARANCE_THEME,
ui_scaling=config.UI_SCALING,
font_family=config.FONT_FAMILY,
ui_language=config.UI_LANGUAGE,
)
common_args = {
"image_file": image_file,
"FONT_FAMILY": config.FONT_FAMILY,
@@ -698,10 +706,27 @@ class View():
# Config Window
def showRestartButton(self, locale:Union[None,str]=None):
def showRestartButtonIfRequired(self, locale:Union[None,str]=None):
is_restart_required = not (
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
)
if locale is None:
locale = config.UI_LANGUAGE
if is_restart_required is True:
self._showRestartButton(locale)
else:
self._hideRestartButton()
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()
def hideRestartButton(self):
def _hideRestartButton(self):
vrct_gui.config_window.restart_button_container.grid_remove()
def _updateActiveSettingBoxTabNo(self, active_setting_box_tab_attr_name:str):