GUIEnhancement: About, Debug, Save dialogs

-  add accelerators
-  optimize dark mode
-  remove/comment unused variables
-  replace debug copy link with push button
-  fix override warnings
-  add initializers

Fix #13686, close #13687
This commit is contained in:
ozone10 2023-05-03 16:21:29 +02:00 committed by Don Ho
parent 779db128ac
commit 1806b8994b
5 changed files with 63 additions and 83 deletions

View File

@ -1324,11 +1324,11 @@ You can define several column markers by using white space to separate the diffe
<DoSaveAll title="Save All Confirmation"> <DoSaveAll title="Save All Confirmation">
<Item id="1766" name="Are you sure you want to save all modified documents? <Item id="1766" name="Are you sure you want to save all modified documents?
Choose &quot;Always Yes&quot; if you don't want to see this dialog again. Choose &quot;Always yes&quot; if you don't want to see this dialog again.
You can re-activate this dialog in Preferences later."/> You can re-activate this dialog in Preferences later."/>
<Item id="6" name="&amp;Yes"/> <Item id="6" name="&amp;Yes"/>
<Item id="7" name="&amp;No"/> <Item id="7" name="&amp;No"/>
<Item id="4" name="Always Yes"/> <Item id="4" name="&amp;Always yes"/>
</DoSaveAll><!-- HowToReproduce: Check the 'Enable Save All confirm dialog' checkbox in Preference->MISC, now click 'Save all' --> </DoSaveAll><!-- HowToReproduce: Check the 'Enable Save All confirm dialog' checkbox in Preference->MISC, now click 'Save all' -->
</Dialog> </Dialog>
<MessageBox> <MessageBox>

View File

@ -1324,11 +1324,11 @@ You can define several column markers by using white space to separate the diffe
<DoSaveAll title="Save All Confirmation"> <DoSaveAll title="Save All Confirmation">
<Item id="1766" name="Are you sure you want to save all modified documents? <Item id="1766" name="Are you sure you want to save all modified documents?
Choose &quot;Always Yes&quot; if you don't want to see this dialog again. Choose &quot;Always yes&quot; if you don't want to see this dialog again.
You can re-activate this dialog in Preferences later."/> You can re-activate this dialog in Preferences later."/>
<Item id="6" name="&amp;Yes"/> <Item id="6" name="&amp;Yes"/>
<Item id="7" name="&amp;No"/> <Item id="7" name="&amp;No"/>
<Item id="4" name="Always Yes"/> <Item id="4" name="&amp;Always yes"/>
</DoSaveAll><!-- HowToReproduce: Check the 'Enable Save All confirm dialog' checkbox in Preference->MISC, now click 'Save all' --> </DoSaveAll><!-- HowToReproduce: Check the 'Enable Save All confirm dialog' checkbox in Preference->MISC, now click 'Save all' -->
</Dialog> </Dialog>
<MessageBox> <MessageBox>

View File

