From eeb47530449cebabc9c94a8bccefc0f574a2491c Mon Sep 17 00:00:00 2001 From: pawelzwronek Date: Mon, 11 Nov 2024 16:46:30 +0100 Subject: [PATCH] Add "Minimize / Close to" option for System tray Fix #15771, close #15785 --- PowerEditor/installer/nativeLang/english.xml | 1 + PowerEditor/installer/nativeLang/english_customizable.xml | 1 + PowerEditor/installer/nativeLang/polish.xml | 1 + PowerEditor/src/Notepad_plus.cpp | 2 +- PowerEditor/src/NppBigSwitch.cpp | 7 ++++--- PowerEditor/src/Parameters.cpp | 2 ++ PowerEditor/src/Parameters.h | 2 +- PowerEditor/src/WinControls/Preference/preferenceDlg.cpp | 3 ++- 8 files changed, 13 insertions(+), 6 deletions(-) diff --git a/PowerEditor/installer/nativeLang/english.xml b/PowerEditor/installer/nativeLang/english.xml index 2fc85af17..0fe080f94 100644 --- a/PowerEditor/installer/nativeLang/english.xml +++ b/PowerEditor/installer/nativeLang/english.xml @@ -1317,6 +1317,7 @@ Translation note: + diff --git a/PowerEditor/installer/nativeLang/english_customizable.xml b/PowerEditor/installer/nativeLang/english_customizable.xml index a3f7ee5b2..3e3703fab 100644 --- a/PowerEditor/installer/nativeLang/english_customizable.xml +++ b/PowerEditor/installer/nativeLang/english_customizable.xml @@ -1315,6 +1315,7 @@ Translation note: + diff --git a/PowerEditor/installer/nativeLang/polish.xml b/PowerEditor/installer/nativeLang/polish.xml index 474e7caf5..2b0a33846 100644 --- a/PowerEditor/installer/nativeLang/polish.xml +++ b/PowerEditor/installer/nativeLang/polish.xml @@ -1326,6 +1326,7 @@ Translation note: + diff --git a/PowerEditor/src/Notepad_plus.cpp b/PowerEditor/src/Notepad_plus.cpp index ec7fdbfce..9165c0cf9 100644 --- a/PowerEditor/src/Notepad_plus.cpp +++ b/PowerEditor/src/Notepad_plus.cpp @@ -453,7 +453,7 @@ LRESULT Notepad_plus::init(HWND hwnd) _dockingManager.init(_pPublicInterface->getHinst(), hwnd, &_pMainWindow); - if ((nppGUI._isMinimizedToTray == sta_minimize || nppGUI._isMinimizedToTray == sta_close) && _pTrayIco == nullptr) + if (nppGUI._isMinimizedToTray != sta_none && _pTrayIco == nullptr) { HICON icon = nullptr; Notepad_plus_Window::loadTrayIcon(_pPublicInterface->getHinst(), &icon); diff --git a/PowerEditor/src/NppBigSwitch.cpp b/PowerEditor/src/NppBigSwitch.cpp index 8e1acec14..c3dd2e321 100644 --- a/PowerEditor/src/NppBigSwitch.cpp +++ b/PowerEditor/src/NppBigSwitch.cpp @@ -2835,9 +2835,10 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPa case WM_SYSCOMMAND: { - const NppGUI & nppgui = (nppParam.getNppGUI()); - if (((nppgui._isMinimizedToTray == sta_minimize || _pPublicInterface->isPrelaunch()) && (wParam == SC_MINIMIZE)) || - (nppgui._isMinimizedToTray == sta_close && wParam == SC_CLOSE) + const NppGUI & nppgui = nppParam.getNppGUI(); + auto toTray = nppgui._isMinimizedToTray; + if (((toTray == sta_minimize || toTray == sta_minimize_close || _pPublicInterface->isPrelaunch()) && (wParam == SC_MINIMIZE)) || + ((toTray == sta_close || toTray == sta_minimize_close) && wParam == SC_CLOSE) ) { if (nullptr == _pTrayIco) diff --git a/PowerEditor/src/Parameters.cpp b/PowerEditor/src/Parameters.cpp index 5b65b9e33..73c8b33bf 100644 --- a/PowerEditor/src/Parameters.cpp +++ b/PowerEditor/src/Parameters.cpp @@ -5037,6 +5037,8 @@ void NppParameters::feedGUIParameters(TiXmlNode *node) _nppGUI._isMinimizedToTray = sta_minimize; else if (lstrcmp(val, L"2") == 0) _nppGUI._isMinimizedToTray = sta_close; + else if (lstrcmp(val, L"3") == 0) + _nppGUI._isMinimizedToTray = sta_minimize_close; } } } diff --git a/PowerEditor/src/Parameters.h b/PowerEditor/src/Parameters.h index c9cc0fcc5..c59f8ca6f 100644 --- a/PowerEditor/src/Parameters.h +++ b/PowerEditor/src/Parameters.h @@ -122,7 +122,7 @@ enum urlMode {urlDisable = 0, urlNoUnderLineFg, urlUnderLineFg, urlNoUnderLineBg urlMax = urlUnderLineBg}; enum AutoIndentMode { autoIndent_none = 0, autoIndent_advanced = 1, autoIndent_basic = 2 }; -enum SysTrayAction { sta_none = 0, sta_minimize = 1, sta_close = 2 }; +enum SysTrayAction { sta_none = 0, sta_minimize = 1, sta_close = 2, sta_minimize_close = 3 }; const int LANG_INDEX_INSTR = 0; const int LANG_INDEX_INSTR2 = 1; diff --git a/PowerEditor/src/WinControls/Preference/preferenceDlg.cpp b/PowerEditor/src/WinControls/Preference/preferenceDlg.cpp index a8c83fc1d..fa849211c 100644 --- a/PowerEditor/src/WinControls/Preference/preferenceDlg.cpp +++ b/PowerEditor/src/WinControls/Preference/preferenceDlg.cpp @@ -2425,8 +2425,9 @@ intptr_t CALLBACK MiscSubDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM) ::SendDlgItemMessage(_hSelf, IDC_COMBO_SYSTRAY_ACTION_HOICE, CB_ADDSTRING, 0, reinterpret_cast(L"No action to")); ::SendDlgItemMessage(_hSelf, IDC_COMBO_SYSTRAY_ACTION_HOICE, CB_ADDSTRING, 0, reinterpret_cast(L"Minimize to")); ::SendDlgItemMessage(_hSelf, IDC_COMBO_SYSTRAY_ACTION_HOICE, CB_ADDSTRING, 0, reinterpret_cast(L"Close to")); + ::SendDlgItemMessage(_hSelf, IDC_COMBO_SYSTRAY_ACTION_HOICE, CB_ADDSTRING, 0, reinterpret_cast(L"Minimize / Close to")); - if (nppGUI._isMinimizedToTray < 0 || nppGUI._isMinimizedToTray > sta_close) + if (nppGUI._isMinimizedToTray < 0 || nppGUI._isMinimizedToTray > sta_minimize_close) nppGUI._isMinimizedToTray = sta_none; ::SendDlgItemMessage(_hSelf, IDC_COMBO_SYSTRAY_ACTION_HOICE, CB_SETCURSEL, nppGUI._isMinimizedToTray, 0);