[Update/bugfix] Config Window: DeepL Auth Key. DeepLアカウントページを開けるボタンを追加。

メイン画面翻訳エンジン選択のボタンを押した時の処理が2回走っていたのを修正。
This commit is contained in:
Sakamoto Shiina
2024-02-14 23:00:54 +09:00
parent 98c838352b
commit 9e12d43fe0
12 changed files with 147 additions and 12 deletions

View File

@@ -66,6 +66,10 @@ class Config:
def DOCUMENTS_URL(self): def DOCUMENTS_URL(self):
return self._DOCUMENTS_URL return self._DOCUMENTS_URL
@property
def DEEPL_AUTH_KEY_PAGE_URL(self):
return self._DEEPL_AUTH_KEY_PAGE_URL
@property @property
def TRANSPARENCY_RANGE(self): def TRANSPARENCY_RANGE(self):
return self._TRANSPARENCY_RANGE return self._TRANSPARENCY_RANGE
@@ -819,6 +823,7 @@ class Config:
self._GITHUB_URL = "https://api.github.com/repos/misyaguziya/VRCT/releases/latest" self._GITHUB_URL = "https://api.github.com/repos/misyaguziya/VRCT/releases/latest"
self._BOOTH_URL = "https://misyaguziya.booth.pm/" self._BOOTH_URL = "https://misyaguziya.booth.pm/"
self._DOCUMENTS_URL = "https://mzsoftware.notion.site/VRCT-Documents-be79b7a165f64442ad8f326d86c22246" 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._TRANSPARENCY_RANGE = (50, 100)
self._APPEARANCE_THEME_LIST = ["Light", "Dark", "System"] self._APPEARANCE_THEME_LIST = ["Light", "Dark", "System"]
self._UI_SCALING_LIST = generatePercentageStringsList(start=40, end=200, step=10) self._UI_SCALING_LIST = generatePercentageStringsList(start=40, end=200, step=10)

BIN
img/link_icon_black.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 361 B

BIN
img/link_icon_white.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 373 B

View File

@@ -129,6 +129,7 @@ config_window:
deepl_auth_key: deepl_auth_key:
label: 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. 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: mic_host:
label: Mic Host/Driver label: Mic Host/Driver

View File

@@ -128,6 +128,7 @@ config_window:
deepl_auth_key: deepl_auth_key:
label: DeepL 認証キー label: DeepL 認証キー
desc: "使用の際は、メイン画面にある %{translator} をDeepL_APIに変更してください。\n※対応していない言語もあります。" desc: "使用の際は、メイン画面にある %{translator} をDeepL_APIに変更してください。\n※対応していない言語もあります。"
open_auth_key_webpage: DeepLアカウントページを開く
mic_host: mic_host:
label: マイク(ホスト/ドライバー) label: マイク(ホスト/ドライバー)

View File

@@ -103,6 +103,7 @@ class View():
CALLBACK_UPDATE_SOFTWARE=None, CALLBACK_UPDATE_SOFTWARE=None,
CALLBACK_OPEN_FILEPATH_LOGS=None, CALLBACK_OPEN_FILEPATH_LOGS=None,
CALLBACK_OPEN_FILEPATH_CONFIG_FILE=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_DELETE_MAIN_WINDOW=self.quitVRCT,
CALLBACK_QUIT_VRCT=None, CALLBACK_QUIT_VRCT=None,
@@ -295,6 +296,7 @@ class View():
), ),
CALLBACK_SET_DEEPL_AUTH_KEY=None, CALLBACK_SET_DEEPL_AUTH_KEY=None,
VAR_DEEPL_AUTH_KEY=StringVar(value=config.AUTH_KEYS["DeepL_API"]), 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) # Transcription Tab (Mic)
@@ -978,6 +980,10 @@ class View():
self.openWebPage(config.DOCUMENTS_URL) self.openWebPage(config.DOCUMENTS_URL)
self._printToTextbox_Info(i18n.t("main_window.textbox_system_message.opened_web_page_vrct_documents")) 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 # Widget Control
# Common # Common

View File

