From 2df43c10c9474ee631a69321f75f179744b821e1 Mon Sep 17 00:00:00 2001 From: lx-s Date: Sat, 9 Dec 2023 20:37:06 +0100 Subject: [PATCH] Translated Manage Endpoints Dialog --- Translations/wm_de/resource.h | 4 ++ Translations/wm_de/wm_de.rc | Bin 24766 -> 25416 bytes WinMute/Settings_ManageEndpointsDlg.cpp | 73 +++++++++++++++++------- WinMute/WinMute.rc | 13 +++-- WinMute/resource.h | 7 ++- 5 files changed, 70 insertions(+), 27 deletions(-) diff --git a/Translations/wm_de/resource.h b/Translations/wm_de/resource.h index 9e13f24..43789a1 100644 --- a/Translations/wm_de/resource.h +++ b/Translations/wm_de/resource.h @@ -91,6 +91,10 @@ #define IDS_SETTINGS_MUTE_MANAGE_ENDPOINTS_MUTE_ONLY_LISTED 1252 #define IDS_SETTINGS_MUTE_MANAGE_ENDPOINTS_MUTE_ALL_BUT_LISTED 1253 #define IDS_SETTINGS_MUTE_MANAGE_ENDPOINTS_ENDPOINTS_TITLE 1254 +#define IDS_SETTINGS_MANAGE_ENDPOINTS_ADD_TITLE 1260 +#define IDS_SETTINGS_MANAGE_ENDPOINTS_EDIT_TITLE 1261 +#define IDS_SETTINGS_MANAGE_ENDPOINTS_ADD_ENDPOINT_NAME_TEXT 1262 +#define IDS_SETTINGS_MANAGE_ENDPOINTS_ADD_ENDPOINT_NAME_LABEL 1263 #define IDS_SETTINGS_QUIETHOURS_INTRO 1300 #define IDS_SETTINGS_QUIETHOURS_ENABLE 1301 #define IDS_SETTINGS_QUIETHOURS_START_TIME_LABEL 1302 diff --git a/Translations/wm_de/wm_de.rc b/Translations/wm_de/wm_de.rc index 02cfa56a6ab2cb0bd029a7c9634db939c6c86544..c58cbba2bd0b93919e7a68cf545a2965fb2530f9 100644 GIT binary patch delta 184 zcmdmYknzMZ#tkj8lQ|qzCZ|OyusSlhFt|*Pj+JE1XUJs8o6M-|I5{OsiQN?_?#U2> zBr_2rBM#QV5YOPs;0II_z~B#5=Lb|7X`INK3N~YZj5xOfLn1>SLpnn$L(=3#PhF6i lICV1WNej9HRi`i%Fo0dbP{Lp}c_N$WWIlGO&1+(Xm;rhXEbIUP delta 22 ecmX?cjB(#V#tkj8lV`B;P3B{l+H95}#0&s%k_Z3* diff --git a/WinMute/Settings_ManageEndpointsDlg.cpp b/WinMute/Settings_ManageEndpointsDlg.cpp index a2a8519..72f7b2e 100644 --- a/WinMute/Settings_ManageEndpointsDlg.cpp +++ b/WinMute/Settings_ManageEndpointsDlg.cpp @@ -101,6 +101,23 @@ static bool GetAudioEndpoints(std::vector& endpoints) return true; } +static void LoadManageEndpointsAddDlgTranslation(HWND hDlg, bool isEdit) +{ + WMi18n &i18n = WMi18n::GetInstance(); + if (isEdit) { + i18n.SetItemText(hDlg, IDS_SETTINGS_MANAGE_ENDPOINTS_EDIT_TITLE); + } else { + i18n.SetItemText(hDlg, IDS_SETTINGS_MANAGE_ENDPOINTS_ADD_TITLE); + } + i18n.SetItemText(hDlg, IDC_ENDPOINT_NAME_LABEL, IDS_SETTINGS_BLUETOOTH_ADD_DLG_DEVICE_NAME_LABEL); + i18n.SetItemText(hDlg, IDOK, IDS_SETTINGS_BTN_SAVE); + i18n.SetItemText(hDlg, IDCANCEL, IDS_SETTINGS_BTN_CANCEL); + + ComboBox_SetCueBannerText( + GetDlgItem(hDlg, IDC_ENDPOINT_NAME), + i18n.GetTextW(IDS_SETTINGS_MANAGE_ENDPOINTS_ADD_ENDPOINT_NAME_TEXT).c_str()); +} + static INT_PTR CALLBACK Settings_EndpointAddDlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam) { switch (msg) { @@ -113,19 +130,15 @@ static INT_PTR CALLBACK Settings_EndpointAddDlgProc(HWND hDlg, UINT msg, WPARAM } SetWindowLongPtr(hDlg, GWLP_USERDATA, reinterpret_cast(endpointData)); - if (endpointData->name.length() == 0) { - if (!SetWindowTextW(hDlg, L"Add endpoint")) { - PrintWindowsError(L"SetWindowText", GetLastError()); - return FALSE; - } - } else { - if (!SetWindowTextW(hDlg, L"Edit endpoint") || - !SetWindowTextW(GetDlgItem(hDlg, IDC_ENDPOINT_NAME), - endpointData->name.c_str())) { - PrintWindowsError(L"SetWindowText", GetLastError()); - return FALSE; - } + LoadManageEndpointsAddDlgTranslation(hDlg, endpointData->name.length() != 0); + if (endpointData->name.length() != 0) { + SetWindowTextW(GetDlgItem(hDlg, IDC_ENDPOINT_NAME), + endpointData->name.c_str()); } + + // Disable save button until at least one string change is made + EnableWindow(GetDlgItem(hDlg, IDOK), FALSE); + // Fill Combobox std::vector audioEndpoints; if (GetAudioEndpoints(audioEndpoints)) { @@ -142,18 +155,14 @@ static INT_PTR CALLBACK Settings_EndpointAddDlgProc(HWND hDlg, UINT msg, WPARAM return TRUE; } case WM_COMMAND: - if (LOWORD(wParam) == IDOK) { + if (LOWORD(wParam) == IDC_ENDPOINT_NAME && HIWORD(wParam) == CBN_EDITUPDATE) { + HWND hDevName = GetDlgItem(hDlg, IDC_ENDPOINT_NAME); + const int textLen = Edit_GetTextLength(hDevName); + EnableWindow(GetDlgItem(hDlg, IDOK), textLen > 0); + } else if (LOWORD(wParam) == IDOK) { HWND hEpName = GetDlgItem(hDlg, IDC_ENDPOINT_NAME); const int textLen = Edit_GetTextLength(hEpName); - if (textLen == 0) { - EDITBALLOONTIP ebt; - ZeroMemory(&ebt, sizeof(ebt)); - ebt.cbStruct = sizeof(ebt); - ebt.pszText = L"Please enter a endpoint name"; - ebt.pszTitle = L"Endpoint Name"; - ebt.ttiIcon = TTI_INFO; - Edit_ShowBalloonTip(hEpName, &ebt); - } else { + if (textLen != 0) { wchar_t epNameBuf[ENDPOINT_NAME_MAX_LEN + 1] = { 'L\0' }; EndpointData *epData = reinterpret_cast(GetWindowLongPtr(hDlg, GWLP_USERDATA)); if (epData != nullptr) { @@ -192,6 +201,24 @@ static std::vector ExportEndpointNameList(HWND hList) return items; } +static void LoadManageEndpointsDlgTranslation(HWND hDlg) +{ + WMi18n &i18n = WMi18n::GetInstance(); + + SetWindowText(hDlg, i18n.GetTextW(IDS_SETTINGS_MUTE_MANAGE_ENDPOINTS_TITLE).c_str()); + i18n.SetItemText(hDlg, IDC_GROUP_LIST_BEHAVIOUR, IDS_SETTINGS_MUTE_MANAGE_ENDPOINTS_LIST_BEHAVIOUR_TITLE); + i18n.SetItemText(hDlg, IDC_ENDPOINT_LIST_IS_ALLOWLIST, IDS_SETTINGS_MUTE_MANAGE_ENDPOINTS_MUTE_ONLY_LISTED); + i18n.SetItemText(hDlg, IDC_ENDPOINT_LIST_IS_BLOCKLIST, IDS_SETTINGS_MUTE_MANAGE_ENDPOINTS_MUTE_ALL_BUT_LISTED); + i18n.SetItemText(hDlg, IDC_GROUP_ENDPOINTS, IDS_SETTINGS_MUTE_MANAGE_ENDPOINTS_ENDPOINTS_TITLE); + + i18n.SetItemText(hDlg, IDC_ENDPOINT_ADD, IDS_SETTINGS_BTN_ADD); + i18n.SetItemText(hDlg, IDC_ENDPOINT_EDIT, IDS_SETTINGS_BTN_EDIT); + i18n.SetItemText(hDlg, IDC_ENDPOINT_REMOVE, IDS_SETTINGS_BTN_REMOVE); + i18n.SetItemText(hDlg, IDC_ENDPOINT_REMOVEALL, IDS_SETTINGS_BTN_REMOVE_ALL); + i18n.SetItemText(hDlg, IDOK, IDS_SETTINGS_BTN_SAVE); + i18n.SetItemText(hDlg, IDCANCEL, IDS_SETTINGS_BTN_CANCEL); +} + INT_PTR CALLBACK Settings_ManageEndpointsDlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam) { switch (msg) { @@ -200,6 +227,8 @@ INT_PTR CALLBACK Settings_ManageEndpointsDlgProc(HWND hDlg, UINT msg, WPARAM wPa if (IsAppThemed()) { EnableThemeDialogTexture(hDlg, ETDT_ENABLETAB); } + LoadManageEndpointsDlgTranslation(hDlg); + WMSettings *settings = reinterpret_cast(lParam); assert(settings != nullptr); SetWindowLongPtr(hDlg, GWLP_USERDATA, reinterpret_cast(settings)); diff --git a/WinMute/WinMute.rc b/WinMute/WinMute.rc index ea8ead7..d7bb9bf 100644 --- a/WinMute/WinMute.rc +++ b/WinMute/WinMute.rc @@ -212,7 +212,7 @@ STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSM CAPTION "Manage Endpoints" FONT 8, "MS Shell Dlg", 400, 0, 0x1 BEGIN - DEFPUSHBUTTON "OK",IDOK,133,179,50,14 + DEFPUSHBUTTON "Save",IDOK,133,179,50,14 PUSHBUTTON "Cancel",IDCANCEL,184,179,50,14 LISTBOX IDC_ENDPOINT_LIST,13,60,159,110,LBS_SORT | LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_TABSTOP PUSHBUTTON "Add",IDC_ENDPOINT_ADD,175,60,56,16 @@ -220,9 +220,9 @@ BEGIN PUSHBUTTON "Remove",IDC_ENDPOINT_REMOVE,175,97,56,16 PUSHBUTTON "Remove all",IDC_ENDPOINT_REMOVEALL,175,120,56,16 CONTROL "Mute only listed endpoints",IDC_ENDPOINT_LIST_IS_ALLOWLIST, - "Button",BS_AUTORADIOBUTTON,13,19,99,10 + "Button",BS_AUTORADIOBUTTON,13,19,209,10 CONTROL "Mute all but the listed endpoints",IDC_ENDPOINT_LIST_IS_BLOCKLIST, - "Button",BS_AUTORADIOBUTTON,13,32,118,10 + "Button",BS_AUTORADIOBUTTON,13,32,207,10 GROUPBOX "List behaviour",IDC_GROUP_LIST_BEHAVIOUR,7,7,227,41 GROUPBOX "Endpoints",IDC_GROUP_ENDPOINTS,7,48,227,128 END @@ -234,7 +234,7 @@ FONT 8, "MS Shell Dlg", 400, 0, 0x1 BEGIN DEFPUSHBUTTON "Save",IDOK,91,41,50,14 PUSHBUTTON "Cancel",IDCANCEL,144,41,50,14 - LTEXT "Endpoint name:",IDC_STATIC,7,7,187,14 + LTEXT "Endpoint name:",IDC_ENDPOINT_NAME_LABEL,7,7,187,14 COMBOBOX IDC_ENDPOINT_NAME,7,22,187,17,CBS_DROPDOWN | CBS_SORT | WS_VSCROLL | WS_TABSTOP END @@ -753,6 +753,11 @@ BEGIN IDS_SETTINGS_MUTE_MANAGE_ENDPOINTS_MUTE_ALL_BUT_LISTED "Mute all but listed endpoints" IDS_SETTINGS_MUTE_MANAGE_ENDPOINTS_ENDPOINTS_TITLE "Endpoints" + IDS_SETTINGS_MANAGE_ENDPOINTS_ADD_TITLE "Add Endpoint" + IDS_SETTINGS_MANAGE_ENDPOINTS_EDIT_TITLE "Edit Endpoint" + IDS_SETTINGS_MANAGE_ENDPOINTS_ADD_ENDPOINT_NAME_TEXT + "Please enter a endpoint name" + IDS_SETTINGS_MANAGE_ENDPOINTS_ADD_ENDPOINT_NAME_LABEL "Endpoint name:" END #endif // English (United Kingdom) resources diff --git a/WinMute/resource.h b/WinMute/resource.h index 0dedabf..7fb7188 100644 --- a/WinMute/resource.h +++ b/WinMute/resource.h @@ -163,6 +163,7 @@ #define IDC_WIFI_NAME_LABEL 1064 #define IDC_GROUP_LIST_BEHAVIOUR 1066 #define IDC_GROUP_ENDPOINTS 1067 +#define IDC_ENDPOINT_NAME_LABEL 1068 #define IDS_SETTINGS_BLUETOOTH_ADD_DLG_TITLE 1101 #define IDS_SETTINGS_BLUETOOTH_EDIT_DLG_TITLE 1102 #define IDS_SETTINGS_BLUETOOTH_ADD_DLG_DEVICE_NAME_LABEL 1103 @@ -190,6 +191,10 @@ #define IDS_SETTINGS_MUTE_MANAGE_ENDPOINTS_MUTE_ONLY_LISTED 1252 #define IDS_SETTINGS_MUTE_MANAGE_ENDPOINTS_MUTE_ALL_BUT_LISTED 1253 #define IDS_SETTINGS_MUTE_MANAGE_ENDPOINTS_ENDPOINTS_TITLE 1254 +#define IDS_SETTINGS_MANAGE_ENDPOINTS_ADD_TITLE 1260 +#define IDS_SETTINGS_MANAGE_ENDPOINTS_EDIT_TITLE 1261 +#define IDS_SETTINGS_MANAGE_ENDPOINTS_ADD_ENDPOINT_NAME_TEXT 1262 +#define IDS_SETTINGS_MANAGE_ENDPOINTS_ADD_ENDPOINT_NAME_LABEL 1263 #define IDS_SETTINGS_QUIETHOURS_INTRO 1300 #define IDS_SETTINGS_QUIETHOURS_ENABLE 1301 #define IDS_SETTINGS_QUIETHOURS_START_TIME_LABEL 1302 @@ -260,7 +265,7 @@ #ifndef APSTUDIO_READONLY_SYMBOLS #define _APS_NEXT_RESOURCE_VALUE 141 #define _APS_NEXT_COMMAND_VALUE 40041 -#define _APS_NEXT_CONTROL_VALUE 1068 +#define _APS_NEXT_CONTROL_VALUE 1069 #define _APS_NEXT_SYMED_VALUE 101 #endif #endif -- 2.43.0