@ -1257,7 +1257,7 @@ BEGIN
END END
END END
IDD_ABOUTBOX DIALOGEX 0, 0, 271, 240 IDD_ABOUTBOX DIALOGEX 0, 0, 270, 240
STYLE DS_SETFONT | DS_FIXEDSYS | WS_POPUP | WS_BORDER | WS_SYSMENU STYLE DS_SETFONT | DS_FIXEDSYS | WS_POPUP | WS_BORDER | WS_SYSMENU
FONT 8, TEXT("MS Shell Dlg"), 0, 0, 0x1 FONT 8, TEXT("MS Shell Dlg"), 0, 0, 0x1
BEGIN BEGIN
@ -1277,48 +1277,49 @@ BEGIN
//LTEXT "Happy Users' Edition",IDC_AUTHOR_NAME,85,38,100,8 //LTEXT "Happy Users' Edition",IDC_AUTHOR_NAME,85,38,100,8
//LTEXT "I want to get a refund",IDC_HOME_ADDR,85,48,126,8 //LTEXT "I want to get a refund",IDC_HOME_ADDR,85,48,126,8
LTEXT "Home:",IDC_STATIC,21,58,47,8 LTEXT "Home:",IDC_STATIC,21,58,47,8
LTEXT "https://notepad-plus-plus.org/",IDC_HOME_ADDR,50,58,126,8 LTEXT "https://notepad-plus-plus.org/",IDC_HOME_ADDR,50,57,126,10
GROUPBOX "GNU General Public Licence",IDC_STATIC,19,75,231,131,BS_CENTER GROUPBOX "GNU General Public Licence",IDC_STATIC,20,75,230,138,BS_CENTER
DEFPUSHBUTTON "OK",IDOK,106,215,50,14,BS_FLAT DEFPUSHBUTTON "OK",IDOK,110,220,50,14
// IDC_LICENCE_EDIT should be the last line, don't know why // IDC_LICENCE_EDIT should be the last line, don't know why
EDITTEXT IDC_LICENCE_EDIT,31,99,209,96,ES_MULTILINE | ES_AUTOVSCROLL | ES_READONLY | NOT WS_BORDER | WS_VSCROLL EDITTEXT IDC_LICENCE_EDIT,30,93,210,117,ES_MULTILINE | ES_AUTOVSCROLL | ES_READONLY | NOT WS_BORDER
END END
IDD_DEBUGINFOBOX DIALOGEX 0, 0, 271, 200 IDD_DEBUGINFOBOX DIALOGEX 0, 0, 246, 195
STYLE DS_SETFONT | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU STYLE DS_SETFONT | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU
EXSTYLE WS_EX_DLGMODALFRAME | WS_EX_WINDOWEDGE EXSTYLE WS_EX_DLGMODALFRAME | WS_EX_WINDOWEDGE
CAPTION "Debug Info" CAPTION "Debug Info"
FONT 8, TEXT("MS Shell Dlg"), 0, 0, 0x1 FONT 8, TEXT("MS Shell Dlg"), 0, 0, 0x1
BEGIN BEGIN
EDITTEXT IDC_DEBUGINFO_EDIT,31,20,220,96,ES_MULTILINE | ES_AUTOVSCROLL | ES_READONLY | NOT WS_BORDER | WS_VSCROLL GROUPBOX "",IDC_STATIC,8,3,230,151,BS_CENTER
LTEXT "Copy debug info into clipboard",IDC_DEBUGINFO_COPYLINK,31,120,126,8 EDITTEXT IDC_DEBUGINFO_EDIT,18,16,210,128,ES_MULTILINE | ES_AUTOVSCROLL | ES_READONLY | NOT WS_BORDER | WS_VSCROLL
DEFPUSHBUTTON "OK",IDOK,106,160,50,14,BS_FLAT PUSHBUTTON "&Copy debug info into clipboard",IDC_DEBUGINFO_COPYLINK,8,157,126,14
DEFPUSHBUTTON "OK",IDOK,98,175,50,14
END END
IDD_DOSAVEORNOTBOX DIALOGEX 0, 0, 310, 80 IDD_DOSAVEORNOTBOX DIALOGEX 0, 0, 312, 80
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU
EXSTYLE WS_EX_DLGMODALFRAME | WS_EX_WINDOWEDGE EXSTYLE WS_EX_DLGMODALFRAME | WS_EX_WINDOWEDGE
CAPTION "Save" CAPTION "Save"
FONT 8, TEXT("MS Shell Dlg"), 0, 0, 0x1 FONT 8, TEXT("MS Shell Dlg"), 0, 0, 0x1
BEGIN BEGIN
LTEXT "",IDC_DOSAVEORNOTTEXT,7,10,290,40,SS_EDITCONTROL LTEXT "",IDC_DOSAVEORNOTTEXT,7,10,290,40,SS_EDITCONTROL
DEFPUSHBUTTON "&Yes",IDYES,10,60,50,14,BS_FLAT DEFPUSHBUTTON "&Yes",IDYES,10,60,50,14
PUSHBUTTON "&No",IDNO,65,60,50,14,BS_FLAT PUSHBUTTON "&No",IDNO,63,60,50,14
PUSHBUTTON "&Cancel",IDCANCEL,120,60,50,14,BS_FLAT PUSHBUTTON "&Cancel",IDCANCEL,116,60,60,14
PUSHBUTTON "Yes to &all",IDRETRY,175,60,60,14,BS_FLAT PUSHBUTTON "Yes to &all",IDRETRY,179,60,60,14
PUSHBUTTON "N&o to all",IDIGNORE,240,60,60,14,BS_FLAT PUSHBUTTON "N&o to all",IDIGNORE,242,60,60,14
END END
IDD_DOSAVEALLBOX DIALOGEX 0, 0, 260, 100 IDD_DOSAVEALLBOX DIALOGEX 0, 0, 260, 95
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU
EXSTYLE WS_EX_DLGMODALFRAME | WS_EX_WINDOWEDGE EXSTYLE WS_EX_DLGMODALFRAME | WS_EX_WINDOWEDGE
CAPTION "Save" CAPTION "Save"
FONT 8, TEXT("MS Shell Dlg"), 0, 0, 0x1 FONT 8, TEXT("MS Shell Dlg"), 0, 0, 0x1
BEGIN BEGIN
LTEXT "",IDC_DOSAVEALLTEXT,7,10,250,70,SS_EDITCONTROL LTEXT "",IDC_DOSAVEALLTEXT,7,10,250,70,SS_EDITCONTROL
DEFPUSHBUTTON "&Yes",IDYES,47,75,50,14,BS_FLAT DEFPUSHBUTTON "&Yes",IDYES,47,75,50,14
PUSHBUTTON "Always Yes", IDRETRY, 102, 75, 60, 14, BS_FLAT PUSHBUTTON "&Always yes",IDRETRY,100,75,60,14
PUSHBUTTON "&No",IDNO,167,75,50,14,BS_FLAT PUSHBUTTON "&No",IDNO,163,75,50,14
END END
IDD_GOLINE DIALOGEX 0, 0, 258, 75 IDD_GOLINE DIALOGEX 0, 0, 258, 75

