Improve: multi-line keyword input in notification settings
Replace the single-line, semicolon-separated keyword field with a taller multi-line edit box (with a vertical scrollbar) where each keyword goes on its own line. The stored format stays semicolon-separated, so existing notify.ini files remain valid; load/save convert between newlines and semicolons, trimming each keyword and skipping empty lines. Also decode the stored matchPattern as UTF-8 when loading the dialog, so non-ASCII keywords round-trip correctly (matching the CP_UTF8 encoding used on save). Co-Authored-By: deepseek-v4-pro
This commit is contained in:
1 parent
f3a05c14b1
commit
8d0f419093
3 files changed
+39
-4
No files matched your search
Binary file not shown.
@@ -56,7 +56,7 @@ BOOL NotifySettingsDlg::OnInitDialog()
|
|||||||
SetDlgItemText(IDC_STATIC_TRIGGER, _TR(_T("触发条件:")));
|
SetDlgItemText(IDC_STATIC_TRIGGER, _TR(_T("触发条件:")));
|
||||||
SetDlgItemText(IDC_STATIC_MATCH_COLUMN, _TR(_T("匹配列:")));
|
SetDlgItemText(IDC_STATIC_MATCH_COLUMN, _TR(_T("匹配列:")));
|
||||||
SetDlgItemText(IDC_STATIC_KEYWORDS, _TR(_T("关键词:")));
|
SetDlgItemText(IDC_STATIC_KEYWORDS, _TR(_T("关键词:")));
|
||||||
SetDlgItemText(IDC_STATIC_KEYWORDS_HINT, _TR(_T("(多个关键词用分号分隔,匹配任一项即触发通知)")));
|
SetDlgItemText(IDC_STATIC_KEYWORDS_HINT, _TR(_T("(每行一个关键词,匹配任一项即触发通知)")));
|
||||||
SetDlgItemText(IDC_STATIC_NOTIFY_TIP, _TR(_T("提示: 同一主机 60 分钟内仅通知一次")));
|
SetDlgItemText(IDC_STATIC_NOTIFY_TIP, _TR(_T("提示: 同一主机 60 分钟内仅通知一次")));
|
||||||
SetDlgItemText(IDOK, _TR("确定"));
|
SetDlgItemText(IDOK, _TR("确定"));
|
||||||
SetDlgItemText(IDCANCEL, _TR("取消"));
|
SetDlgItemText(IDCANCEL, _TR("取消"));
|
||||||
@@ -154,7 +154,24 @@ void NotifySettingsDlg::LoadSettings()
|
|||||||
m_comboNotifyColumn.SetCurSel(rule.columnIndex);
|
m_comboNotifyColumn.SetCurSel(rule.columnIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
m_editNotifyPattern.SetWindowText(CString(rule.matchPattern.c_str()));
|
// Display stored semicolon-separated keywords as one keyword per line.
|
||||||
|
{
|
||||||
|
CString pattern;
|
||||||
|
const CString stored(CA2T(rule.matchPattern.c_str(), CP_UTF8));
|
||||||
|
int start = 0;
|
||||||
|
for (;;) {
|
||||||
|
const int pos = stored.Find(_T(';'), start);
|
||||||
|
CString kw = (pos < 0) ? stored.Mid(start) : stored.Mid(start, pos - start);
|
||||||
|
kw.Trim();
|
||||||
|
if (!kw.IsEmpty()) {
|
||||||
|
if (!pattern.IsEmpty()) pattern += _T("\r\n");
|
||||||
|
pattern += kw;
|
||||||
|
}
|
||||||
|
if (pos < 0) break;
|
||||||
|
start = pos + 1;
|
||||||
|
}
|
||||||
|
m_editNotifyPattern.SetWindowText(pattern);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void NotifySettingsDlg::SaveSettings()
|
void NotifySettingsDlg::SaveSettings()
|
||||||
@@ -189,8 +206,26 @@ void NotifySettingsDlg::SaveSettings()
|
|||||||
sel = m_comboNotifyColumn.GetCurSel();
|
sel = m_comboNotifyColumn.GetCurSel();
|
||||||
rule.columnIndex = (sel >= 0) ? (int)m_comboNotifyColumn.GetItemData(sel) : ONLINELIST_COMPUTER_NAME;
|
rule.columnIndex = (sel >= 0) ? (int)m_comboNotifyColumn.GetItemData(sel) : ONLINELIST_COMPUTER_NAME;
|
||||||
|
|
||||||
|
// Normalize one-keyword-per-line input back to semicolon-separated storage.
|
||||||
m_editNotifyPattern.GetWindowText(str);
|
m_editNotifyPattern.GetWindowText(str);
|
||||||
rule.matchPattern = CT2A(str, CP_UTF8);
|
str.Replace(_T("\r\n"), _T("\n"));
|
||||||
|
str.Replace(_T('\r'), _T('\n'));
|
||||||
|
{
|
||||||
|
CString joined;
|
||||||
|
int start = 0;
|
||||||
|
for (;;) {
|
||||||
|
const int pos = str.Find(_T('\n'), start);
|
||||||
|
CString kw = (pos < 0) ? str.Mid(start) : str.Mid(start, pos - start);
|
||||||
|
kw.Trim();
|
||||||
|
if (!kw.IsEmpty()) {
|
||||||
|
if (!joined.IsEmpty()) joined += _T(';');
|
||||||
|
joined += kw;
|
||||||
|
}
|
||||||
|
if (pos < 0) break;
|
||||||
|
start = pos + 1;
|
||||||
|
}
|
||||||
|
rule.matchPattern = CT2A(joined, CP_UTF8);
|
||||||
|
}
|
||||||
|
|
||||||
// Update manager config and save
|
// Update manager config and save
|
||||||
GetNotifyManager().SetConfig(m_config);
|
GetNotifyManager().SetConfig(m_config);
|
||||||
|
|||||||
@@ -1493,7 +1493,7 @@ SMTP
|
|||||||
触发条件:=Trigger:
|
触发条件:=Trigger:
|
||||||
匹配列:=Match Column:
|
匹配列:=Match Column:
|
||||||
关键词:=Keywords:
|
关键词:=Keywords:
|
||||||
(多个关键词用分号分隔,匹配任一项即触发通知)=(Multiple keywords separated by semicolon)
|
(每行一个关键词,匹配任一项即触发通知)=(One keyword per line)
|
||||||
提示: 同一主机 60 分钟内仅通知一次=Tip: Same host notified only once per 60 minutes
|
提示: 同一主机 60 分钟内仅通知一次=Tip: Same host notified only once per 60 minutes
|
||||||
主机上线=Host Online
|
主机上线=Host Online
|
||||||
IP地址=IP Address
|
IP地址=IP Address
|
||||||
|
|||||||
Reference in new issue
Block a user