Make better UI for the file status auto-update enhancement

This commit is contained in:
Don HO 2019-03-21 00:06:01 +01:00
parent 469f4a2c69
commit 28f87ca6de
No known key found for this signature in database
GPG Key ID: 6C429F1D8D84F46E
7 changed files with 131 additions and 59 deletions

View File

@ -909,6 +909,11 @@
</SearchEngine>
<MISC title="其他">
<ComboBox id="6347">
<Element name="啟用"/>
<Element name="啟用於所有開啟文件"/>
<Element name="停止啟用"/>
</ComboBox>
<Item id="6307" name="啟用"/>
<Item id="6308" name="最小化至系統匣"/>
<Item id="6312" name="自動更新檔案狀態"/>

View File

@ -38,7 +38,7 @@
<Item subMenuId="search-jumpUp" name="Jump Up"/>
<Item subMenuId="search-jumpDown" name="Jump Down"/>
<Item subMenuId="search-bookmark" name="Bookmark"/>
<Item subMenuId="view-currentFileIn" name="View Current File in"/>
<Item subMenuId="view-currentFileIn" name="View Current File in"/>
<Item subMenuId="view-showSymbol" name="Show Symbol"/>
<Item subMenuId="view-zoom" name="Zoom"/>
<Item subMenuId="view-moveCloneDocument" name="Move/Clone Current Document"/>
@ -910,11 +910,14 @@
</SearchEngine>
<MISC title="MISC.">
<Item id="6307" name="Enable for all tabs"/>
<ComboBox id="6347">
<Element name="Enable"/>
<Element name="Enable for all tabs"/>
<Element name="Disable"/>
</ComboBox>
<Item id="6308" name="Minimize to system tray"/>
<Item id="6312" name="File Status Auto-Detection"/>
<Item id="6313" name="Update silently"/>
<Item id="6314" name="Enable only for current tab"/>
<Item id="6318" name="Clickable Link Settings"/>
<Item id="6325" name="Scroll to the last line after update"/>
<Item id="6319" name="Enable"/>
@ -1067,7 +1070,7 @@ Do you want to launch Notepad++ in Administrator mode?"/>
<OpenInAdminModeWithoutCloseCurrent title="Save failed" message="The file cannot be saved and it may be protected.
Do you want to launch Notepad++ in Administrator mode?"/>
<OpenInAdminModeFailed title="Open in Administrator mode failed" message="Notepad++ cannot be opened in Administrator mode."/>
<ViewInBrowser title="View Current File in Browser" message="Application cannot be found in your system."/>
<ViewInBrowser title="View Current File in Browser" message="Application cannot be found in your system."/>
</MessageBox>
<ClipboardHistory>
<PanelTitle name="Clipboard History"/>

View File

@ -895,6 +895,11 @@
</SearchEngine>
<MISC title="Divers">
<ComboBox id="6347">
<Element name="Activer"/>
<Element name="Activer avec tous les onglets"/>
<Element name="Désactiver"/>
</ComboBox>
<Item id="6114" name="Activer"/>
<Item id="6115" name="Indentation automatique"/>
<Item id="6117" name="Activer la liste de MRU"/>

View File

