From 6364fdba236699ea46f0d0a6f440bcee76e24712 Mon Sep 17 00:00:00 2001 From: lx-s Date: Thu, 11 Jan 2024 08:49:23 +0100 Subject: [PATCH] Added help-link to language selection --- Translations/lang-en.json | 1 + WinMute/Settings_GeneralDlg.cpp | 21 +++++++++++++++++++++ WinMute/WinMute.rc | 2 ++ WinMute/resource.h | 3 ++- 4 files changed, 26 insertions(+), 1 deletion(-) diff --git a/Translations/lang-en.json b/Translations/lang-en.json index 4c9da9c..d01d974 100644 --- a/Translations/lang-en.json +++ b/Translations/lang-en.json @@ -75,6 +75,7 @@ "settings.general.enable-logging": "Enable logging", "settings.general.btn-open-log-file": "Open log file...", "settings.general.select-language-label": "Language", + "settings.general.help-translating": "Help translating", "settings.bluetooth.add-edit.enter-device-name-placeholder": "Please enter a Bluetooth device name", "settings.bluetooth.description": "\"Bluetooth Muting\" allows disabling the audio if an audio-class bluetooth device is disconnected, and re-enables it if a device is reconnected to the computer.\n\nThis behaviour can be enabled for all bluetooth audio-devices or only for a specific set.", "settings.bluetooth.enable-muting": "Enable Bluetooth-based muting", diff --git a/WinMute/Settings_GeneralDlg.cpp b/WinMute/Settings_GeneralDlg.cpp index 32c77ad..91b63ec 100644 --- a/WinMute/Settings_GeneralDlg.cpp +++ b/WinMute/Settings_GeneralDlg.cpp @@ -62,6 +62,12 @@ static void FillLanguageList(HWND hLanguageList, const SettingsGeneralData& dlgD static void LoadSettingsGeneralDlgTranslation(HWND hDlg) { WMi18n &i18n = WMi18n::GetInstance(); + + const auto helpTranslateLink = std::vformat( + L"{}", + std::make_wformat_args(i18n.GetTranslationW("settings.general.help-translating"))); + + SetDlgItemText(hDlg, IDC_LINK_HELP_TRANSLATING, helpTranslateLink.c_str()); i18n.SetItemText(hDlg, IDC_SELECT_LANGUAGE_LABEL, "settings.general.select-language-label"); i18n.SetItemText(hDlg, IDC_RUNONSTARTUP, "settings.general.run-on-startup"); i18n.SetItemText(hDlg, IDC_CHECK_FOR_UPDATES_ON_STARTUP, "settings.general.check-for-updates-on-start"); @@ -143,6 +149,21 @@ INT_PTR CALLBACK Settings_GeneralDlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPA } return FALSE; } + case WM_NOTIFY: { + const PNMLINK pNmLink = reinterpret_cast(lParam); +#pragma warning(push) +#pragma warning(disable : 26454) // Disable arithmetic overflow warning for NM_CLICK and NM_RETURN + if (pNmLink->hdr.code == NM_CLICK || + pNmLink->hdr.code == NM_RETURN) { +#pragma warning(pop) + const UINT_PTR ctrlId = pNmLink->hdr.idFrom; + const LITEM item = pNmLink->item; + if ((ctrlId == IDC_LINK_HELP_TRANSLATING) && item.iLink == 0) { + LaunchBrowser(hDlg, item.szUrl); + } + } + return TRUE; + } case WM_COMMAND: { if (LOWORD(wParam) == IDC_ENABLELOGGING) { DWORD checked = Button_GetCheck(GetDlgItem(hDlg, IDC_ENABLELOGGING)); diff --git a/WinMute/WinMute.rc b/WinMute/WinMute.rc index a62c1e1..7ef43a9 100644 --- a/WinMute/WinMute.rc +++ b/WinMute/WinMute.rc @@ -90,6 +90,8 @@ BEGIN CONTROL "Enable logging",IDC_ENABLELOGGING,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,102,219,15 PUSHBUTTON "Open log file...",IDC_OPENLOG,22,118,104,16 LTEXT "[log file path]",IDC_LOGFILEPATH,23,138,203,27 + CONTROL "Help translating",IDC_LINK_HELP_TRANSLATING, + "SysLink",WS_TABSTOP,143,15,83,14 END IDD_SETTINGS_QUIETHOURS DIALOGEX 0, 0, 246, 198 diff --git a/WinMute/resource.h b/WinMute/resource.h index 1731915..a616167 100644 --- a/WinMute/resource.h +++ b/WinMute/resource.h @@ -112,6 +112,7 @@ #define IDC_RADIO1 1071 #define IDC_UPDATES_VIA_PACKAGE_MANAGER_NOTICE 1072 #define IDC_UPDATE_OPTIONS_DISABLED 1072 +#define IDC_LINK_HELP_TRANSLATING 1073 #define ID_TRAYMENU_INFO 40001 #define ID_TRAYMENU_ 40002 #define ID_TRAYMENU_MUTEON 40003 @@ -159,7 +160,7 @@ #ifndef APSTUDIO_READONLY_SYMBOLS #define _APS_NEXT_RESOURCE_VALUE 142 #define _APS_NEXT_COMMAND_VALUE 40041 -#define _APS_NEXT_CONTROL_VALUE 1073 +#define _APS_NEXT_CONTROL_VALUE 1074 #define _APS_NEXT_SYMED_VALUE 101 #endif #endif -- 2.43.0