From deab93f9b50f580bc276225755c2782b20cd255a Mon Sep 17 00:00:00 2001 From: Don Ho Date: Sun, 22 Aug 2021 17:49:35 +0200 Subject: [PATCH] Make "Confirm Save All" dialog more clear Use "Always Yes" button instead of "Cancel", and whole dialog is translatble. Fix #10339, close #10429 --- PowerEditor/installer/nativeLang/english.xml | 13 ++- PowerEditor/installer/nativeLang/french.xml | 10 ++ .../nativeLang/taiwaneseMandarin.xml | 80 ++++++++------ PowerEditor/src/Notepad_plus.cpp | 20 ++++ PowerEditor/src/Notepad_plus.h | 1 + PowerEditor/src/Notepad_plus.rc | 14 ++- PowerEditor/src/NppIO.cpp | 8 +- .../src/WinControls/AboutDlg/AboutDlg.cpp | 101 +++++++++++++++++- .../src/WinControls/AboutDlg/AboutDlg.h | 22 ++++ PowerEditor/src/resource.h | 7 +- 10 files changed, 226 insertions(+), 50 deletions(-) diff --git a/PowerEditor/installer/nativeLang/english.xml b/PowerEditor/installer/nativeLang/english.xml index 12e8009fc..b78ada67e 100644 --- a/PowerEditor/installer/nativeLang/english.xml +++ b/PowerEditor/installer/nativeLang/english.xml @@ -1160,6 +1160,15 @@ You can define several column markers by using white space to separate the diffe + + + + + + Notepad++ will be restarted after all the operations are terminated. Continue?"/> - diff --git a/PowerEditor/installer/nativeLang/french.xml b/PowerEditor/installer/nativeLang/french.xml index e9f5492f7..9cf5deaa3 100644 --- a/PowerEditor/installer/nativeLang/french.xml +++ b/PowerEditor/installer/nativeLang/french.xml @@ -1085,6 +1085,7 @@ Vous pouvez définir plusieurs marqueurs de colonne en utilisant un espace pour + @@ -1138,6 +1139,15 @@ Vous pouvez définir plusieurs marqueurs de colonne en utilisant un espace pour + + + + + + diff --git a/PowerEditor/installer/nativeLang/taiwaneseMandarin.xml b/PowerEditor/installer/nativeLang/taiwaneseMandarin.xml index 9dbe6b984..3d0c33f24 100644 --- a/PowerEditor/installer/nativeLang/taiwaneseMandarin.xml +++ b/PowerEditor/installer/nativeLang/taiwaneseMandarin.xml @@ -1098,6 +1098,7 @@ + @@ -1152,74 +1153,83 @@ + + + + + + - - + + - + - - + - + - - - +你要在 Notepad++ 中保留這個文件嗎?"/> + + +你要重新載入此文件嗎?"/> +你要重新載入並捨棄在 Notepad++ 中所做的修改嗎?"/> +你要直接到 Notepad++ 網站下載最新版本嗎?"/> - + - + +你要回復它嗎?"/> - + - + - - + + - - + + - + - - - + + + - + @@ -1316,11 +1326,11 @@ - + - + @@ -1404,7 +1414,7 @@ - + diff --git a/PowerEditor/src/Notepad_plus.cpp b/PowerEditor/src/Notepad_plus.cpp index a796193be..f2833d99f 100644 --- a/PowerEditor/src/Notepad_plus.cpp +++ b/PowerEditor/src/Notepad_plus.cpp @@ -2040,6 +2040,26 @@ int Notepad_plus::doSaveOrNot(const TCHAR* fn, bool isMulti) return buttonID; } +int Notepad_plus::doSaveAll() +{ + // In case Notepad++ is iconized into notification zone + if (!::IsWindowVisible(_pPublicInterface->getHSelf())) + { + ::ShowWindow(_pPublicInterface->getHSelf(), SW_SHOW); + + // Send sizing info to make window fit (specially to show tool bar.) + ::SendMessage(_pPublicInterface->getHSelf(), WM_SIZE, 0, 0); + } + + DoSaveAllBox doSaveAllBox; + doSaveAllBox.init(_pPublicInterface->getHinst(), _pPublicInterface->getHSelf()); + doSaveAllBox.doDialog(_nativeLangSpeaker.isRTL()); + int buttonID = doSaveAllBox.getClickedButtonId(); + doSaveAllBox.destroy(); + + return buttonID; +} + int Notepad_plus::doReloadOrNot(const TCHAR *fn, bool dirty) { if (dirty) diff --git a/PowerEditor/src/Notepad_plus.h b/PowerEditor/src/Notepad_plus.h index 2266fec7f..c428719a7 100644 --- a/PowerEditor/src/Notepad_plus.h +++ b/PowerEditor/src/Notepad_plus.h @@ -467,6 +467,7 @@ private: int doReloadOrNot(const TCHAR *fn, bool dirty); int doCloseOrNot(const TCHAR *fn); int doDeleteOrNot(const TCHAR *fn); + int doSaveAll(); void enableMenu(int cmdID, bool doEnable) const; void enableCommand(int cmdID, bool doEnable, int which) const; diff --git a/PowerEditor/src/Notepad_plus.rc b/PowerEditor/src/Notepad_plus.rc index 3ad4b493f..a9facdcc3 100644 --- a/PowerEditor/src/Notepad_plus.rc +++ b/PowerEditor/src/Notepad_plus.rc @@ -1229,7 +1229,7 @@ EXSTYLE WS_EX_DLGMODALFRAME | WS_EX_WINDOWEDGE CAPTION "Save" FONT 8, TEXT("MS Shell Dlg"), 0, 0, 0x1 BEGIN - LTEXT "",IDC_DOSAVEORNOTTEX,7,10,290,40,SS_EDITCONTROL + LTEXT "",IDC_DOSAVEORNOTTEXT,7,10,290,40,SS_EDITCONTROL DEFPUSHBUTTON "&Yes",IDYES,10,60,50,14,BS_FLAT PUSHBUTTON "&No",IDNO,65,60,50,14,BS_FLAT PUSHBUTTON "&Cancel",IDCANCEL,120,60,50,14,BS_FLAT @@ -1237,6 +1237,18 @@ BEGIN PUSHBUTTON "N&o to all",IDIGNORE,240,60,60,14,BS_FLAT END +IDD_DOSAVEALLBOX DIALOGEX 0, 0, 260, 100 +STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU +EXSTYLE WS_EX_DLGMODALFRAME | WS_EX_WINDOWEDGE +CAPTION "Save" +FONT 8, TEXT("MS Shell Dlg"), 0, 0, 0x1 +BEGIN + LTEXT "",IDC_DOSAVEALLTEXT,7,10,250,70,SS_EDITCONTROL + DEFPUSHBUTTON "&Yes",IDYES,47,75,50,14,BS_FLAT + PUSHBUTTON "Always Yes", IDRETRY, 102, 75, 60, 14, BS_FLAT + PUSHBUTTON "&No",IDNO,167,75,50,14,BS_FLAT +END + IDD_GOLINE DIALOGEX 26, 41, 261, 88 STYLE DS_SETFONT | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU EXSTYLE WS_EX_DLGMODALFRAME | WS_EX_WINDOWEDGE diff --git a/PowerEditor/src/NppIO.cpp b/PowerEditor/src/NppIO.cpp index 53618a0cf..7a99648f3 100644 --- a/PowerEditor/src/NppIO.cpp +++ b/PowerEditor/src/NppIO.cpp @@ -1604,18 +1604,14 @@ bool Notepad_plus::fileSaveAllConfirm() if (NppParameters::getInstance().getNppGUI()._saveAllConfirm) { - int answer = _nativeLangSpeaker.messageBox("SaveAllConfirm", - _pPublicInterface->getHSelf(), - TEXT("Are you sure you want to save all documents?\r\rChoose \"Cancel\" if your answer will always be \"Yes\" and you won't be asked this question again.\rYou can re-activate this dialog in Preferences dialog later."), - TEXT("Save All Confirmation"), - MB_YESNOCANCEL | MB_DEFBUTTON2); + int answer = doSaveAll(); if (answer == IDYES) { confirmed = true; } - if (answer == IDCANCEL) + if (answer == IDRETRY) { NppParameters::getInstance().getNppGUI()._saveAllConfirm = false; //uncheck the "Enable save all confirm dialog" checkbox in Preference-> MISC settings diff --git a/PowerEditor/src/WinControls/AboutDlg/AboutDlg.cpp b/PowerEditor/src/WinControls/AboutDlg/AboutDlg.cpp index f0b8a8e46..0becd2512 100644 --- a/PowerEditor/src/WinControls/AboutDlg/AboutDlg.cpp +++ b/PowerEditor/src/WinControls/AboutDlg/AboutDlg.cpp @@ -372,7 +372,7 @@ void DoSaveOrNotBox::changeLang() { const unsigned char len = 255; TCHAR text[len]; - ::GetDlgItemText(_hSelf, IDC_DOSAVEORNOTTEX, text, len); + ::GetDlgItemText(_hSelf, IDC_DOSAVEORNOTTEXT, text, len); msg = text; } @@ -380,7 +380,7 @@ void DoSaveOrNotBox::changeLang() msg = defaultMessage; msg = stringReplace(msg, TEXT("$STR_REPLACE$"), _fn); - ::SetDlgItemText(_hSelf, IDC_DOSAVEORNOTTEX, msg.c_str()); + ::SetDlgItemText(_hSelf, IDC_DOSAVEORNOTTEXT, msg.c_str()); } INT_PTR CALLBACK DoSaveOrNotBox::run_dlgProc(UINT message, WPARAM wParam, LPARAM /*lParam*/) @@ -453,3 +453,100 @@ INT_PTR CALLBACK DoSaveOrNotBox::run_dlgProc(UINT message, WPARAM wParam, LPARAM } return FALSE; } + + +void DoSaveAllBox::doDialog(bool isRTL) +{ + + if (isRTL) + { + DLGTEMPLATE* pMyDlgTemplate = NULL; + HGLOBAL hMyDlgTemplate = makeRTLResource(IDD_DOSAVEALLBOX, &pMyDlgTemplate); + ::DialogBoxIndirectParam(_hInst, pMyDlgTemplate, _hParent, dlgProc, reinterpret_cast(this)); + ::GlobalFree(hMyDlgTemplate); + } + else + ::DialogBoxParam(_hInst, MAKEINTRESOURCE(IDD_DOSAVEALLBOX), _hParent, dlgProc, reinterpret_cast(this)); +} + +void DoSaveAllBox::changeLang() +{ + generic_string msg; + generic_string defaultMessage = TEXT("Are you sure you want to save all modified documents?\r\rChoose \"Always Yes\" if your don't want to see this dialog again.\rYou can re-activate this dialog in Preferences later."); + NativeLangSpeaker* nativeLangSpeaker = NppParameters::getInstance().getNativeLangSpeaker(); + + if (nativeLangSpeaker->changeDlgLang(_hSelf, "DoSaveAll")) + { + const size_t len = 1024; + TCHAR text[len]; + ::GetDlgItemText(_hSelf, IDC_DOSAVEALLTEXT, text, len); + msg = text; + } + + if (msg.empty()) + msg = defaultMessage; + + ::SetDlgItemText(_hSelf, IDC_DOSAVEALLTEXT, msg.c_str()); +} + +INT_PTR CALLBACK DoSaveAllBox::run_dlgProc(UINT message, WPARAM wParam, LPARAM /*lParam*/) +{ + switch (message) + { + case WM_INITDIALOG: + { + NppDarkMode::autoSubclassAndThemeChildControls(_hSelf); + + changeLang(); + goToCenter(); + return TRUE; + } + + case WM_CTLCOLORDLG: + case WM_CTLCOLORSTATIC: + { + if (NppDarkMode::isEnabled()) + { + return NppDarkMode::onCtlColorDarker(reinterpret_cast(wParam)); + } + break; + } + + case WM_COMMAND: + { + switch (LOWORD(wParam)) + { + case IDCANCEL: + { + ::EndDialog(_hSelf, -1); + clickedButtonId = IDCANCEL; + return TRUE; + } + + case IDYES: + { + ::EndDialog(_hSelf, 0); + clickedButtonId = IDYES; + return TRUE; + } + + case IDNO: + { + ::EndDialog(_hSelf, 0); + clickedButtonId = IDNO; + return TRUE; + } + + case IDRETRY: + { + ::EndDialog(_hSelf, 0); + clickedButtonId = IDRETRY; + return TRUE; + } + } + } + default: + return FALSE; + } + return FALSE; +} \ No newline at end of file diff --git a/PowerEditor/src/WinControls/AboutDlg/AboutDlg.h b/PowerEditor/src/WinControls/AboutDlg/AboutDlg.h index 177ad2615..c7a057ff0 100644 --- a/PowerEditor/src/WinControls/AboutDlg/AboutDlg.h +++ b/PowerEditor/src/WinControls/AboutDlg/AboutDlg.h @@ -116,3 +116,25 @@ private: generic_string _fn; bool _isMulti = false; }; + +class DoSaveAllBox : public StaticDialog +{ +public: + DoSaveAllBox() = default; + + void doDialog(bool isRTL = false); + + virtual void destroy() {}; + + int getClickedButtonId() const { + return clickedButtonId; + }; + + void changeLang(); + +protected: + virtual INT_PTR CALLBACK run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam); + +private: + int clickedButtonId = -1; +}; diff --git a/PowerEditor/src/resource.h b/PowerEditor/src/resource.h index 8b016e106..e6e583c53 100644 --- a/PowerEditor/src/resource.h +++ b/PowerEditor/src/resource.h @@ -484,8 +484,11 @@ #define IDC_DEBUGINFO_EDIT 1751 #define IDC_DEBUGINFO_COPYLINK 1752 -#define IDD_DOSAVEORNOTBOX 1760 -#define IDC_DOSAVEORNOTTEX 1761 +#define IDD_DOSAVEORNOTBOX 1760 +#define IDC_DOSAVEORNOTTEXT 1761 + +#define IDD_DOSAVEALLBOX 1765 +#define IDC_DOSAVEALLTEXT 1766 //#define IDD_USER_DEFINE_BOX 1800 //#define IDD_RUN_DLG 1900