@ -130,16 +130,15 @@ BEGIN
CONTROL "Enable Notepad++ auto-updater",IDC_CHECK_AUTOUPDATE, "Button",BS_AUTOCHECKBOX | BS_MULTILINE | WS_TABSTOP,37,173,217,10
CONTROL "Enable",IDC_CHECK_CLICKABLELINK_ENABLE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,267,15,140,10
CONTROL "No underline",IDC_CHECK_CLICKABLELINK_NOUNDERLINE, "Button",BS_AUTOCHECKBOX | WS_TABSTOP,267,28,140,10
CONTROL "Enable for all tabs",IDC_CHECK_FILEAUTODETECTION_ALL,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,267,57,140,10
CONTROL "Enable only for current tab",IDC_CHECK_FILEAUTODETECTION_CURRENT,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,267,69,140,10
CONTROL "Update silently",IDC_CHECK_UPDATESILENTLY,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,267,81,140,10
CONTROL "Scroll to the last line after update",IDC_CHECK_UPDATEGOTOEOF,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,267,93,140,10
COMBOBOX IDC_COMBO_FILEUPDATECHOICE,267, 60,140,100,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
CONTROL "Update silently",IDC_CHECK_UPDATESILENTLY,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,267,76,140,10
CONTROL "Scroll to the last line after update",IDC_CHECK_UPDATEGOTOEOF,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,267,88,140,10
EDITTEXT IDC_EDIT_SESSIONFILEEXT,381,135,34,14,ES_AUTOHSCROLL
EDITTEXT IDC_EDIT_WORKSPACEFILEEXT,381,152,34,14,ES_AUTOHSCROLL
GROUPBOX "Document Switcher (Ctrl+TAB)",IDC_DOCUMENTSWITCHER_STATIC,37,4,155,39,BS_CENTER
GROUPBOX "Clickable Link Settings",IDC_CLICKABLELINK_STATIC,259,4,155,39,BS_CENTER
GROUPBOX "Document Peeker",IDC_DOCUMENTPEEK_STATIC,37,47,155,39,BS_CENTER
GROUPBOX "File Status Auto-Detection",IDC_FILEAUTODETECTION_STATIC,259,47,155,62,BS_CENTER
GROUPBOX "File Status Auto-Detection",IDC_FILEAUTODETECTION_STATIC,259,47,155,60,BS_CENTER
RTEXT "Session file ext.:",IDC_SESSIONFILEEXT_STATIC,271,138,108,8
RTEXT "Workspace file ext.:",IDC_WORKSPACEFILEEXT_STATIC,271,155,108,8
END

View File

