diff options
author | George Hazan <george.hazan@gmail.com> | 2024-09-11 19:52:52 +0300 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2024-09-11 19:52:52 +0300 |
commit | 02bb82c1c0a4031e7b2f5578370fa5acd620f8e1 (patch) | |
tree | c18da4f063f47fc89cd2d57a5184bb15b7a135fb /src | |
parent | 120b68869dab681e9c2360cd2b3905ee3a7ecf4a (diff) |
fixes #4653 (Плагины сообщений: невозможно удалить имя группы чатов)
Diffstat (limited to 'src')
-rw-r--r-- | src/core/stdmsg/res/resource.rc | 44 | ||||
-rw-r--r-- | src/core/stdmsg/src/chat_options.cpp | 30 | ||||
-rw-r--r-- | src/core/stdmsg/src/resource.h | 1 | ||||
-rw-r--r-- | src/mir_app/src/chat_clist.cpp | 28 | ||||
-rw-r--r-- | src/mir_app/src/chat_svc.cpp | 2 | ||||
-rw-r--r-- | src/mir_app/src/chat_tools.cpp | 4 |
6 files changed, 57 insertions, 52 deletions
diff --git a/src/core/stdmsg/res/resource.rc b/src/core/stdmsg/res/resource.rc index 52d4c4731e..fc41cbb773 100644 --- a/src/core/stdmsg/res/resource.rc +++ b/src/core/stdmsg/res/resource.rc @@ -88,8 +88,8 @@ BEGIN CONTROL "",IDC_SPLITTERY,"Static",SS_ENHMETAFILE,0,108,251,1
LISTBOX IDC_SRMM_NICKLIST,182,2,69,94,LBS_OWNERDRAWFIXED | LBS_HASSTRINGS | LBS_NOINTEGRALHEIGHT | NOT WS_BORDER | WS_VSCROLL | WS_TABSTOP,WS_EX_STATICEDGE
CONTROL "",IDC_AVATAR,"Button",BS_OWNERDRAW | NOT WS_VISIBLE,1,127,6,13
- CONTROL "",IDC_SRMM_QUOTE,"RichEdit50W",ES_AUTOHSCROLL | WS_DISABLED | WS_BORDER | WS_TABSTOP,0,95,235,16
- CONTROL "",IDC_SRMM_CLOSEQUOTE,"MButtonClass", WS_TABSTOP,237,97,16,16
+ CONTROL "",IDC_SRMM_QUOTE,"RichEdit50W",WS_DISABLED | WS_BORDER | WS_TABSTOP | 0x80,0,95,235,16
+ CONTROL "",IDC_SRMM_CLOSEQUOTE,"MButtonClass",WS_TABSTOP,237,97,16,16
END
IDD_OPT_MSGHIST DIALOGEX 0, 0, 311, 171
@@ -192,8 +192,10 @@ STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD EXSTYLE WS_EX_CONTROLPARENT
FONT 8, "MS Shell Dlg", 0, 0, 0x1
BEGIN
- CONTROL "",IDC_CHECKBOXES,"SysTreeView32",TVS_DISABLEDRAGDROP | WS_HSCROLL | WS_TABSTOP,10,12,280,205
- GROUPBOX "Options",IDC_STATIC,0,0,300,227
+ CONTROL "",IDC_CHECKBOXES,"SysTreeView32",TVS_DISABLEDRAGDROP | WS_HSCROLL | WS_TABSTOP,6,11,287,188
+ GROUPBOX "Options",IDC_STATIC,0,0,300,206
+ CONTROL "Add new rooms to group:",IDC_CHAT_USEGROUP,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,8,213,186,8
+ EDITTEXT IDC_GROUP,202,211,93,12,ES_AUTOHSCROLL
END
IDD_OPTIONS2 DIALOGEX 0, 0, 300, 200
@@ -225,11 +227,9 @@ BEGIN EDITTEXT IDC_LIMIT,248,114,38,14,ES_RIGHT | ES_AUTOHSCROLL | ES_NUMBER
CONTROL "Spin1",IDC_SPIN3,"msctls_updown32",UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_ARROWKEYS | UDS_NOTHOUSANDS | UDS_HOTTRACK,275,114,11,14
GROUPBOX "Other",IDC_STATIC,1,145,294,53
- LTEXT "Add new rooms to group:",IDC_STATIC,11,159,132,8
- EDITTEXT IDC_GROUP,158,158,49,14,ES_AUTOHSCROLL
- LTEXT "Nick list row distance (pixels):",IDC_STATIC,11,180,140,8
- EDITTEXT IDC_NICKROW2,158,178,29,14,ES_RIGHT | ES_AUTOHSCROLL | ES_NUMBER
- CONTROL "",IDC_SPIN4,"msctls_updown32",UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_ARROWKEYS | UDS_NOTHOUSANDS | UDS_HOTTRACK,183,178,11,14
+ LTEXT "Nick list row distance (pixels):",IDC_STATIC,11,158,140,8
+ EDITTEXT IDC_NICKROW2,158,156,29,14,ES_RIGHT | ES_AUTOHSCROLL | ES_NUMBER
+ CONTROL "",IDC_SPIN4,"msctls_updown32",UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_ARROWKEYS | UDS_NOTHOUSANDS | UDS_HOTTRACK,183,156,11,14
END
@@ -297,35 +297,14 @@ BEGIN IDD_OPTIONS1, DIALOG
BEGIN
- VERTGUIDE, 10
- VERTGUIDE, 153
- VERTGUIDE, 181
- VERTGUIDE, 202
- VERTGUIDE, 290
- HORZGUIDE, 12
- HORZGUIDE, 174
- HORZGUIDE, 192
- HORZGUIDE, 213
END
IDD_OPTIONS2, DIALOG
BEGIN
LEFTMARGIN, 1
RIGHTMARGIN, 295
- VERTGUIDE, 10
- VERTGUIDE, 60
- VERTGUIDE, 144
- VERTGUIDE, 158
- VERTGUIDE, 183
- VERTGUIDE, 221
- VERTGUIDE, 286
TOPMARGIN, 1
BOTTOMMARGIN, 198
- HORZGUIDE, 108
- HORZGUIDE, 126
- HORZGUIDE, 146
- HORZGUIDE, 158
- HORZGUIDE, 174
END
END
#endif // APSTUDIO_INVOKED
@@ -535,6 +514,11 @@ BEGIN 0
END
+IDD_OPTIONS1 AFX_DIALOG_LAYOUT
+BEGIN
+ 0
+END
+
#endif // English (United States) resources
/////////////////////////////////////////////////////////////////////////////
diff --git a/src/core/stdmsg/src/chat_options.cpp b/src/core/stdmsg/src/chat_options.cpp index 2518807485..9755a3218c 100644 --- a/src/core/stdmsg/src/chat_options.cpp +++ b/src/core/stdmsg/src/chat_options.cpp @@ -91,13 +91,20 @@ class COptMainDlg : public CChatOptionsBaseDlg { uint32_t m_dwFlags; + CCtrlEdit edtGroup; + CCtrlCheck chkUseGroup; CCtrlTreeOpts checkBoxes; public: COptMainDlg() : CChatOptionsBaseDlg(IDD_OPTIONS1), - checkBoxes(this, IDC_CHECKBOXES) + edtGroup(this, IDC_GROUP), + checkBoxes(this, IDC_CHECKBOXES), + chkUseGroup(this, IDC_CHAT_USEGROUP) { + CreateLink(chkUseGroup, Chat::bUseGroup); + chkUseGroup.OnChange = Callback(this, &COptMainDlg::onChange_UseGroup); + m_dwFlags = db_get_dw(0, CHAT_MODULE, "IconFlags"); auto *pwszSection = TranslateT("Appearance and functionality of chat room windows"); @@ -135,11 +142,23 @@ public: checkBoxes.AddOption(pwszSection, TranslateT("Show icon for status changes"), m_dwFlags, GC_EVENT_ADDSTATUS); } + bool OnInitDialog() override + { + edtGroup.SetText(Chat_GetGroup()); + return true; + } + bool OnApply() override { + Chat_SetGroup(ptrW(rtrimw(edtGroup.GetText()))); db_set_dw(0, CHAT_MODULE, "IconFlags", m_dwFlags); return true; } + + void onChange_UseGroup(CCtrlCheck *) + { + edtGroup.Enable(chkUseGroup.IsChecked()); + } }; ///////////////////////////////////////////////////////////////////////////////////////// @@ -163,7 +182,7 @@ static INT CALLBACK BrowseCallbackProc(HWND hwnd, UINT uMsg, LPARAM lp, LPARAM p class COptLogDlg : public CChatOptionsBaseDlg { - CCtrlEdit edtGroup, edtLogDir, edtLogTimestamp, edtTimestamp, edtHighlight, edtInStamp, edtOutStamp, edtLimit; + CCtrlEdit edtLogDir, edtLogTimestamp, edtTimestamp, edtHighlight, edtInStamp, edtOutStamp, edtLimit; CCtrlSpin spin2, spin3, spin4; CCtrlCheck chkLogging, chkHighlight; CCtrlButton btnFontChoose; @@ -175,7 +194,6 @@ public: spin3(this, IDC_SPIN3, 10000), spin4(this, IDC_SPIN4, 255, 10), - edtGroup(this, IDC_GROUP), edtLimit(this, IDC_LIMIT), edtLogDir(this, IDC_LOGDIRECTORY), edtInStamp(this, IDC_INSTAMP), @@ -186,7 +204,7 @@ public: chkLogging(this, IDC_LOGGING), chkHighlight(this, IDC_HIGHLIGHT), - + btnFontChoose(this, IDC_FONTCHOOSE) { chkLogging.OnChange = Callback(this, &COptLogDlg::onChange_Logging); @@ -201,8 +219,6 @@ public: spin3.SetPosition(db_get_w(0, CHAT_MODULE, "LoggingLimit", 100)); spin4.SetPosition(db_get_b(0, CHAT_MODULE, "NicklistRowDist", 12)); - edtGroup.SetText(ptrW(Chat_GetGroup())); - wchar_t szTemp[MAX_PATH]; PathToRelativeW(g_Settings.pszLogDir, szTemp); edtLogDir.SetText(szTemp); @@ -261,8 +277,6 @@ public: else db_unset(0, CHAT_MODULE, "HeaderOutgoing"); - Chat_SetGroup(ptrW(rtrimw(edtGroup.GetText()))); - g_Settings.bHighlightEnabled = chkHighlight.GetState(); db_set_b(0, CHAT_MODULE, "HighlightEnabled", g_Settings.bHighlightEnabled); diff --git a/src/core/stdmsg/src/resource.h b/src/core/stdmsg/src/resource.h index aaefd5ce20..dbdb870663 100644 --- a/src/core/stdmsg/src/resource.h +++ b/src/core/stdmsg/src/resource.h @@ -106,6 +106,7 @@ #define IDC_RADIO2 1068
#define IDC_RADIO3 1069
#define IDC_ADD 1070
+#define IDC_CHAT_USEGROUP 1071
#define IDC_TAB 1074
#define IDC_1 1075
#define IDC_2 1076
diff --git a/src/mir_app/src/chat_clist.cpp b/src/mir_app/src/chat_clist.cpp index 37e32e0d95..e01f1291ff 100644 --- a/src/mir_app/src/chat_clist.cpp +++ b/src/mir_app/src/chat_clist.cpp @@ -38,23 +38,16 @@ static MCONTACT FindRoom(const char *pszModule, const wchar_t *pszRoom) MCONTACT AddRoom(const char *pszModule, const wchar_t *pszRoom, const wchar_t *pszDisplayName, int iType)
{
- ptrW pwszGroup(Chat_GetGroup());
- if (mir_wstrlen(pwszGroup)) {
- MGROUP hGroup = Clist_GroupExists(pwszGroup);
- if (hGroup == 0) {
- hGroup = Clist_GroupCreate(0, pwszGroup);
- if (hGroup)
- Clist_GroupSetExpanded(hGroup, 1);
- }
- }
+ auto wszGroup(Chat_GetGroup());
+ bool bNeedGroup = Chat::bUseGroup && !wszGroup.IsEmpty();
MCONTACT hContact = FindRoom(pszModule, pszRoom);
if (hContact) {
// contact exists, let's assign the standard group name if it's missing
- if (mir_wstrlen(pwszGroup)) {
+ if (bNeedGroup) {
ptrW pwszOldGroup(Clist_GetGroup(hContact));
if (!mir_wstrlen(pwszOldGroup))
- Clist_SetGroup(hContact, pwszGroup);
+ Clist_SetGroup(hContact, wszGroup);
}
db_set_w(hContact, pszModule, "Status", ID_STATUS_OFFLINE);
@@ -67,7 +60,18 @@ MCONTACT AddRoom(const char *pszModule, const wchar_t *pszRoom, const wchar_t *p return 0;
Proto_AddToContact(hContact, pszModule);
- Clist_SetGroup(hContact, pwszGroup);
+
+ // create the 'Chat rooms' group only if needed
+ if (bNeedGroup) {
+ MGROUP hGroup = Clist_GroupExists(wszGroup);
+ if (hGroup == 0) {
+ hGroup = Clist_GroupCreate(0, wszGroup);
+ if (hGroup)
+ Clist_GroupSetExpanded(hGroup, 1);
+ }
+
+ Clist_SetGroup(hContact, wszGroup);
+ }
if (auto *pa = Proto_GetAccount(pszModule)) {
if (MBaseProto *pd = g_arProtos.find((MBaseProto *)&pa->szProtoName)) {
diff --git a/src/mir_app/src/chat_svc.cpp b/src/mir_app/src/chat_svc.cpp index 368cdd51e0..2bf0745e90 100644 --- a/src/mir_app/src/chat_svc.cpp +++ b/src/mir_app/src/chat_svc.cpp @@ -26,6 +26,8 @@ CMOption<bool> Chat::bShowNicklist(CHAT_MODULE, "ShowNicklist", true); CMOption<bool> Chat::bFilterEnabled(CHAT_MODULE, "FilterEnabled", false);
CMOption<bool> Chat::bTopicOnClist(CHAT_MODULE, "TopicOnClist", false);
CMOption<bool> Chat::bPopupOnJoin(CHAT_MODULE, "PopupOnJoin", false);
+CMOption<bool> Chat::bUseGroup(CHAT_MODULE, "UseGroup", true);
+
CMOption<bool> Chat::bDoubleClick4Privat(CHAT_MODULE, "DoubleClick4Privat", false);
CMOption<bool> Chat::bShowContactStatus(CHAT_MODULE, "ShowContactStatus", true);
CMOption<bool> Chat::bContactStatusFirst(CHAT_MODULE, "ContactStatusFirst", false);
diff --git a/src/mir_app/src/chat_tools.cpp b/src/mir_app/src/chat_tools.cpp index b9d2016103..66e8acbc6b 100644 --- a/src/mir_app/src/chat_tools.cpp +++ b/src/mir_app/src/chat_tools.cpp @@ -757,9 +757,9 @@ void Chat_EventToGC(SESSION_INFO *si, MEVENT hDbEvent) /////////////////////////////////////////////////////////////////////////////////////////
-MIR_APP_DLL(wchar_t*) Chat_GetGroup()
+MIR_APP_DLL(CMStringW) Chat_GetGroup()
{
- return db_get_wsa(0, CHAT_MODULE, "AddToGroup", TranslateT("Chat rooms"));
+ return db_get_wsm(0, CHAT_MODULE, "AddToGroup", TranslateT("Chat rooms"));
}
MIR_APP_DLL(void) Chat_SetGroup(const wchar_t *pwszGroupName)
|