@@ -5,7 +5,7 @@ from typing import Union
from customtkinter import CTkFont, CTkFrame, CTkLabel, CTkEntry, CTkSlider, CTkSwitch, CTkCheckBox, CTkProgressBar, CTkImage, CTkRadioButton from customtkinter import CTkFont, CTkFrame, CTkLabel, CTkEntry, CTkSlider, CTkSwitch, CTkCheckBox, CTkProgressBar, CTkImage, CTkRadioButton
from CTkToolTip import * 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 vrct_gui import vrct_gui
from utils import isEven, callFunctionIfCallable from utils import isEven, callFunctionIfCallable
@@ -615,6 +615,75 @@ class _SettingBoxGenerator():
return setting_box_frame 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("<Any-KeyRelease>", 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("<FocusOut>", 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

View File

@@ -6,7 +6,7 @@ def createSettingBox_Translation(setting_box_wrapper, config_window, settings, v
sbg = _SettingBoxGenerator(setting_box_wrapper, config_window, settings, view_variable) sbg = _SettingBoxGenerator(setting_box_wrapper, config_window, settings, view_variable)
createSettingBoxSwitch = sbg.createSettingBoxSwitch createSettingBoxSwitch = sbg.createSettingBoxSwitch
createSettingBoxDropdownMenu = sbg.createSettingBoxDropdownMenu createSettingBoxDropdownMenu = sbg.createSettingBoxDropdownMenu
createSettingBoxEntry = sbg.createSettingBoxEntry createSettingBoxEntry_AuthKey = sbg.createSettingBoxEntry_AuthKey
def switchUseTranslationFeatureCallback(switch_widget): def switchUseTranslationFeatureCallback(switch_widget):
callFunctionIfCallable(view_variable.CALLBACK_SET_USE_TRANSLATION_FEATURE, switch_widget.get()) 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 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_label_text=view_variable.VAR_LABEL_DEEPL_AUTH_KEY,
for_var_desc_text=view_variable.VAR_DESC_DEEPL_AUTH_KEY, for_var_desc_text=view_variable.VAR_DESC_DEEPL_AUTH_KEY,
entry_attr_name="sb__entry_deepl_auth_key", entry_attr_name="sb__entry_deepl_auth_key",
entry_width=settings.uism.RESPONSIVE_UI_SIZE_INT_300, entry_width=settings.uism.RESPONSIVE_UI_SIZE_INT_300,
entry_bind__Any_KeyRelease=lambda value: deeplAuthKeyCallback(value), entry_bind__Any_KeyRelease=lambda value: deeplAuthKeyCallback(value),
entry_textvariable=view_variable.VAR_DEEPL_AUTH_KEY, 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) config_window.sb__deepl_auth_key.grid(row=row, pady=0)
row+=1 row+=1

View File

@@ -330,6 +330,7 @@ def _darkTheme(base_color):
REDO_ICON = getImageFileFromUiUtils("redo_icon_white.png"), REDO_ICON = getImageFileFromUiUtils("redo_icon_white.png"),
SWAP_ICON = getImageFileFromUiUtils("swap_icon_white.png"), SWAP_ICON = getImageFileFromUiUtils("swap_icon_white.png"),
FOLDER_OPEN_ICON = getImageFileFromUiUtils("folder_open_icon_white.png"), FOLDER_OPEN_ICON = getImageFileFromUiUtils("folder_open_icon_white.png"),
LINK_ICON = getImageFileFromUiUtils("link_icon_white.png"),
), ),
) )

View File

@@ -324,6 +324,7 @@ def _lightTheme(base_color):
REDO_ICON = getImageFileFromUiUtils("redo_icon_black.png"), REDO_ICON = getImageFileFromUiUtils("redo_icon_black.png"),
SWAP_ICON = getImageFileFromUiUtils("swap_icon_black.png"), SWAP_ICON = getImageFileFromUiUtils("swap_icon_black.png"),
FOLDER_OPEN_ICON = getImageFileFromUiUtils("folder_open_icon_black.png"), FOLDER_OPEN_ICON = getImageFileFromUiUtils("folder_open_icon_black.png"),
LINK_ICON = getImageFileFromUiUtils("link_icon_black.png"),
), ),
) )

View File

@@ -349,6 +349,13 @@ class UiScalingManager():
self.config_window.SB__MESSAGE_FORMAT__ENTRIES_BOTTOM_PADY = (0, self._calculateUiSize(14)) 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_IPADXY = self._calculateUiSize(16)
self.config_window.SB__BUTTON_ICON_SIZE = self._calculateUiSize(24) self.config_window.SB__BUTTON_ICON_SIZE = self._calculateUiSize(24)

View File

@@ -168,7 +168,27 @@ def createButtonWithImage(parent_widget, button_image_size, button_ipadxy, butto
return button_wrapper 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") 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_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 = 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 LABEL_COLUMN=0
if label_button_position == "center": 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)) 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) register_widgets = [label_button_label_wrapper, label_button_box, label_button_label_widget]
bindButtonPressColor([label_button_label_wrapper, label_button_box, label_button_label_widget], label_button_clicked_bg_color, label_button_hovered_bg_color) 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(): def bindEventFromWidgets():
bindButtonReleaseFunction([label_button_label_wrapper, label_button_box, label_button_label_widget], label_button_clicked_command) bindButtonReleaseFunction(register_widgets, label_button_clicked_command)
bindEventFromWidgets()
def unbindEventFromWidgets(): 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.unbindFunction = unbindEventFromWidgets
label_button_box.bindFunction = bindEventFromWidgets 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)