@ -871,6 +871,9 @@ INT_PTR CALLBACK MarginsDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM lPa
return FALSE;
}
const size_t fileUpdateChoiceEnable = 0;
const size_t fileUpdateChoiceEnable4All = 1;
const size_t fileUpdateChoiceDisable = 2;
INT_PTR CALLBACK SettingsDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM)
{
NppParameters *pNppParam = NppParameters::getInstance();
@ -879,24 +882,30 @@ INT_PTR CALLBACK SettingsDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM)
{
case WM_INITDIALOG :
{
::SendDlgItemMessage(_hSelf, IDC_COMBO_FILEUPDATECHOICE, CB_ADDSTRING, 0, reinterpret_cast<LPARAM>(TEXT("Enable")));
::SendDlgItemMessage(_hSelf, IDC_COMBO_FILEUPDATECHOICE, CB_ADDSTRING, 0, reinterpret_cast<LPARAM>(TEXT("Enable with all opened files")));
::SendDlgItemMessage(_hSelf, IDC_COMBO_FILEUPDATECHOICE, CB_ADDSTRING, 0, reinterpret_cast<LPARAM>(TEXT("Disable")));
int selIndex = -1;
if (nppGUI._fileAutoDetection & cdEnabledOld)
{
::SendDlgItemMessage(_hSelf, IDC_CHECK_FILEAUTODETECTION_ALL, BM_SETCHECK, BST_CHECKED, 0);
::SendDlgItemMessage(_hSelf, IDC_CHECK_FILEAUTODETECTION_CURRENT, BM_SETCHECK, BST_UNCHECKED, 0);
::EnableWindow(::GetDlgItem(_hSelf, IDC_CHECK_FILEAUTODETECTION_CURRENT), FALSE);
selIndex = fileUpdateChoiceEnable4All;
}
else if (nppGUI._fileAutoDetection & cdEnabledNew)
{
::SendDlgItemMessage(_hSelf, IDC_CHECK_FILEAUTODETECTION_CURRENT, BM_SETCHECK, BST_CHECKED, 0);
::SendDlgItemMessage(_hSelf, IDC_CHECK_FILEAUTODETECTION_ALL, BM_SETCHECK, BST_UNCHECKED, 0);
::EnableWindow(::GetDlgItem(_hSelf, IDC_CHECK_FILEAUTODETECTION_ALL), FALSE);
selIndex = fileUpdateChoiceEnable;
}
else //cdDisabled
{
::EnableWindow(::GetDlgItem(_hSelf, IDC_CHECK_UPDATESILENTLY), FALSE);
::EnableWindow(::GetDlgItem(_hSelf, IDC_CHECK_UPDATEGOTOEOF), FALSE);
selIndex = fileUpdateChoiceDisable;
}
::SendDlgItemMessage(_hSelf, IDC_COMBO_FILEUPDATECHOICE, CB_SETCURSEL, selIndex, 0);
bool bCheck = (nppGUI._fileAutoDetection & cdAutoUpdate) ? true : false;
::SendDlgItemMessage(_hSelf, IDC_CHECK_UPDATESILENTLY, BM_SETCHECK, bCheck? BST_CHECKED: BST_UNCHECKED, 0);
@ -973,54 +982,19 @@ INT_PTR CALLBACK SettingsDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM)
switch (wParam)
{
case IDC_CHECK_FILEAUTODETECTION_ALL:
case IDC_CHECK_FILEAUTODETECTION_CURRENT:
{
bool isAllChecked = isCheckedOrNot(IDC_CHECK_FILEAUTODETECTION_ALL);
bool isCurrentChecked = isCheckedOrNot(IDC_CHECK_FILEAUTODETECTION_CURRENT);
::EnableWindow(::GetDlgItem(_hSelf, IDC_CHECK_UPDATESILENTLY), isAllChecked | isCurrentChecked);
::EnableWindow(::GetDlgItem(_hSelf, IDC_CHECK_UPDATEGOTOEOF), isAllChecked | isCurrentChecked);
::EnableWindow(::GetDlgItem(_hSelf, IDC_CHECK_FILEAUTODETECTION_ALL), !isCurrentChecked);
::EnableWindow(::GetDlgItem(_hSelf, IDC_CHECK_FILEAUTODETECTION_CURRENT), !isAllChecked);
bool isSilent = isCheckedOrNot(IDC_CHECK_UPDATESILENTLY);
bool isGo2End = isCheckedOrNot(IDC_CHECK_UPDATEGOTOEOF);
int cd = cdDisabled;
if (isAllChecked | isCurrentChecked)
{
if (isAllChecked)
cd |= cdEnabledOld;
else
cd |= cdEnabledNew;
if (isSilent)
cd |= cdAutoUpdate;
if (isGo2End)
cd |= cdGo2end;
}
nppGUI._fileAutoDetection = cd;
}
return TRUE;
case IDC_CHECK_UPDATESILENTLY:
case IDC_CHECK_UPDATEGOTOEOF:
{
bool isSilent = isCheckedOrNot(IDC_CHECK_UPDATESILENTLY);
bool isGo2End = isCheckedOrNot(IDC_CHECK_UPDATEGOTOEOF);
bool isAllChecked = isCheckedOrNot(IDC_CHECK_FILEAUTODETECTION_ALL);
bool isCurrentChecked = isCheckedOrNot(IDC_CHECK_FILEAUTODETECTION_CURRENT);
auto index = ::SendDlgItemMessage(_hSelf, IDC_COMBO_FILEUPDATECHOICE, CB_GETCURSEL, 0, 0);
int cd = cdDisabled;
if (isAllChecked | isCurrentChecked)
if (index == fileUpdateChoiceEnable || index == fileUpdateChoiceEnable4All)
{
if (isAllChecked)
if (index == fileUpdateChoiceEnable4All)
cd |= cdEnabledOld;
else
cd |= cdEnabledNew;
@ -1117,6 +1091,49 @@ INT_PTR CALLBACK SettingsDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM)
nppGUI._isDocPeekOnMap = isCheckedOrNot(IDC_CHECK_ENABLEDOCPEEKONMAP);
return TRUE;
}
default:
{
if (HIWORD(wParam) == CBN_SELCHANGE)
{
if (LOWORD(wParam) == IDC_COMBO_FILEUPDATECHOICE)
{
auto index = ::SendDlgItemMessage(_hSelf, IDC_COMBO_FILEUPDATECHOICE, CB_GETCURSEL, 0, 0);
if (index == fileUpdateChoiceEnable || index == fileUpdateChoiceEnable4All)
{
bool isSilent = isCheckedOrNot(IDC_CHECK_UPDATESILENTLY);
bool isGo2End = isCheckedOrNot(IDC_CHECK_UPDATEGOTOEOF);
int cd = cdDisabled;
if (index == fileUpdateChoiceEnable4All)
cd |= cdEnabledOld;
else
cd |= cdEnabledNew;
if (isSilent)
cd |= cdAutoUpdate;
if (isGo2End)
cd |= cdGo2end;
nppGUI._fileAutoDetection = cd;
::EnableWindow(::GetDlgItem(_hSelf, IDC_CHECK_UPDATESILENTLY), TRUE);
::EnableWindow(::GetDlgItem(_hSelf, IDC_CHECK_UPDATEGOTOEOF), TRUE);
}
else if (index == fileUpdateChoiceDisable)
{
::EnableWindow(::GetDlgItem(_hSelf, IDC_CHECK_UPDATESILENTLY), FALSE);
::EnableWindow(::GetDlgItem(_hSelf, IDC_CHECK_UPDATEGOTOEOF), FALSE);
nppGUI._fileAutoDetection = cdDisabled;
}
return TRUE;
}
}
}
}
}
}

