From 9e12d43fe0eee4a02bd4645f4cb23e89da9e5b3a Mon Sep 17 00:00:00 2001 From: Sakamoto Shiina <68018796+ShiinaSakamoto@users.noreply.github.com> Date: Wed, 14 Feb 2024 23:00:54 +0900 Subject: [PATCH] =?UTF-8?q?[Update/bugfix]=20Config=20Window:=20DeepL=20Au?= =?UTF-8?q?th=20Key.=20DeepL=E3=82=A2=E3=82=AB=E3=82=A6=E3=83=B3=E3=83=88?= =?UTF-8?q?=E3=83=9A=E3=83=BC=E3=82=B8=E3=82=92=E9=96=8B=E3=81=91=E3=82=8B?= =?UTF-8?q?=E3=83=9C=E3=82=BF=E3=83=B3=E3=82=92=E8=BF=BD=E5=8A=A0=E3=80=82?= =?UTF-8?q?=20=E3=83=A1=E3=82=A4=E3=83=B3=E7=94=BB=E9=9D=A2=E7=BF=BB?= =?UTF-8?q?=E8=A8=B3=E3=82=A8=E3=83=B3=E3=82=B8=E3=83=B3=E9=81=B8=E6=8A=9E?= =?UTF-8?q?=E3=81=AE=E3=83=9C=E3=82=BF=E3=83=B3=E3=82=92=E6=8A=BC=E3=81=97?= =?UTF-8?q?=E3=81=9F=E6=99=82=E3=81=AE=E5=87=A6=E7=90=86=E3=81=8C2?= =?UTF-8?q?=E5=9B=9E=E8=B5=B0=E3=81=A3=E3=81=A6=E3=81=84=E3=81=9F=E3=81=AE?= =?UTF-8?q?=E3=82=92=E4=BF=AE=E6=AD=A3=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config.py | 5 ++ img/link_icon_black.png | Bin 0 -> 361 bytes img/link_icon_white.png | Bin 0 -> 373 bytes locales/en.yml | 1 + locales/ja.yml | 1 + view.py | 6 ++ .../_SettingBoxGenerator.py | 71 +++++++++++++++++- .../createSettingBox_Translation.py | 7 +- vrct_gui/ui_managers/Themes/_darkTheme.py | 1 + vrct_gui/ui_managers/Themes/_lightTheme.py | 1 + vrct_gui/ui_managers/UiScalingManager.py | 7 ++ vrct_gui/ui_utils/ui_utils.py | 59 ++++++++++++--- 12 files changed, 147 insertions(+), 12 deletions(-) create mode 100644 img/link_icon_black.png create mode 100644 img/link_icon_white.png diff --git a/config.py b/config.py index d565bfe8..aba44f08 100644 --- a/config.py +++ b/config.py @@ -66,6 +66,10 @@ class Config: def DOCUMENTS_URL(self): return self._DOCUMENTS_URL + @property + def DEEPL_AUTH_KEY_PAGE_URL(self): + return self._DEEPL_AUTH_KEY_PAGE_URL + @property def TRANSPARENCY_RANGE(self): return self._TRANSPARENCY_RANGE @@ -819,6 +823,7 @@ class Config: self._GITHUB_URL = "https://api.github.com/repos/misyaguziya/VRCT/releases/latest" self._BOOTH_URL = "https://misyaguziya.booth.pm/" self._DOCUMENTS_URL = "https://mzsoftware.notion.site/VRCT-Documents-be79b7a165f64442ad8f326d86c22246" + self._DEEPL_AUTH_KEY_PAGE_URL = "https://www.deepl.com/ja/account/summary" self._TRANSPARENCY_RANGE = (50, 100) self._APPEARANCE_THEME_LIST = ["Light", "Dark", "System"] self._UI_SCALING_LIST = generatePercentageStringsList(start=40, end=200, step=10) diff --git a/img/link_icon_black.png b/img/link_icon_black.png new file mode 100644 index 0000000000000000000000000000000000000000..e4790914bca8b01599137d70c50a2efc3c694b5e GIT binary patch literal 361 zcmeAS@N?(olHy`uVBq!ia0vp^1|ZDA1|-9oezpTC&H|6fVg?4jBOuH;Rhv(mfq_xl z)5S3)8s4_BKw~a{P0dL|c1t-t+TanF(C$r&Rqa7X8iB z_N;F6!L|PnWv~5Sdw)LzS4INgy*T~+`q<+>ZPIcIkJ+XjNY~yVV&~l`@Z$}O)5Fa| z5zO;@4@CXYVM%&$lQrpKBx}$CW}kaUmLB|lwsB8m$mH*eq8_~dS`Cc;Y7?0Dv&s8wOoSSZ6U@*#t1uIaK>tAx#L7#?X|j7&B-SbO7orr-lM w0meKA6slpr_>Xm$uheS?Fa5!$a_1+5x`^R|erJXnVAwHuy85}Sb4q9e044;CWdHyG literal 0 HcmV?d00001 diff --git a/img/link_icon_white.png b/img/link_icon_white.png new file mode 100644 index 0000000000000000000000000000000000000000..58a56d45a6794bc717b5b91fcffe8eed8f85a80e GIT binary patch literal 373 zcmV-*0gC>KP)RA}Dqne7dNFc5~1;tUSq7EB-!&?(%8B_Kd_0=IAn-J#T9 zH3l@Hw0GCWzCTMyo~JJ#M*xW7O~MV(w1cuaUvLZ9hP?rkbp3TJrMv;aPOk;izy$uT z*Av@o&@`vx!MOD)e42_(%JBgZKm%QWnZcJu{?x}eHakNDKmLRV@VJ2`@ZJh6h4)gx z1l~IVQ+Tfg*1&rsuom760ULOB0b6)h0T=K9A8+E&;PvD{-hiu}*C7>f4Noe70Z%62 z0={Vn_3hgQT>xw6bx@x|bNDnXi@h^=0K^6;;L!xA;L!w>f+Gbynm|?NwGiTr4G(~L z6IW$kV}k3jkJC|r8z2gB14IFCfGEHX5Cymaq5wC*-wV9QY3jd~t`d9$G2D3pFk0zq Tc+A-900000NkvXXu0mjfrRkJD literal 0 HcmV?d00001 diff --git a/locales/en.yml b/locales/en.yml index e8c3f925..1904261a 100644 --- a/locales/en.yml +++ b/locales/en.yml @@ -129,6 +129,7 @@ config_window: deepl_auth_key: label: DeepL Auth Key desc: Please select %{translator} on the main screen with DeepL_API when using. ※Some languages may not be supported. + open_auth_key_webpage: Open DeepL Account Webpage mic_host: label: Mic Host/Driver diff --git a/locales/ja.yml b/locales/ja.yml index 121a287b..2befc4bd 100644 --- a/locales/ja.yml +++ b/locales/ja.yml @@ -128,6 +128,7 @@ config_window: deepl_auth_key: label: DeepL 認証キー desc: "使用の際は、メイン画面にある %{translator} をDeepL_APIに変更してください。\n※対応していない言語もあります。" + open_auth_key_webpage: DeepLアカウントページを開く mic_host: label: マイク(ホスト/ドライバー) diff --git a/view.py b/view.py index c792824e..e7962850 100644 --- a/view.py +++ b/view.py @@ -103,6 +103,7 @@ class View(): CALLBACK_UPDATE_SOFTWARE=None, CALLBACK_OPEN_FILEPATH_LOGS=None, CALLBACK_OPEN_FILEPATH_CONFIG_FILE=None, + CALLBACK_OPEN_WEBPAGE_DEEPL_AUTH_KEY=self.openWebPage_DeepL_Auth_Key, CALLBACK_DELETE_MAIN_WINDOW=self.quitVRCT, CALLBACK_QUIT_VRCT=None, @@ -295,6 +296,7 @@ class View(): ), CALLBACK_SET_DEEPL_AUTH_KEY=None, VAR_DEEPL_AUTH_KEY=StringVar(value=config.AUTH_KEYS["DeepL_API"]), + VAR_OPEN_DEEPL_WEB_PAGE=StringVar(value=i18n.t( "config_window.deepl_auth_key.open_auth_key_webpage")), # Transcription Tab (Mic) @@ -978,6 +980,10 @@ class View(): self.openWebPage(config.DOCUMENTS_URL) self._printToTextbox_Info(i18n.t("main_window.textbox_system_message.opened_web_page_vrct_documents")) + def openWebPage_DeepL_Auth_Key(self): + self.openWebPage(config.DEEPL_AUTH_KEY_PAGE_URL) + + # Widget Control # Common diff --git a/vrct_gui/config_window/widgets/createSideMenuAndSettingsBoxContainers/setting_box_containers/_SettingBoxGenerator.py b/vrct_gui/config_window/widgets/createSideMenuAndSettingsBoxContainers/setting_box_containers/_SettingBoxGenerator.py index ade6913a..60386162 100644 --- a/vrct_gui/config_window/widgets/createSideMenuAndSettingsBoxContainers/setting_box_containers/_SettingBoxGenerator.py +++ b/vrct_gui/config_window/widgets/createSideMenuAndSettingsBoxContainers/setting_box_containers/_SettingBoxGenerator.py @@ -5,7 +5,7 @@ from typing import Union from customtkinter import CTkFont, CTkFrame, CTkLabel, CTkEntry, CTkSlider, CTkSwitch, CTkCheckBox, CTkProgressBar, CTkImage, CTkRadioButton from CTkToolTip import * -from vrct_gui.ui_utils import createButtonWithImage, getLatestWidth, createOptionMenuBox, getLatestHeight, bindButtonFunctionAndColor, bindEnterAndLeaveFunction, bindButtonReleaseFunction, bindButtonPressFunction +from vrct_gui.ui_utils import createButtonWithImage, getLatestWidth, createOptionMenuBox, getLatestHeight, bindButtonFunctionAndColor, bindEnterAndLeaveFunction, bindButtonReleaseFunction, bindButtonPressFunction, createLabelButton from vrct_gui import vrct_gui from utils import isEven, callFunctionIfCallable @@ -615,6 +615,75 @@ class _SettingBoxGenerator(): return setting_box_frame + def createSettingBoxEntry_AuthKey(self, + for_var_label_text, for_var_desc_text, + entry_attr_name, + entry_width, + entry_textvariable, + entry_bind__Any_KeyRelease, + entry_bind__FocusOut=None, + open_authkey_page_command=None, + open_authkey_text_variable=None, + image_file=None, + ): + + (setting_box_frame, setting_box_item_frame) = self._createSettingBoxFrame(entry_attr_name, for_var_label_text, for_var_desc_text) + + + all_wrapper = CTkFrame(setting_box_item_frame, corner_radius=0, fg_color=self.settings.ctm.SB__BG_COLOR, width=0, height=0) + all_wrapper.grid(row=1, column=0, sticky="ew") + + all_wrapper.grid_columnconfigure(0, weight=1) + + + def adjusted_command__for_entry_bind__Any_KeyRelease(e): + entry_bind__Any_KeyRelease(e.widget.get()) + + entry_widget = CTkEntry( + all_wrapper, + text_color=self.settings.ctm.SB__ENTRY_TEXT_COLOR, + fg_color=self.settings.ctm.SB__ENTRY_BG_COLOR, + border_color=self.settings.ctm.SB__ENTRY_BORDER_COLOR, + width=entry_width, + height=self.settings.uism.SB__PROGRESSBAR_X_SLIDER__ENTRY_HEIGHT, + textvariable=entry_textvariable, + font=CTkFont(family=self.settings.FONT_FAMILY, size=self.settings.uism.SB__ENTRY_FONT_SIZE, weight="normal"), + ) + entry_widget.bind("", adjusted_command__for_entry_bind__Any_KeyRelease) + setattr(self.config_window, entry_attr_name, entry_widget) + + + entry_widget.grid(row=0, column=SETTING_BOX_COLUMN, sticky="e") + + if entry_bind__FocusOut is not None: + entry_widget.bind("", entry_bind__FocusOut, "+") + + + + (open_page_button, label_button_label_widget, label_button_img_widget) = createLabelButton( + parent_widget=all_wrapper, + label_button_bg_color=self.settings.ctm.SB__BUTTON_COLOR, + label_button_hovered_bg_color=self.settings.ctm.SB__BUTTON_HOVERED_COLOR, + label_button_clicked_bg_color=self.settings.ctm.SB__BUTTON_CLICKED_COLOR, + label_button_ipadx=self.settings.uism.SB__AUTHKEY_WEBPAGE_BUTTON_IPADX, + label_button_ipady=self.settings.uism.SB__AUTHKEY_WEBPAGE_BUTTON_IPADY, + variable=open_authkey_text_variable, + font_family=self.settings.FONT_FAMILY, + font_size=self.settings.uism.SB__AUTHKEY_WEBPAGE_BUTTON_LABEL_FONT_SIZE, + text_color=self.settings.ctm.LABELS_TEXT_COLOR, + label_button_clicked_command=open_authkey_page_command, + + label_button_position="center", + + image_file=image_file, + image_size=self.settings.uism.SB__AUTHKEY_WEBPAGE_BUTTON_IMG_SIZE, + label_button_padx_between_img=self.settings.uism.SB__AUTHKEY_WEBPAGE_PADX_BETWEEN_LABEL_AND_ICON, + ) + open_page_button.grid(row=1, column=SETTING_BOX_COLUMN, pady=(self.settings.uism.SB__AUTHKEY_WEBPAGE_BUTTON_TOP_PADY,0)) + + + return setting_box_frame + diff --git a/vrct_gui/config_window/widgets/createSideMenuAndSettingsBoxContainers/setting_box_containers/setting_box_translation/createSettingBox_Translation.py b/vrct_gui/config_window/widgets/createSideMenuAndSettingsBoxContainers/setting_box_containers/setting_box_translation/createSettingBox_Translation.py index f245c387..7e3a9ba5 100644 --- a/vrct_gui/config_window/widgets/createSideMenuAndSettingsBoxContainers/setting_box_containers/setting_box_translation/createSettingBox_Translation.py +++ b/vrct_gui/config_window/widgets/createSideMenuAndSettingsBoxContainers/setting_box_containers/setting_box_translation/createSettingBox_Translation.py @@ -6,7 +6,7 @@ def createSettingBox_Translation(setting_box_wrapper, config_window, settings, v sbg = _SettingBoxGenerator(setting_box_wrapper, config_window, settings, view_variable) createSettingBoxSwitch = sbg.createSettingBoxSwitch createSettingBoxDropdownMenu = sbg.createSettingBoxDropdownMenu - createSettingBoxEntry = sbg.createSettingBoxEntry + createSettingBoxEntry_AuthKey = sbg.createSettingBoxEntry_AuthKey def switchUseTranslationFeatureCallback(switch_widget): callFunctionIfCallable(view_variable.CALLBACK_SET_USE_TRANSLATION_FEATURE, switch_widget.get()) @@ -41,13 +41,16 @@ def createSettingBox_Translation(setting_box_wrapper, config_window, settings, v row+=1 - config_window.sb__deepl_auth_key = createSettingBoxEntry( + config_window.sb__deepl_auth_key = createSettingBoxEntry_AuthKey( for_var_label_text=view_variable.VAR_LABEL_DEEPL_AUTH_KEY, for_var_desc_text=view_variable.VAR_DESC_DEEPL_AUTH_KEY, entry_attr_name="sb__entry_deepl_auth_key", entry_width=settings.uism.RESPONSIVE_UI_SIZE_INT_300, entry_bind__Any_KeyRelease=lambda value: deeplAuthKeyCallback(value), entry_textvariable=view_variable.VAR_DEEPL_AUTH_KEY, + open_authkey_page_command=lambda _e: callFunctionIfCallable(view_variable.CALLBACK_OPEN_WEBPAGE_DEEPL_AUTH_KEY), + open_authkey_text_variable=view_variable.VAR_OPEN_DEEPL_WEB_PAGE, + image_file=settings.image_file.LINK_ICON ) config_window.sb__deepl_auth_key.grid(row=row, pady=0) row+=1 \ No newline at end of file diff --git a/vrct_gui/ui_managers/Themes/_darkTheme.py b/vrct_gui/ui_managers/Themes/_darkTheme.py index 46592b4f..1b5fc339 100644 --- a/vrct_gui/ui_managers/Themes/_darkTheme.py +++ b/vrct_gui/ui_managers/Themes/_darkTheme.py @@ -330,6 +330,7 @@ def _darkTheme(base_color): REDO_ICON = getImageFileFromUiUtils("redo_icon_white.png"), SWAP_ICON = getImageFileFromUiUtils("swap_icon_white.png"), FOLDER_OPEN_ICON = getImageFileFromUiUtils("folder_open_icon_white.png"), + LINK_ICON = getImageFileFromUiUtils("link_icon_white.png"), ), ) diff --git a/vrct_gui/ui_managers/Themes/_lightTheme.py b/vrct_gui/ui_managers/Themes/_lightTheme.py index 08caeae1..d953372c 100644 --- a/vrct_gui/ui_managers/Themes/_lightTheme.py +++ b/vrct_gui/ui_managers/Themes/_lightTheme.py @@ -324,6 +324,7 @@ def _lightTheme(base_color): REDO_ICON = getImageFileFromUiUtils("redo_icon_black.png"), SWAP_ICON = getImageFileFromUiUtils("swap_icon_black.png"), FOLDER_OPEN_ICON = getImageFileFromUiUtils("folder_open_icon_black.png"), + LINK_ICON = getImageFileFromUiUtils("link_icon_black.png"), ), ) diff --git a/vrct_gui/ui_managers/UiScalingManager.py b/vrct_gui/ui_managers/UiScalingManager.py index bbf7326d..85204af7 100644 --- a/vrct_gui/ui_managers/UiScalingManager.py +++ b/vrct_gui/ui_managers/UiScalingManager.py @@ -349,6 +349,13 @@ class UiScalingManager(): self.config_window.SB__MESSAGE_FORMAT__ENTRIES_BOTTOM_PADY = (0, self._calculateUiSize(14)) + self.config_window.SB__AUTHKEY_WEBPAGE_BUTTON_IPADX = self._calculateUiSize(12) + self.config_window.SB__AUTHKEY_WEBPAGE_BUTTON_IPADY = self._calculateUiSize(6) + self.config_window.SB__AUTHKEY_WEBPAGE_BUTTON_LABEL_FONT_SIZE = self._calculateUiSize(12) + self.config_window.SB__AUTHKEY_WEBPAGE_BUTTON_IMG_SIZE = self.dupTuple(self._calculateUiSize(12)) + self.config_window.SB__AUTHKEY_WEBPAGE_PADX_BETWEEN_LABEL_AND_ICON = self._calculateUiSize(10) + self.config_window.SB__AUTHKEY_WEBPAGE_BUTTON_TOP_PADY = self._calculateUiSize(10) + self.config_window.SB__BUTTON_IPADXY = self._calculateUiSize(16) self.config_window.SB__BUTTON_ICON_SIZE = self._calculateUiSize(24) diff --git a/vrct_gui/ui_utils/ui_utils.py b/vrct_gui/ui_utils/ui_utils.py index ca75416b..94f9adae 100644 --- a/vrct_gui/ui_utils/ui_utils.py +++ b/vrct_gui/ui_utils/ui_utils.py @@ -168,7 +168,27 @@ def createButtonWithImage(parent_widget, button_image_size, button_ipadxy, butto return button_wrapper -def createLabelButton(parent_widget, label_button_bg_color, label_button_hovered_bg_color, label_button_clicked_bg_color, label_button_ipadx, label_button_ipady, variable, font_family, font_size, text_color, label_button_clicked_command, label_button_position=None, label_button_padx_between_img=0, label_button_min_height=None, label_button_min_width=None): +def createLabelButton( + parent_widget, + label_button_bg_color, + label_button_hovered_bg_color, + label_button_clicked_bg_color, + label_button_ipadx, + label_button_ipady, + variable, + font_family, + font_size, + text_color, + label_button_clicked_command, + label_button_position=None, + label_button_padx_between_img=0, + image_file=None, + image_size=None, + image_widget_attr_name=None, + label_button_min_height=None, + label_button_min_width=None, + setattr_widget=None, + ): label_button_box = CTkFrame(parent_widget, corner_radius=6, fg_color=label_button_bg_color, cursor="hand2") @@ -181,7 +201,7 @@ def createLabelButton(parent_widget, label_button_bg_color, label_button_hovered label_button_box.grid_columnconfigure(0, minsize=label_button_min_width) label_button_label_wrapper = CTkFrame(label_button_box, corner_radius=0, fg_color=label_button_bg_color) - label_button_label_wrapper.grid(row=0, column=0, padx=label_button_ipadx, pady=label_button_ipady, sticky="ew") + label_button_label_wrapper.grid(row=0, column=0, padx=label_button_ipadx, pady=label_button_ipady) LABEL_COLUMN=0 if label_button_position == "center": @@ -198,25 +218,46 @@ def createLabelButton(parent_widget, label_button_bg_color, label_button_hovered label_button_label_widget.grid(row=0, column=LABEL_COLUMN, padx=(0, label_button_padx_between_img)) - bindEnterAndLeaveColor([label_button_label_wrapper, label_button_box, label_button_label_widget], label_button_hovered_bg_color, label_button_bg_color) - bindButtonPressColor([label_button_label_wrapper, label_button_box, label_button_label_widget], label_button_clicked_bg_color, label_button_hovered_bg_color) + register_widgets = [label_button_label_wrapper, label_button_box, label_button_label_widget] + if image_file is not None: + label_button_label_wrapper.grid_columnconfigure((0,3), weight=1) + label_button_img_widget = CTkLabel( + label_button_label_wrapper, + text=None, + corner_radius=0, + height=0, + image=CTkImage(image_file, size=image_size) + ) + + if image_widget_attr_name is not None: + setattr(setattr_widget, image_widget_attr_name, label_button_img_widget) + + label_button_img_widget.grid(row=0, column=LABEL_COLUMN+1) + register_widgets.append(label_button_img_widget) + bindEnterAndLeaveColor(register_widgets, label_button_hovered_bg_color, label_button_bg_color) + bindButtonPressColor(register_widgets, label_button_clicked_bg_color, label_button_hovered_bg_color) + - 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() + bindButtonReleaseFunction(register_widgets, label_button_clicked_command) def unbindEventFromWidgets(): - unbindEnterLEaveButtonPressButtonReleaseFunction([label_button_label_wrapper, label_button_box, label_button_label_widget]) + unbindEnterLEaveButtonPressButtonReleaseFunction(register_widgets) + + bindEventFromWidgets() label_button_box.unbindFunction = unbindEventFromWidgets label_button_box.bindFunction = bindEventFromWidgets + if image_file is not None: + return (label_button_box, label_button_label_widget, label_button_img_widget) + else: + return (label_button_box, label_button_label_widget) + - return (label_button_box, label_button_label_widget)