View File

@ -27,12 +27,12 @@ intptr_t CALLBACK AboutDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM lPar
{ {
switch (message) switch (message)
{ {
case WM_INITDIALOG : case WM_INITDIALOG:
{ {
NppDarkMode::autoSubclassAndThemeChildControls(_hSelf); NppDarkMode::autoSubclassAndThemeChildControls(_hSelf);
HWND compileDateHandle = ::GetDlgItem(_hSelf, IDC_BUILD_DATETIME); HWND compileDateHandle = ::GetDlgItem(_hSelf, IDC_BUILD_DATETIME);
generic_string buildTime = TEXT("Build time : "); generic_string buildTime = TEXT("Build time: ");
WcharMbcsConvertor& wmc = WcharMbcsConvertor::getInstance(); WcharMbcsConvertor& wmc = WcharMbcsConvertor::getInstance();
buildTime += wmc.char2wchar(__DATE__, CP_ACP); buildTime += wmc.char2wchar(__DATE__, CP_ACP);
@ -68,11 +68,7 @@ intptr_t CALLBACK AboutDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM lPar
case WM_CTLCOLORDLG: case WM_CTLCOLORDLG:
case WM_CTLCOLORSTATIC: case WM_CTLCOLORSTATIC:
{ {
if (NppDarkMode::isEnabled()) return NppDarkMode::onCtlColorDarker(reinterpret_cast<HDC>(wParam));
{
return NppDarkMode::onCtlColorDarker(reinterpret_cast<HDC>(wParam));
}
break;
} }
case WM_PRINTCLIENT: case WM_PRINTCLIENT:
@ -97,7 +93,7 @@ intptr_t CALLBACK AboutDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM lPar
int w = dpiManager.scaleX(iconSideSize); int w = dpiManager.scaleX(iconSideSize);
int h = dpiManager.scaleY(iconSideSize); int h = dpiManager.scaleY(iconSideSize);
HICON hIcon; HICON hIcon = nullptr;
if (NppDarkMode::isEnabled()) if (NppDarkMode::isEnabled())
hIcon = (HICON)::LoadImage(_hInst, MAKEINTRESOURCE(IDI_CHAMELEON_DM), IMAGE_ICON, w, h, LR_DEFAULTSIZE); hIcon = (HICON)::LoadImage(_hInst, MAKEINTRESOURCE(IDI_CHAMELEON_DM), IMAGE_ICON, w, h, LR_DEFAULTSIZE);
else else
@ -139,8 +135,8 @@ void AboutDlg::doDialog()
if (!isCreated()) if (!isCreated())
create(IDD_ABOUTBOX); create(IDD_ABOUTBOX);
// Adjust the position of AboutBox // Adjust the position of AboutBox
goToCenter(); goToCenter(SWP_SHOWWINDOW | SWP_NOSIZE);
} }
@ -183,7 +179,7 @@ intptr_t CALLBACK DebugInfoDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM
// Binary path // Binary path
_debugInfoStr += TEXT("Path : "); _debugInfoStr += TEXT("Path : ");
TCHAR nppFullPath[MAX_PATH]; TCHAR nppFullPath[MAX_PATH]{};
::GetModuleFileName(NULL, nppFullPath, MAX_PATH); ::GetModuleFileName(NULL, nppFullPath, MAX_PATH);
_debugInfoStr += nppFullPath; _debugInfoStr += nppFullPath;
_debugInfoStr += TEXT("\r\n"); _debugInfoStr += TEXT("\r\n");
@ -212,7 +208,7 @@ intptr_t CALLBACK DebugInfoDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM
_debugInfoStr += TEXT("\r\n"); _debugInfoStr += TEXT("\r\n");
// OS information // OS information
HKEY hKey; HKEY hKey = nullptr;
DWORD dataSize = 0; DWORD dataSize = 0;
constexpr size_t bufSize = 96; constexpr size_t bufSize = 96;
@ -335,9 +331,6 @@ intptr_t CALLBACK DebugInfoDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM
_debugInfoStr += _loadedPlugins.length() == 0 ? TEXT("none") : _loadedPlugins; _debugInfoStr += _loadedPlugins.length() == 0 ? TEXT("none") : _loadedPlugins;
_debugInfoStr += TEXT("\r\n"); _debugInfoStr += TEXT("\r\n");
_copyToClipboardLink.init(_hInst, _hSelf);
_copyToClipboardLink.create(::GetDlgItem(_hSelf, IDC_DEBUGINFO_COPYLINK), IDC_DEBUGINFO_COPYLINK);
getClientRect(_rc); getClientRect(_rc);
return TRUE; return TRUE;
} }
@ -345,11 +338,7 @@ intptr_t CALLBACK DebugInfoDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM
case WM_CTLCOLORDLG: case WM_CTLCOLORDLG:
case WM_CTLCOLORSTATIC: case WM_CTLCOLORSTATIC:
{ {
if (NppDarkMode::isEnabled()) return NppDarkMode::onCtlColorDarker(reinterpret_cast<HDC>(wParam));
{
return NppDarkMode::onCtlColorDarker(reinterpret_cast<HDC>(wParam));
}
break;
} }
case WM_PRINTCLIENT: case WM_PRINTCLIENT:
@ -378,14 +367,15 @@ intptr_t CALLBACK DebugInfoDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM
case IDC_DEBUGINFO_COPYLINK: case IDC_DEBUGINFO_COPYLINK:
{ {
if ((GetKeyState(VK_LBUTTON) & 0x100) != 0) // Visual effect
{ ::SendDlgItemMessage(_hSelf, IDC_DEBUGINFO_EDIT, EM_SETSEL, 0, _debugInfoDisplay.length() - 1);
// Visual effect
::SendDlgItemMessage(_hSelf, IDC_DEBUGINFO_EDIT, EM_SETSEL, 0, _debugInfoDisplay.length() - 1); // Copy to clipboard
str2Clipboard(_debugInfoDisplay, _hSelf);
// Set focus to edit control
::SendMessage(_hSelf, WM_NEXTDLGCTL, reinterpret_cast<WPARAM>(::GetDlgItem(_hSelf, IDC_DEBUGINFO_EDIT)), TRUE);
// Copy to clipboard
str2Clipboard(_debugInfoDisplay, _hSelf);
}
return TRUE; return TRUE;
} }
default: default:
@ -412,7 +402,7 @@ void DebugInfoDlg::doDialog()
refreshDebugInfo(); refreshDebugInfo();
// Adjust the position of AboutBox // Adjust the position of AboutBox
goToCenter(); goToCenter(SWP_SHOWWINDOW | SWP_NOSIZE);
} }
void DebugInfoDlg::refreshDebugInfo() void DebugInfoDlg::refreshDebugInfo()
@ -454,8 +444,8 @@ void DoSaveOrNotBox::changeLang()
if (nativeLangSpeaker->changeDlgLang(_hSelf, "DoSaveOrNot")) if (nativeLangSpeaker->changeDlgLang(_hSelf, "DoSaveOrNot"))
{ {
const unsigned char len = 255; constexpr unsigned char len = 255;
TCHAR text[len]; TCHAR text[len]{};
::GetDlgItemText(_hSelf, IDC_DOSAVEORNOTTEXT, text, len); ::GetDlgItemText(_hSelf, IDC_DOSAVEORNOTTEXT, text, len);
msg = text; msg = text;
} }
@ -478,18 +468,14 @@ intptr_t CALLBACK DoSaveOrNotBox::run_dlgProc(UINT message, WPARAM wParam, LPARA
changeLang(); changeLang();
::EnableWindow(::GetDlgItem(_hSelf, IDRETRY), _isMulti); ::EnableWindow(::GetDlgItem(_hSelf, IDRETRY), _isMulti);
::EnableWindow(::GetDlgItem(_hSelf, IDIGNORE), _isMulti); ::EnableWindow(::GetDlgItem(_hSelf, IDIGNORE), _isMulti);
goToCenter(); goToCenter(SWP_SHOWWINDOW | SWP_NOSIZE);
return TRUE; return TRUE;
} }
case WM_CTLCOLORDLG: case WM_CTLCOLORDLG:
case WM_CTLCOLORSTATIC: case WM_CTLCOLORSTATIC:
{ {
if (NppDarkMode::isEnabled()) return NppDarkMode::onCtlColorDarker(reinterpret_cast<HDC>(wParam));
{
return NppDarkMode::onCtlColorDarker(reinterpret_cast<HDC>(wParam));
}
break;
} }
case WM_PRINTCLIENT: case WM_PRINTCLIENT:
@ -571,8 +557,8 @@ void DoSaveAllBox::changeLang()
if (nativeLangSpeaker->changeDlgLang(_hSelf, "DoSaveAll")) if (nativeLangSpeaker->changeDlgLang(_hSelf, "DoSaveAll"))
{ {
const size_t len = 1024; constexpr size_t len = 1024;
TCHAR text[len]; TCHAR text[len]{};
::GetDlgItemText(_hSelf, IDC_DOSAVEALLTEXT, text, len); ::GetDlgItemText(_hSelf, IDC_DOSAVEALLTEXT, text, len);
msg = text; msg = text;
} }
@ -592,18 +578,14 @@ intptr_t CALLBACK DoSaveAllBox::run_dlgProc(UINT message, WPARAM wParam, LPARAM
NppDarkMode::autoSubclassAndThemeChildControls(_hSelf); NppDarkMode::autoSubclassAndThemeChildControls(_hSelf);
changeLang(); changeLang();
goToCenter(); goToCenter(SWP_SHOWWINDOW | SWP_NOSIZE);
return TRUE; return TRUE;
} }
case WM_CTLCOLORDLG: case WM_CTLCOLORDLG:
case WM_CTLCOLORSTATIC: case WM_CTLCOLORSTATIC:
{ {
if (NppDarkMode::isEnabled()) return NppDarkMode::onCtlColorDarker(reinterpret_cast<HDC>(wParam));
{
return NppDarkMode::onCtlColorDarker(reinterpret_cast<HDC>(wParam));
}
break;
} }
case WM_PRINTCLIENT: case WM_PRINTCLIENT:

