From 6e43ba6ea529126d5366295300caee8798777032 Mon Sep 17 00:00:00 2001 From: mere-human <9664141+mere-human@users.noreply.github.com> Date: Sun, 14 Feb 2021 17:00:33 +0200 Subject: [PATCH] Add an option to mute all sounds in preferences dialog Fix #7950, close #9507 --- PowerEditor/gcc/makefile | 2 +- PowerEditor/installer/nativeLang/english.xml | 1 + PowerEditor/src/Parameters.cpp | 5 +++++ PowerEditor/src/Parameters.h | 1 + .../src/ScintillaComponent/FindReplaceDlg.cpp | 3 ++- PowerEditor/src/WinControls/Grid/BabyGrid.cpp | 17 ++++++++++------- .../src/WinControls/Preference/preference.rc | 3 ++- .../WinControls/Preference/preferenceDlg.cpp | 7 +++++++ .../src/WinControls/Preference/preference_rc.h | 1 + PowerEditor/visual.net/notepadPlus.vcxproj | 8 ++++---- 10 files changed, 34 insertions(+), 14 deletions(-) diff --git a/PowerEditor/gcc/makefile b/PowerEditor/gcc/makefile index 4e937fb47..37ee5858d 100644 --- a/PowerEditor/gcc/makefile +++ b/PowerEditor/gcc/makefile @@ -251,7 +251,7 @@ CXX = $(CROSS_COMPILE)g++ CXXFLAGS = $(INCLUDESPECIAL) -DTIXML_USE_STL -DTIXMLA_USE_STL $(UNICODE) -std=c++17 -fpermissive INCLUDES = $(patsubst %,-I%,$(DIRS)) -I./include LDFLAGS = -Wl,--subsystem,windows -municode -mwindows -LIBS = -lcomdlg32 -lcomctl32 -lgdi32 -lole32 -loleacc -lshell32 -lshlwapi -ldbghelp -lversion -lcrypt32 -lsensapi -lwininet -lwintrust -lwinmm -luuid +LIBS = -lcomdlg32 -lcomctl32 -lgdi32 -lole32 -loleacc -lshell32 -lshlwapi -ldbghelp -lversion -lcrypt32 -lsensapi -lwininet -lwintrust -luuid RC = $(CROSS_COMPILE)windres diff --git a/PowerEditor/installer/nativeLang/english.xml b/PowerEditor/installer/nativeLang/english.xml index f3e75f90d..f547da32d 100644 --- a/PowerEditor/installer/nativeLang/english.xml +++ b/PowerEditor/installer/nativeLang/english.xml @@ -1052,6 +1052,7 @@ You can define several column markers by using white space to separate the diffe + diff --git a/PowerEditor/src/Parameters.cpp b/PowerEditor/src/Parameters.cpp index db832be6c..66c2f41e9 100644 --- a/PowerEditor/src/Parameters.cpp +++ b/PowerEditor/src/Parameters.cpp @@ -5280,6 +5280,10 @@ void NppParameters::feedGUIParameters(TiXmlNode *node) const TCHAR* saveDlgExtFilterToAllTypes = element->Attribute(TEXT("saveDlgExtFilterToAllTypes")); if (saveDlgExtFilterToAllTypes) _nppGUI._setSaveDlgExtFiltToAllTypes = (lstrcmp(saveDlgExtFilterToAllTypes, TEXT("yes")) == 0); + + const TCHAR * optMuteSounds = element->Attribute(TEXT("muteSounds")); + if (optMuteSounds) + _nppGUI._muteSounds = lstrcmp(optMuteSounds, TEXT("yes")) == 0; } else if (!lstrcmp(nm, TEXT("commandLineInterpreter"))) { @@ -6213,6 +6217,7 @@ void NppParameters::createXmlTreeFromGUIParams() GUIConfigElement->SetAttribute(TEXT("docPeekOnTab"), _nppGUI._isDocPeekOnTab ? TEXT("yes") : TEXT("no")); GUIConfigElement->SetAttribute(TEXT("docPeekOnMap"), _nppGUI._isDocPeekOnMap ? TEXT("yes") : TEXT("no")); GUIConfigElement->SetAttribute(TEXT("saveDlgExtFilterToAllTypes"), _nppGUI._setSaveDlgExtFiltToAllTypes ? TEXT("yes") : TEXT("no")); + GUIConfigElement->SetAttribute(TEXT("muteSounds"), _nppGUI._muteSounds ? TEXT("yes") : TEXT("no")); } // diff --git a/PowerEditor/src/Parameters.h b/PowerEditor/src/Parameters.h index 52a343175..3235278f0 100644 --- a/PowerEditor/src/Parameters.h +++ b/PowerEditor/src/Parameters.h @@ -838,6 +838,7 @@ struct NppGUI final bool _monospacedFontFindDlg = false; bool _findDlgAlwaysVisible = false; bool _confirmReplaceInAllOpenDocs = true; + bool _muteSounds = false; writeTechnologyEngine _writeTechnologyEngine = defaultTechnology; bool _isWordCharDefault = true; std::string _customWordChars; diff --git a/PowerEditor/src/ScintillaComponent/FindReplaceDlg.cpp b/PowerEditor/src/ScintillaComponent/FindReplaceDlg.cpp index 9eceb7685..4dd241b73 100644 --- a/PowerEditor/src/ScintillaComponent/FindReplaceDlg.cpp +++ b/PowerEditor/src/ScintillaComponent/FindReplaceDlg.cpp @@ -2805,7 +2805,8 @@ void FindReplaceDlg::setStatusbarMessage(const generic_string & msg, FindStatus { if (staus == FSNotFound) { - ::PlaySound((LPCTSTR)SND_ALIAS_SYSTEMASTERISK, NULL, SND_ALIAS_ID | SND_ASYNC); + if (!NppParameters::getInstance().getNppGUI()._muteSounds) + ::MessageBeep(0xFFFFFFFF); FLASHWINFO flashInfo; flashInfo.cbSize = sizeof(FLASHWINFO); diff --git a/PowerEditor/src/WinControls/Grid/BabyGrid.cpp b/PowerEditor/src/WinControls/Grid/BabyGrid.cpp index 3222da872..22ba94e4c 100644 --- a/PowerEditor/src/WinControls/Grid/BabyGrid.cpp +++ b/PowerEditor/src/WinControls/Grid/BabyGrid.cpp @@ -1191,9 +1191,10 @@ void DisplayEditString(HWND hWnd,int SI, const TCHAR* tstring) wcscat_s(BGHS[SI].editstringdisplay,BGHS[SI].editstring); } else - { - MessageBeep(0); - } + { + if (!NppParameters::getInstance().getNppGUI()._muteSounds) + MessageBeep(0); + } holdfont=(HFONT)SelectObject(cdc,BGHS[SI].hfont); rt.right -= 5; @@ -1400,7 +1401,8 @@ LRESULT CALLBACK GridProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) GetClientRect(hWnd, &rect); InvalidateRect(hWnd,&rect,TRUE); UpdateWindow(hWnd); - MessageBeep(0); + if (!NppParameters::getInstance().getNppGUI()._muteSounds) + MessageBeep(0); } break; @@ -1669,9 +1671,10 @@ LRESULT CALLBACK GridProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) FindResult = static_cast(SendMessage(BGHS[SelfIndex].hlist1, LB_ADDSTRING, 0, reinterpret_cast(buffer))); if(FindResult==LB_ERR) - { - MessageBeep(0); - } + { + if (!NppParameters::getInstance().getNppGUI()._muteSounds) + MessageBeep(0); + } { RECT rect; rect=GetCellRect(hWnd,SelfIndex,LPBGcell->row,LPBGcell->col); diff --git a/PowerEditor/src/WinControls/Preference/preference.rc b/PowerEditor/src/WinControls/Preference/preference.rc index c7fa7a8e1..794ff8dea 100644 --- a/PowerEditor/src/WinControls/Preference/preference.rc +++ b/PowerEditor/src/WinControls/Preference/preference.rc @@ -416,7 +416,8 @@ BEGIN CONTROL "Peek on document map",IDC_CHECK_ENABLEDOCPEEKONMAP,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,269,71,140,10 // "Enable Notepad++ auto-updater" should be always the 1st item, because it'll be hidden if GUP.exe is absent - CONTROL "Enable Notepad++ auto-updater",IDC_CHECK_AUTOUPDATE,"Button",BS_AUTOCHECKBOX | BS_MULTILINE | WS_TABSTOP,37,94,217,10 + CONTROL "Mute all sounds", IDC_CHECK_MUTE_SOUNDS, "Button", BS_AUTOCHECKBOX | BS_MULTILINE | WS_TABSTOP, 37, 94, 217, 10 + CONTROL "Enable Notepad++ auto-updater",IDC_CHECK_AUTOUPDATE,"Button",BS_AUTOCHECKBOX | BS_MULTILINE | WS_TABSTOP, 37, 78, 210, 10 CONTROL "Set Save dialog file extension filter to *.*",IDC_CHECK_SAVEDLGEXTFILTALLTYPES,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,37,109,267,10 CONTROL "Autodetect character encoding",IDC_CHECK_DETECTENCODING,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,37,124,217,10 CONTROL "Minimize to system tray",IDC_CHECK_MIN2SYSTRAY,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,37,139,217,10 diff --git a/PowerEditor/src/WinControls/Preference/preferenceDlg.cpp b/PowerEditor/src/WinControls/Preference/preferenceDlg.cpp index b64d64735..5bb0b96f3 100644 --- a/PowerEditor/src/WinControls/Preference/preferenceDlg.cpp +++ b/PowerEditor/src/WinControls/Preference/preferenceDlg.cpp @@ -981,6 +981,7 @@ INT_PTR CALLBACK MiscSubDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM) ::SendDlgItemMessage(_hSelf, IDC_CHECK_DIRECTWRITE_ENABLE, BM_SETCHECK, nppGUI._writeTechnologyEngine == directWriteTechnology, 0); ::SendDlgItemMessage(_hSelf, IDC_CHECK_ENABLEDOCPEEKER, BM_SETCHECK, nppGUI._isDocPeekOnTab ? BST_CHECKED : BST_UNCHECKED, 0); ::SendDlgItemMessage(_hSelf, IDC_CHECK_ENABLEDOCPEEKONMAP, BM_SETCHECK, nppGUI._isDocPeekOnMap ? BST_CHECKED : BST_UNCHECKED, 0); + ::SendDlgItemMessage(_hSelf, IDC_CHECK_MUTE_SOUNDS, BM_SETCHECK, nppGUI._muteSounds ? BST_CHECKED : BST_UNCHECKED, 0); ::ShowWindow(::GetDlgItem(_hSelf, IDC_CHECK_AUTOUPDATE), nppGUI._doesExistUpdater?SW_SHOW:SW_HIDE); @@ -1112,6 +1113,12 @@ INT_PTR CALLBACK MiscSubDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM) nppGUI._isDocPeekOnMap = isCheckedOrNot(IDC_CHECK_ENABLEDOCPEEKONMAP); return TRUE; } + + case IDC_CHECK_MUTE_SOUNDS: + { + nppGUI._muteSounds = isCheckedOrNot(IDC_CHECK_MUTE_SOUNDS); + return TRUE; + } default: { diff --git a/PowerEditor/src/WinControls/Preference/preference_rc.h b/PowerEditor/src/WinControls/Preference/preference_rc.h index b64cd0998..154309e90 100644 --- a/PowerEditor/src/WinControls/Preference/preference_rc.h +++ b/PowerEditor/src/WinControls/Preference/preference_rc.h @@ -206,6 +206,7 @@ #define IDC_COMBO_FILEUPDATECHOICE (IDD_PREFERENCE_SUB_MISC + 47) #define IDC_CHECK_DIRECTWRITE_ENABLE (IDD_PREFERENCE_SUB_MISC + 49) #define IDC_CHECK_CLICKABLELINK_FULLBOXMODE (IDD_PREFERENCE_SUB_MISC + 50) + #define IDC_CHECK_MUTE_SOUNDS (IDD_PREFERENCE_SUB_MISC + 60) #define IDD_PREFERENCE_SUB_NEWDOCUMENT 6400 //(IDD_PREFERENCE_BOX + 400) #define IDC_FORMAT_GB_STATIC (IDD_PREFERENCE_SUB_NEWDOCUMENT + 1) diff --git a/PowerEditor/visual.net/notepadPlus.vcxproj b/PowerEditor/visual.net/notepadPlus.vcxproj index 15dd57ac3..9f437b74c 100755 --- a/PowerEditor/visual.net/notepadPlus.vcxproj +++ b/PowerEditor/visual.net/notepadPlus.vcxproj @@ -111,7 +111,7 @@ /fixed:no %(AdditionalOptions) - comctl32.lib;shlwapi.lib;shell32.lib;Oleacc.lib;Dbghelp.lib;Version.lib;Crypt32.lib;wintrust.lib;Sensapi.lib;winmm.lib;wininet.lib;%(AdditionalDependencies) + comctl32.lib;shlwapi.lib;shell32.lib;Oleacc.lib;Dbghelp.lib;Version.lib;Crypt32.lib;wintrust.lib;Sensapi.lib;wininet.lib;%(AdditionalDependencies) LinkVerboseLib $(OutDir)notepad++.exe 1.0 @@ -150,7 +150,7 @@ /fixed:no %(AdditionalOptions) - comctl32.lib;shlwapi.lib;shell32.lib;Oleacc.lib;Dbghelp.lib;Version.lib;Crypt32.lib;wintrust.lib;Sensapi.lib;winmm.lib;wininet.lib;%(AdditionalDependencies) + comctl32.lib;shlwapi.lib;shell32.lib;Oleacc.lib;Dbghelp.lib;Version.lib;Crypt32.lib;wintrust.lib;Sensapi.lib;wininet.lib;%(AdditionalDependencies) LinkVerboseLib $(OutDir)notepad++.exe 1.0 @@ -194,7 +194,7 @@ true - comctl32.lib;shlwapi.lib;shell32.lib;Oleacc.lib;Dbghelp.lib;Version.lib;Crypt32.lib;wintrust.lib;Sensapi.lib;winmm.lib;wininet.lib;%(AdditionalDependencies) + comctl32.lib;shlwapi.lib;shell32.lib;Oleacc.lib;Dbghelp.lib;Version.lib;Crypt32.lib;wintrust.lib;Sensapi.lib;wininet.lib;%(AdditionalDependencies) LinkVerboseLib $(OutDir)notepad++.exe 1.0 @@ -246,7 +246,7 @@ copy ..\src\contextMenu.xml ..\bin\contextMenu.xml true - comctl32.lib;shlwapi.lib;shell32.lib;Oleacc.lib;Dbghelp.lib;Version.lib;Crypt32.lib;wintrust.lib;Sensapi.lib;winmm.lib;wininet.lib;%(AdditionalDependencies) + comctl32.lib;shlwapi.lib;shell32.lib;Oleacc.lib;Dbghelp.lib;Version.lib;Crypt32.lib;wintrust.lib;Sensapi.lib;wininet.lib;%(AdditionalDependencies) LinkVerboseLib $(OutDir)notepad++.exe 1.0