Add "Minimize / Close to" option for System tray

Fix #15771, close #15785
This commit is contained in:
pawelzwronek 2024-11-11 16:46:30 +01:00 committed by Don Ho
parent b8224808bd
commit eeb4753044
8 changed files with 13 additions and 6 deletions

View File

@ -1317,6 +1317,7 @@ Translation note:
<Element name="No action to"/> <Element name="No action to"/>
<Element name="Minimize to"/> <Element name="Minimize to"/>
<Element name="Close to"/> <Element name="Close to"/>
<Element name="Minimize / Close to"/>
</ComboBox> </ComboBox>
<Item id="6308" name="system tray"/> <Item id="6308" name="system tray"/>
<Item id="6312" name="File Status Auto-Detection"/> <Item id="6312" name="File Status Auto-Detection"/>

View File

@ -1315,6 +1315,7 @@ Translation note:
<Element name="No action to"/> <Element name="No action to"/>
<Element name="Minimize to"/> <Element name="Minimize to"/>
<Element name="Close to"/> <Element name="Close to"/>
<Element name="Minimize / Close to"/>
</ComboBox> </ComboBox>
<Item id="6308" name="system tray"/> <Item id="6308" name="system tray"/>
<Item id="6312" name="File Status Auto-Detection"/> <Item id="6312" name="File Status Auto-Detection"/>

View File

@ -1326,6 +1326,7 @@ Translation note:
<Element name="Bez akcji do"/> <Element name="Bez akcji do"/>
<Element name="Minimalizuj do"/> <Element name="Minimalizuj do"/>
<Element name="Zamykaj do"/> <Element name="Zamykaj do"/>
<Element name="Minimalizuj / Zamykaj do"/>
</ComboBox> </ComboBox>
<Item id="6308" name="zasobnika systemowego"/> <Item id="6308" name="zasobnika systemowego"/>
<Item id="6312" name="Autowykrywanie stanu pliku"/> <Item id="6312" name="Autowykrywanie stanu pliku"/>

View File

@ -453,7 +453,7 @@ LRESULT Notepad_plus::init(HWND hwnd)
_dockingManager.init(_pPublicInterface->getHinst(), hwnd, &_pMainWindow); _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; HICON icon = nullptr;
Notepad_plus_Window::loadTrayIcon(_pPublicInterface->getHinst(), &icon); Notepad_plus_Window::loadTrayIcon(_pPublicInterface->getHinst(), &icon);

View File

@ -2835,9 +2835,10 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPa
case WM_SYSCOMMAND: case WM_SYSCOMMAND:
{ {
const NppGUI & nppgui = (nppParam.getNppGUI()); const NppGUI & nppgui = nppParam.getNppGUI();
if (((nppgui._isMinimizedToTray == sta_minimize || _pPublicInterface->isPrelaunch()) && (wParam == SC_MINIMIZE)) || auto toTray = nppgui._isMinimizedToTray;
(nppgui._isMinimizedToTray == sta_close && wParam == SC_CLOSE) 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) if (nullptr == _pTrayIco)

View File

@ -5037,6 +5037,8 @@ void NppParameters::feedGUIParameters(TiXmlNode *node)
_nppGUI._isMinimizedToTray = sta_minimize; _nppGUI._isMinimizedToTray = sta_minimize;
else if (lstrcmp(val, L"2") == 0) else if (lstrcmp(val, L"2") == 0)
_nppGUI._isMinimizedToTray = sta_close; _nppGUI._isMinimizedToTray = sta_close;
else if (lstrcmp(val, L"3") == 0)
_nppGUI._isMinimizedToTray = sta_minimize_close;
} }
} }
} }

View File

@ -122,7 +122,7 @@ enum urlMode {urlDisable = 0, urlNoUnderLineFg, urlUnderLineFg, urlNoUnderLineBg
urlMax = urlUnderLineBg}; urlMax = urlUnderLineBg};
enum AutoIndentMode { autoIndent_none = 0, autoIndent_advanced = 1, autoIndent_basic = 2 }; 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_INSTR = 0;
const int LANG_INDEX_INSTR2 = 1; const int LANG_INDEX_INSTR2 = 1;

View File

@ -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<LPARAM>(L"No action to")); ::SendDlgItemMessage(_hSelf, IDC_COMBO_SYSTRAY_ACTION_HOICE, CB_ADDSTRING, 0, reinterpret_cast<LPARAM>(L"No action to"));
::SendDlgItemMessage(_hSelf, IDC_COMBO_SYSTRAY_ACTION_HOICE, CB_ADDSTRING, 0, reinterpret_cast<LPARAM>(L"Minimize to")); ::SendDlgItemMessage(_hSelf, IDC_COMBO_SYSTRAY_ACTION_HOICE, CB_ADDSTRING, 0, reinterpret_cast<LPARAM>(L"Minimize to"));
::SendDlgItemMessage(_hSelf, IDC_COMBO_SYSTRAY_ACTION_HOICE, CB_ADDSTRING, 0, reinterpret_cast<LPARAM>(L"Close to")); ::SendDlgItemMessage(_hSelf, IDC_COMBO_SYSTRAY_ACTION_HOICE, CB_ADDSTRING, 0, reinterpret_cast<LPARAM>(L"Close to"));
::SendDlgItemMessage(_hSelf, IDC_COMBO_SYSTRAY_ACTION_HOICE, CB_ADDSTRING, 0, reinterpret_cast<LPARAM>(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; nppGUI._isMinimizedToTray = sta_none;
::SendDlgItemMessage(_hSelf, IDC_COMBO_SYSTRAY_ACTION_HOICE, CB_SETCURSEL, nppGUI._isMinimizedToTray, 0); ::SendDlgItemMessage(_hSelf, IDC_COMBO_SYSTRAY_ACTION_HOICE, CB_SETCURSEL, nppGUI._isMinimizedToTray, 0);