From 13627600541c19643b96bd4c7b3a3d9fd92040f9 Mon Sep 17 00:00:00 2001
From: George Hazan <george.hazan@gmail.com>
Date: Fri, 29 Sep 2023 11:49:44 +0300
Subject: =?UTF-8?q?fixes=20#3694=20(tabSRMM:=20=D0=BF=D1=80=D0=B8=20=D0=B2?=
 =?UTF-8?q?=D1=8B=D0=B1=D0=BE=D1=80=D0=B5=20=D1=81=D1=82=D0=BE=D1=80=D0=BE?=
 =?UTF-8?q?=D0=BD=D0=BD=D0=B5=D0=B3=D0=BE=20=D0=B6=D1=83=D1=80=D0=BD=D0=B0?=
 =?UTF-8?q?=D0=BB=D0=B0=20=D0=BF=D1=80=D0=BE=D0=BF=D0=B0=D0=B4=D0=B0=D0=B5?=
 =?UTF-8?q?=D1=82=20=D0=B2=D0=BA=D0=BB=D0=B0=D0=B4=D0=BA=D0=B0=20"=D0=96?=
 =?UTF-8?q?=D1=83=D1=80=D0=BD=D0=B0=D0=BB")?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 src/core/stdmsg/res/resource.rc    | 30 +++++++++++++++++++++++++++---
 src/core/stdmsg/src/msgoptions.cpp | 12 +++++-------
 src/core/stdmsg/src/resource.h     |  1 +
 src/mir_app/src/lpopts.cpp         |  5 ++---
 src/mir_app/src/srmm_log.cpp       | 16 ++++++++++++++++
 5 files changed, 51 insertions(+), 13 deletions(-)

(limited to 'src')

diff --git a/src/core/stdmsg/res/resource.rc b/src/core/stdmsg/res/resource.rc
index 10b1b29c5c..806e68a489 100644
--- a/src/core/stdmsg/res/resource.rc
+++ b/src/core/stdmsg/res/resource.rc
@@ -81,15 +81,30 @@ EXSTYLE WS_EX_CONTROLPARENT
 FONT 8, "MS Shell Dlg", 0, 0, 0x1
 BEGIN
     CONTROL         "",IDC_SRMM_MESSAGE,"RichEdit50W",WS_VSCROLL | WS_TABSTOP | 0x1144,1,111,208,29,WS_EX_ACCEPTFILES | WS_EX_STATICEDGE
-	LTEXT           "", IDC_FRAME, 1, 111, 208, 29, NOT WS_VISIBLE | WS_CLIPSIBLINGS
+    LTEXT           "",IDC_FRAME,1,111,208,29,NOT WS_VISIBLE | WS_CLIPSIBLINGS
     DEFPUSHBUTTON   "&Send",IDOK,212,111,39,29
     CONTROL         "",IDC_SRMM_LOG,"RichEdit50W",WS_VSCROLL | WS_TABSTOP | 0x844,1,16,250,91,WS_EX_STATICEDGE
     CONTROL         "",IDC_SPLITTERX,"Static",SS_ENHMETAFILE,172,23,10,73
     CONTROL         "",IDC_SPLITTERY,"Static",SS_ENHMETAFILE,0,108,251,2
-    LISTBOX         IDC_SRMM_NICKLIST,182,2,69,94,LBS_OWNERDRAWFIXED | LBS_NOINTEGRALHEIGHT | LBS_HASSTRINGS | NOT WS_BORDER | WS_VSCROLL | WS_TABSTOP,WS_EX_STATICEDGE
+    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
 END
 