View File

@ -43,17 +43,17 @@ public :
void doDialog(); void doDialog();
virtual void destroy() { void destroy() override {
_emailLink.destroy(); //_emailLink.destroy();
_pageLink.destroy(); _pageLink.destroy();
}; };
protected : protected :
virtual intptr_t CALLBACK run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam); intptr_t CALLBACK run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam) override;
private : private :
URLCtrl _emailLink; //URLCtrl _emailLink;
URLCtrl _pageLink; URLCtrl _pageLink;
}; };
@ -72,12 +72,10 @@ public:
void refreshDebugInfo(); void refreshDebugInfo();
virtual void destroy() { void destroy() override {};
_copyToClipboardLink.destroy();
};
protected: protected:
virtual intptr_t CALLBACK run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam); intptr_t CALLBACK run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam) override;
private: private:
typedef const CHAR * (__cdecl * PWINEGETVERSION)(); typedef const CHAR * (__cdecl * PWINEGETVERSION)();
@ -86,7 +84,6 @@ private:
const generic_string _cmdLinePlaceHolder { L"$COMMAND_LINE_PLACEHOLDER$" }; const generic_string _cmdLinePlaceHolder { L"$COMMAND_LINE_PLACEHOLDER$" };
bool _isAdmin = false; bool _isAdmin = false;
generic_string _loadedPlugins; generic_string _loadedPlugins;
URLCtrl _copyToClipboardLink;
}; };
class DoSaveOrNotBox : public StaticDialog class DoSaveOrNotBox : public StaticDialog
@ -104,7 +101,7 @@ public:
void doDialog(bool isRTL = false); void doDialog(bool isRTL = false);
virtual void destroy() {}; void destroy() override {};
int getClickedButtonId() const { int getClickedButtonId() const {
return clickedButtonId; return clickedButtonId;
@ -113,7 +110,7 @@ public:
void changeLang(); void changeLang();
protected: protected:
virtual intptr_t CALLBACK run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam); intptr_t CALLBACK run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam) override;
private: private:
int clickedButtonId = -1; int clickedButtonId = -1;
@ -128,7 +125,7 @@ public:
void doDialog(bool isRTL = false); void doDialog(bool isRTL = false);
virtual void destroy() {}; void destroy() override {};
int getClickedButtonId() const { int getClickedButtonId() const {
return clickedButtonId; return clickedButtonId;
@ -137,7 +134,7 @@ public:
void changeLang(); void changeLang();
protected: protected:
virtual intptr_t CALLBACK run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam); intptr_t CALLBACK run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam) override;
private: private:
int clickedButtonId = -1; int clickedButtonId = -1;