From 1890ea65f98f8d915ac2f4c437b2afd3b2535f8b Mon Sep 17 00:00:00 2001 From: Don Ho Date: Tue, 15 Oct 2024 05:09:12 +0200 Subject: [PATCH] Avoid user confusion between Global override & Default Styles Fix #15640, close #15706 --- PowerEditor/installer/nativeLang/english.xml | 17 ++++++++++------- .../nativeLang/english_customizable.xml | 16 +++++++++------- PowerEditor/installer/nativeLang/french.xml | 18 ++++++++++-------- .../nativeLang/taiwaneseMandarin.xml | 2 ++ .../WinControls/ColourPicker/WordStyleDlg.cpp | 17 +++++++++++++++-- .../WinControls/ColourPicker/WordStyleDlg.h | 9 +++++++++ .../WinControls/ColourPicker/WordStyleDlg.rc | 19 ++++++++++--------- .../ColourPicker/WordStyleDlgRes.h | 1 + PowerEditor/src/stylers.model.xml | 2 +- 9 files changed, 67 insertions(+), 34 deletions(-) diff --git a/PowerEditor/installer/nativeLang/english.xml b/PowerEditor/installer/nativeLang/english.xml index c6dbfc639..cffd20554 100644 --- a/PowerEditor/installer/nativeLang/english.xml +++ b/PowerEditor/installer/nativeLang/english.xml @@ -630,14 +630,15 @@ Translation note: - - - - - - - + + + + + + + + @@ -1819,6 +1820,8 @@ Click on "?" button on right to open website with User Manual."/> C, C++, Java, C#, Objective-C, PHP, JavaScript, JSP, CSS, Perl, Rust, PowerShell and JSON. If you select advanced mode but do not edit files in the aforementioned languages, the indentation will remain in basic mode."/> + + diff --git a/PowerEditor/installer/nativeLang/english_customizable.xml b/PowerEditor/installer/nativeLang/english_customizable.xml index 0c9210c87..468180107 100644 --- a/PowerEditor/installer/nativeLang/english_customizable.xml +++ b/PowerEditor/installer/nativeLang/english_customizable.xml @@ -630,14 +630,15 @@ Translation note: - - - - - - - + + + + + + + + @@ -1818,6 +1819,7 @@ Click on "?" button on right to open website with User Manual."/> C, C++, Java, C#, Objective-C, PHP, JavaScript, JSP, CSS, Perl, Rust, PowerShell and JSON. If you select advanced mode but do not edit files in the aforementioned languages, the indentation will remain in basic mode."/> + diff --git a/PowerEditor/installer/nativeLang/french.xml b/PowerEditor/installer/nativeLang/french.xml index 910a5bca4..6528e5bb0 100644 --- a/PowerEditor/installer/nativeLang/french.xml +++ b/PowerEditor/installer/nativeLang/french.xml @@ -630,14 +630,15 @@ Translation note: - - - - - - - - + + + + + + + + + @@ -1813,6 +1814,7 @@ Cliquez sur le bouton « ? » à droite pour ouvrir le site web du manuel utilis C, C++, Java, C#, Objective-C, PHP, JavaScript, JSP, CSS, Perl, Rust, PowerShell et JSON Si vous sélectionnez le mode avancé sans modifier les fichiers des langues mentionnées ci-dessus, les paramètres d'indentation resteront en mode basique."/> + diff --git a/PowerEditor/installer/nativeLang/taiwaneseMandarin.xml b/PowerEditor/installer/nativeLang/taiwaneseMandarin.xml index fa27b4c65..0571064d2 100644 --- a/PowerEditor/installer/nativeLang/taiwaneseMandarin.xml +++ b/PowerEditor/installer/nativeLang/taiwaneseMandarin.xml @@ -597,6 +597,7 @@ + @@ -1644,6 +1645,7 @@ C、C++、Java、C#、Objective-C、PHP、JavaScript、JSP、CSS、Perl、Rust、PowerShell 與 JSON 如果你選擇進階模式但不編輯上述語言文件,縮排設定將保留為基本模式。"/> + diff --git a/PowerEditor/src/WinControls/ColourPicker/WordStyleDlg.cpp b/PowerEditor/src/WinControls/ColourPicker/WordStyleDlg.cpp index 01d96832d..2b636fbcb 100644 --- a/PowerEditor/src/WinControls/ColourPicker/WordStyleDlg.cpp +++ b/PowerEditor/src/WinControls/ColourPicker/WordStyleDlg.cpp @@ -124,7 +124,7 @@ intptr_t CALLBACK WordStyleDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM for (size_t i = 0 ; i < sizeof(fontSizeStrs)/(3*sizeof(wchar_t)) ; ++i) ::SendMessage(_hFontSizeCombo, CB_ADDSTRING, 0, reinterpret_cast(fontSizeStrs[i])); - const std::vector & fontlist = (NppParameters::getInstance()).getFontList(); + const std::vector & fontlist = nppParamInst.getFontList(); for (size_t i = 0, len = fontlist.size() ; i < len ; ++i) { auto j = ::SendMessage(_hFontNameCombo, CB_ADDSTRING, 0, reinterpret_cast(fontlist[i].c_str())); @@ -157,6 +157,18 @@ intptr_t CALLBACK WordStyleDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM std::pair pageAndCtrlID = goToPreferencesSettings(); _goToSettings.display(pageAndCtrlID.first != -1); + HWND hWhatIsGlobalOverride = ::GetDlgItem(_hSelf, IDC_GLOBAL_WHATISGLOBALOVERRIDE_LINK); + _globalOverrideLinkTip.init(_hInst, _hSelf); + _globalOverrideLinkTip.create(hWhatIsGlobalOverride, L""); + + const Style& style = getCurrentStyler(); + bool showWhatIsGlobalOverride = (style._styleDesc == L"Global override"); + _globalOverrideLinkTip.display(showWhatIsGlobalOverride); + + NativeLangSpeaker* pNativeSpeaker = nppParamInst.getNativeLangSpeaker(); + wstring globalOverrideTipStr = pNativeSpeaker->getLocalizedStrFromID("global-override-tip", L"Enabling \"Global override\" here will override that parameter in all language styles. What you probably really want is to use the \"Default Style\" settings instead"); + _globalOverrideTip = CreateToolTip(IDC_GLOBAL_WHATISGLOBALOVERRIDE_LINK, _hSelf, _hInst, const_cast(globalOverrideTipStr.c_str()), false); + NppDarkMode::autoSubclassAndThemeChildControls(_hSelf); goToCenter(SWP_SHOWWINDOW | SWP_NOSIZE); @@ -1085,7 +1097,7 @@ std::pair WordStyleDlg::goToPreferencesSettings() const Style& style = getCurrentStyler(); - // Global override style + // Check if it's one of following Global Styles: if (style._styleDesc == L"Current line background colour") { result.first = edit1; @@ -1472,5 +1484,6 @@ void WordStyleDlg::showGlobalOverrideCtrls(bool show) ::ShowWindow(::GetDlgItem(_hSelf, IDC_GLOBAL_BOLD_CHECK), show ? SW_SHOW : SW_HIDE); ::ShowWindow(::GetDlgItem(_hSelf, IDC_GLOBAL_ITALIC_CHECK), show ? SW_SHOW : SW_HIDE); ::ShowWindow(::GetDlgItem(_hSelf, IDC_GLOBAL_UNDERLINE_CHECK), show ? SW_SHOW : SW_HIDE); + ::ShowWindow(::GetDlgItem(_hSelf, IDC_GLOBAL_WHATISGLOBALOVERRIDE_LINK), show ? SW_SHOW : SW_HIDE); _isShownGOCtrls = show; } diff --git a/PowerEditor/src/WinControls/ColourPicker/WordStyleDlg.h b/PowerEditor/src/WinControls/ColourPicker/WordStyleDlg.h index b553c1611..a8b4b245c 100644 --- a/PowerEditor/src/WinControls/ColourPicker/WordStyleDlg.h +++ b/PowerEditor/src/WinControls/ColourPicker/WordStyleDlg.h @@ -71,6 +71,13 @@ class WordStyleDlg : public StaticDialog { public : WordStyleDlg() = default; + ~WordStyleDlg() { + _goToSettings.destroy(); + _globalOverrideLinkTip.destroy(); + + if (_globalOverrideTip) + ::DestroyWindow(_globalOverrideTip); + }; void create(int dialogID, bool isRTL = false, bool msgDestParent = true) override; void doDialog(bool isRTL = false); @@ -104,6 +111,8 @@ private : HWND _hStyleInfoStaticText = nullptr; URLCtrl _goToSettings; + URLCtrl _globalOverrideLinkTip; + HWND _globalOverrideTip = nullptr; LexerStylerArray _lsArray; StyleArray _globalStyles; diff --git a/PowerEditor/src/WinControls/ColourPicker/WordStyleDlg.rc b/PowerEditor/src/WinControls/ColourPicker/WordStyleDlg.rc index dbf16eab0..441062816 100644 --- a/PowerEditor/src/WinControls/ColourPicker/WordStyleDlg.rc +++ b/PowerEditor/src/WinControls/ColourPicker/WordStyleDlg.rc @@ -64,19 +64,20 @@ BEGIN LTEXT "User-defined keywords",IDC_USER_KEYWORDS_STATIC,350,135,126,8 EDITTEXT IDC_USER_KEYWORDS_EDIT,347,146,136,52,ES_MULTILINE | WS_VSCROLL - CONTROL "Enable global foreground colour",IDC_GLOBAL_FG_CHECK,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,191,134,132,10 - CONTROL "Enable global background colour",IDC_GLOBAL_BG_CHECK,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,191,149,131,10 - CONTROL "Enable global font",IDC_GLOBAL_FONT_CHECK,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,327,134,153,10 - CONTROL "Enable global font size",IDC_GLOBAL_FONTSIZE_CHECK,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,327,149,135,10 - CONTROL "Enable global bold font style",IDC_GLOBAL_BOLD_CHECK,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,327,164,135,10 - CONTROL "Enable global italic font style",IDC_GLOBAL_ITALIC_CHECK,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,327,179,135,10 - CONTROL "Enable global underline font style",IDC_GLOBAL_UNDERLINE_CHECK,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,327,194,135,10 + CONTROL "Force foreground color for all styles",IDC_GLOBAL_FG_CHECK,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,191,134,132,10 + CONTROL "Force background color for all styles",IDC_GLOBAL_BG_CHECK,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,191,149,132,10 + CONTROL "Force font choice for all styles",IDC_GLOBAL_FONT_CHECK,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,327,134,153,10 + CONTROL "Force font size choice for all styles",IDC_GLOBAL_FONTSIZE_CHECK,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,327,149,135,10 + CONTROL "Force bold choice for all styles",IDC_GLOBAL_BOLD_CHECK,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,327,164,135,10 + CONTROL "Force italic choice for all styles",IDC_GLOBAL_ITALIC_CHECK,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,327,179,135,10 + CONTROL "Force underline choice for all styles",IDC_GLOBAL_UNDERLINE_CHECK,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,327,194,135,10 + + LTEXT "Go to settings",IDC_GLOBAL_GOTOSETTINGS_LINK,210,153,131,10,WS_TABSTOP + LTEXT "What is Global override?",IDC_GLOBAL_WHATISGLOBALOVERRIDE_LINK,191,173,132,10,WS_TABSTOP PUSHBUTTON "Save && Close",IDC_SAVECLOSE_BUTTON,264,222,69,14 PUSHBUTTON "Cancel",IDCANCEL,337,222,50,14 - LTEXT "Go to settings",IDC_GLOBAL_GOTOSETTINGS_LINK,210,153,131,10,WS_TABSTOP - CONTROL "Transparency",IDC_SC_TRANSPARENT_CHECK,"Button",BS_AUTOCHECKBOX | NOT WS_VISIBLE | WS_TABSTOP,431,221,63,10 CONTROL "",IDC_SC_PERCENTAGE_SLIDER,"msctls_trackbar32",TBS_BOTH | TBS_NOTICKS | TBS_TRANSPARENTBKGND | NOT WS_VISIBLE | WS_TABSTOP,441,235,53,10 END diff --git a/PowerEditor/src/WinControls/ColourPicker/WordStyleDlgRes.h b/PowerEditor/src/WinControls/ColourPicker/WordStyleDlgRes.h index 5bce3087d..2b3a6e784 100644 --- a/PowerEditor/src/WinControls/ColourPicker/WordStyleDlgRes.h +++ b/PowerEditor/src/WinControls/ColourPicker/WordStyleDlgRes.h @@ -56,6 +56,7 @@ #define IDC_GLOBAL_UNDERLINE_CHECK (IDD_STYLER_DLG + 32) #define IDC_STYLEDESCRIPTION_STATIC (IDD_STYLER_DLG + 33) #define IDC_GLOBAL_GOTOSETTINGS_LINK (IDD_STYLER_DLG + 34) + #define IDC_GLOBAL_WHATISGLOBALOVERRIDE_LINK (IDD_STYLER_DLG + 35) # define IDD_GLOBAL_STYLER_DLG 2300 #define IDC_SAVECLOSE_BUTTON (IDD_GLOBAL_STYLER_DLG + 1) diff --git a/PowerEditor/src/stylers.model.xml b/PowerEditor/src/stylers.model.xml index 2f2cfbf6f..bc960bfee 100644 --- a/PowerEditor/src/stylers.model.xml +++ b/PowerEditor/src/stylers.model.xml @@ -1708,7 +1708,6 @@ - @@ -1762,5 +1761,6 @@ +