View File

@ -162,14 +162,12 @@
#define IDC_HISTORY_GB_STATIC (IDD_PREFERENCE_SETTING_BOX + 4)
#define IDC_CHECK_DONTCHECKHISTORY (IDD_PREFERENCE_SETTING_BOX + 5)
#define IDC_MAXNBFILE_STATIC (IDD_PREFERENCE_SETTING_BOX + 6)
#define IDC_CHECK_FILEAUTODETECTION_ALL (IDD_PREFERENCE_SETTING_BOX + 7)
#define IDC_CHECK_MIN2SYSTRAY (IDD_PREFERENCE_SETTING_BOX + 8)
#define IDC_CHECK_REMEMBERSESSION (IDD_PREFERENCE_SETTING_BOX + 9)
#define IDC_TABSIZEVAL_STATIC (IDD_PREFERENCE_SETTING_BOX + 10)
#define IDC_MAXNBFILEVAL_STATIC (IDD_PREFERENCE_SETTING_BOX + 11)
#define IDC_FILEAUTODETECTION_STATIC (IDD_PREFERENCE_SETTING_BOX + 12)
#define IDC_CHECK_UPDATESILENTLY (IDD_PREFERENCE_SETTING_BOX + 13)
#define IDC_CHECK_FILEAUTODETECTION_CURRENT (IDD_PREFERENCE_SETTING_BOX + 14)
#define IDC_RADIO_BKNONE (IDD_PREFERENCE_SETTING_BOX + 15)
#define IDC_RADIO_BKSIMPLE (IDD_PREFERENCE_SETTING_BOX + 16)
#define IDC_RADIO_BKVERBOSE (IDD_PREFERENCE_SETTING_BOX + 17)
@ -205,6 +203,7 @@
#define IDC_DOCUMENTPEEK_STATIC (IDD_PREFERENCE_SETTING_BOX + 44)
#define IDC_CHECK_ENABLEDOCPEEKER (IDD_PREFERENCE_SETTING_BOX + 45)
#define IDC_CHECK_ENABLEDOCPEEKONMAP (IDD_PREFERENCE_SETTING_BOX + 46)
#define IDC_COMBO_FILEUPDATECHOICE (IDD_PREFERENCE_SETTING_BOX + 47)
#define IDD_PREFERENCE_NEWDOCSETTING_BOX 6400 //(IDD_PREFERENCE_BOX + 400)

View File

@ -1090,6 +1090,50 @@ bool NativeLangSpeaker::changeDlgLang(HWND hDlg, const char *dlgTagName, char *t
}
}
}
// Set the text of child control
for (TiXmlNodeA *childNode = dlgNode->FirstChildElement("ComboBox");
childNode;
childNode = childNode->NextSibling("ComboBox"))
{
std::vector<generic_string> comboElms;
TiXmlElementA *element = childNode->ToElement();
int id;
element->Attribute("id", &id);
HWND hCombo = ::GetDlgItem(hDlg, id);
if (hCombo)
{
for (TiXmlNodeA *gChildNode = childNode->FirstChildElement("Element");
gChildNode;
gChildNode = gChildNode->NextSibling("Element"))
{
TiXmlElementA *comBoelement = gChildNode->ToElement();
const char *name = comBoelement->Attribute("name");
const wchar_t *nameW = wmc->char2wchar(name, _nativeLangEncoding);
comboElms.push_back(nameW);
}
}
size_t count = ::SendMessage(hCombo, CB_GETCOUNT, 0, 0);
if (count == comboElms.size())
{
// get selected index
auto selIndex = ::SendMessage(hCombo, CB_GETCURSEL, 0, 0);
// remove all old items
::SendMessage(hCombo, CB_RESETCONTENT, 0, 0);
// add translated entries
for (const auto& i : comboElms)
{
::SendMessage(hCombo, CB_ADDSTRING, 0, reinterpret_cast<LPARAM>(i.c_str()));
}
// restore selected index
::SendMessage(hCombo, CB_SETCURSEL, selIndex, 0);
}
}
return true;
}