+IDD_OPT_MSGHIST DIALOGEX 0, 0, 311, 171
+STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD
+EXSTYLE WS_EX_CONTROLPARENT
+FONT 8, "MS Shell Dlg", 0, 0, 0x1
+BEGIN
+    CONTROL         "Load unread events only",IDC_LOADUNREAD,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,8,10,138,10
+    CONTROL         "Load number of previous events",IDC_LOADCOUNT,"Button",BS_AUTORADIOBUTTON,8,26,138,10
+    EDITTEXT        IDC_LOADCOUNTN,151,25,33,12,ES_RIGHT | ES_NUMBER | WS_DISABLED
+    CONTROL         "Spin1",IDC_LOADCOUNTSPIN,"msctls_updown32",UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_ARROWKEYS | UDS_NOTHOUSANDS | UDS_HOTTRACK | WS_DISABLED,185,25,11,12
+    CONTROL         "Load previous events less than",IDC_LOADTIME,"Button",BS_AUTORADIOBUTTON,8,42,141,10
+    EDITTEXT        IDC_LOADTIMEN,151,41,33,12,ES_RIGHT | ES_NUMBER | WS_DISABLED
+    CONTROL         "Spin1",IDC_LOADTIMESPIN,"msctls_updown32",UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_ARROWKEYS | UDS_NOTHOUSANDS | UDS_HOTTRACK | WS_DISABLED,184,39,11,12
+    LTEXT           "minutes old",IDC_STMINSOLD,189,41,82,8,WS_DISABLED
+END
+
 IDD_OPT_MSGLOG DIALOGEX 0, 0, 311, 171
 STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD
 EXSTYLE WS_EX_CONTROLPARENT
@@ -102,6 +117,7 @@ BEGIN
     CONTROL         "Show seconds",IDC_SHOWSECS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,19,53,268,10
     CONTROL         "Show dates",IDC_SHOWDATES,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,19,65,268,10
     CONTROL         "Show formatting",IDC_SHOWFORMATTING,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,8,77,280,10
+    CONTROL         "Automatically copy selected text",IDC_AUTOCOPY,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,8,90,280,10
     GROUPBOX        "Load history events",IDC_STATIC,4,110,303,52
     CONTROL         "Load unread events only",IDC_LOADUNREAD,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,8,122,138,10
     CONTROL         "Load number of previous events",IDC_LOADCOUNT,"Button",BS_AUTORADIOBUTTON,8,134,138,10
@@ -111,7 +127,6 @@ BEGIN
     EDITTEXT        IDC_LOADTIMEN,151,145,33,12,ES_RIGHT | ES_NUMBER | WS_DISABLED
     CONTROL         "Spin1",IDC_LOADTIMESPIN,"msctls_updown32",UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_ARROWKEYS | UDS_NOTHOUSANDS | UDS_HOTTRACK | WS_DISABLED,184,144,11,14
     LTEXT           "minutes old",IDC_STMINSOLD,189,147,82,8,WS_DISABLED
-    CONTROL         "Automatically copy selected text",IDC_AUTOCOPY,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,8,90,280,10
 END
 
 IDD_OPT_TABS DIALOGEX 0, 0, 283, 80
@@ -249,6 +264,10 @@ BEGIN
         HORZGUIDE, 53
     END
 
+    IDD_OPT_MSGHIST, DIALOG
+    BEGIN
+    END
+
     IDD_OPT_MSGLOG, DIALOG
     BEGIN
         BOTTOMMARGIN, 162
@@ -507,6 +526,11 @@ BEGIN
     0
 END
 
+IDD_OPT_MSGHIST AFX_DIALOG_LAYOUT
+BEGIN
+    0
+END
+
 #endif    // English (United States) resources
 /////////////////////////////////////////////////////////////////////////////
 
diff --git a/src/core/stdmsg/src/msgoptions.cpp b/src/core/stdmsg/src/msgoptions.cpp
index 5fa17a9e4e..40ceee7ff3 100644
--- a/src/core/stdmsg/src/msgoptions.cpp
+++ b/src/core/stdmsg/src/msgoptions.cpp
@@ -305,8 +305,8 @@ class COptionLogDlg : public CDlgBase
 	CCtrlSpin  spinCount, spinTime;
 
 public:
-	COptionLogDlg() :
-		CDlgBase(g_plugin, IDD_OPT_MSGLOG),
+	COptionLogDlg(int iDlgId) :
+		CDlgBase(g_plugin, iDlgId),
 		chkSecs(this, IDC_SHOWSECS),
 		chkDate(this, IDC_SHOWDATES),
 		chkTime(this, IDC_SHOWTIMES),
@@ -571,11 +571,9 @@ int OptInitialise(WPARAM wParam, LPARAM)
 	odp.pDialog = new COptionMainDlg();
 	g_plugin.addOptions(wParam, &odp);
 
-	if (!Srmm_IsCustomLogUsed()) {
-		odp.szTab.a = LPGEN("Messaging log");
-		odp.pDialog = new COptionLogDlg();
-		g_plugin.addOptions(wParam, &odp);
-	}
+	odp.szTab.a = LPGEN("Messaging log");
+	odp.pDialog = new COptionLogDlg(Srmm_IsCustomLogUsed() ? IDD_OPT_MSGHIST : IDD_OPT_MSGLOG);
+	g_plugin.addOptions(wParam, &odp);
 
 	odp.szTab.a = LPGEN("Typing notify");
 	odp.pDialog = new COptionTypingDlg();
diff --git a/src/core/stdmsg/src/resource.h b/src/core/stdmsg/src/resource.h
index e96fef18b4..e0436a8abd 100644
--- a/src/core/stdmsg/src/resource.h
+++ b/src/core/stdmsg/src/resource.h
@@ -9,6 +9,7 @@
 #define IDD_OPTIONSPOPUP                106
 #define IDD_CONTAINER                   107
 #define IDD_OPT_TABS                    108
+#define IDD_OPT_MSGHIST                 109
 #define IDI_BUNDERLINE                  120
 #define IDI_BBOLD                       121
 #define IDI_BITALICS                    122
diff --git a/src/mir_app/src/lpopts.cpp b/src/mir_app/src/lpopts.cpp
index 7444c8e1dc..24818c95b2 100644
--- a/src/mir_app/src/lpopts.cpp
+++ b/src/mir_app/src/lpopts.cpp
@@ -232,9 +232,8 @@ bool CLangpackDlg::OnApply()
 		ReloadLangpack(tszPath);
 		
 		if (m_bExiting) {
-			HWND hwndParent = GetParent(GetHwnd());
-			PostMessage(hwndParent, WM_CLOSE, 1, 0);
-			mir_forkthread(ReloadOptions, hwndParent);
+			PostMessage(m_hwndParent, WM_CLOSE, 1, 0);
+			mir_forkthread(ReloadOptions, m_hwndParent);
 		}
 	}
 	return true;
diff --git a/src/mir_app/src/srmm_log.cpp b/src/mir_app/src/srmm_log.cpp
index bbbcc7fac0..b91204a59c 100644
--- a/src/mir_app/src/srmm_log.cpp
+++ b/src/mir_app/src/srmm_log.cpp
@@ -106,6 +106,19 @@ MIR_APP_DLL(bool) Srmm_IsCustomLogUsed()
 /////////////////////////////////////////////////////////////////////////////////////////
 // options dialog
 
+static void CALLBACK OpenOptions(void *)
+{
+	g_plugin.openOptions(L"Message sessions", L"Log viewer");
+}
+
+static void ReloadOptions(void *hWnd)
+{
+	while (IsWindow((HWND)hWnd))
+		Sleep(50);
+
+	CallFunctionAsync(OpenOptions, nullptr);
+}
+
 static class CSrmmLogOptionsDlg *pDialog = nullptr;
 
 class CSrmmLogOptionsDlg : public CDlgBase
@@ -145,6 +158,9 @@ public:
 
 		if (auto *pLogger = (LoggerClass *)m_list.GetItemData(idx))
 			g_logger = pLogger->szShortName;
+
+		PostMessage(m_hwndParent, WM_CLOSE, 1, 0);
+		mir_forkthread(ReloadOptions, m_hwndParent);
 		return true;
 	}
 
-- 
cgit v1.2.3