From 6714833b0fbaf94aa94c0d38d04a93824a20939a Mon Sep 17 00:00:00 2001 From: Sakamoto Shiina <68018796+ShiinaSakamoto@users.noreply.github.com> Date: Mon, 16 Oct 2023 20:49:39 +0900 Subject: [PATCH] =?UTF-8?q?[Update]=20Config=20Window:=20showRestartButton?= =?UTF-8?q?=E9=96=A2=E6=95=B0=E3=81=AE=E8=AA=BF=E6=95=B4=E3=80=82=E5=89=8D?= =?UTF-8?q?=E5=9B=9E=E3=81=AE=E8=A8=AD=E5=AE=9A=E3=81=A8=E5=90=8C=E3=81=98?= =?UTF-8?q?=E3=81=A7=E3=80=81=E5=86=8D=E8=B5=B7=E5=8B=95=E3=81=8C=E5=BF=85?= =?UTF-8?q?=E8=A6=81=E3=81=AA=E3=81=91=E3=82=8C=E3=81=B0=E5=86=8D=E8=B5=B7?= =?UTF-8?q?=E5=8B=95=E3=83=9C=E3=82=BF=E3=83=B3=E3=82=92=E8=A1=A8=E7=A4=BA?= =?UTF-8?q?=E3=81=97=E3=81=AA=E3=81=84=E3=82=88=E3=81=86=E3=81=AB=E3=80=82?= =?UTF-8?q?=E9=81=B8=E6=8A=9E=E4=B8=AD=E3=81=AE=E8=A8=80=E8=AA=9E=E3=81=A7?= =?UTF-8?q?=E3=81=AE=E8=A1=A8=E7=A4=BA=E3=82=82=E5=AF=BE=E5=BF=9C=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- controller.py | 8 ++++---- view.py | 29 +++++++++++++++++++++++++++-- 2 files changed, 31 insertions(+), 6 deletions(-) diff --git a/controller.py b/controller.py index a53bdc0f..bc0f0f68 100644 --- a/controller.py +++ b/controller.py @@ -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): diff --git a/view.py b/view.py index 27b38138..29b0c046 100644 --- a/view.py +++ b/view.py @@ -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):