summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2021-06-10 16:29:02 +0300
committerGeorge Hazan <ghazan@miranda.im>2021-06-10 16:29:02 +0300
commitc6519db3afea05236cd41a144110a8a74f3daa96 (patch)
treea30afee305efb54be06a4b7bf1fafdbc6f2ce9ce /src
parent2ad5c23a591fb5aa4c34f1148ee565cc015d1384 (diff)
fixes #2914 (unified empty history menu items)
Diffstat (limited to 'src')
-rw-r--r--src/mir_app/src/chat_svc.cpp5
-rw-r--r--src/mir_app/src/srmm_statusicon.cpp39
-rw-r--r--src/mir_app/src/stdafx.h1
3 files changed, 44 insertions, 1 deletions
diff --git a/src/mir_app/src/chat_svc.cpp b/src/mir_app/src/chat_svc.cpp
index c08fe1cc98..c831ea9c7e 100644
--- a/src/mir_app/src/chat_svc.cpp
+++ b/src/mir_app/src/chat_svc.cpp
@@ -42,7 +42,9 @@ static HANDLE
hEventDoubleclicked = nullptr,
hEventJoinChat = nullptr,
hEventLeaveChat = nullptr,
- hHookEvent = nullptr;
+ hHookEvent = nullptr;
+
+void SrmmModulesLoaded();
/////////////////////////////////////////////////////////////////////////////////////////
// Post-load event hooks
@@ -808,6 +810,7 @@ static int PrebuildContactMenu(WPARAM hContact, LPARAM)
static int ModulesLoaded(WPARAM, LPARAM)
{
+ SrmmModulesLoaded();
LoadChatIcons();
HookEvent(ME_SMILEYADD_OPTIONSCHANGED, SmileyOptionsChanged);
diff --git a/src/mir_app/src/srmm_statusicon.cpp b/src/mir_app/src/srmm_statusicon.cpp
index b3686575ad..e02f9fc306 100644
--- a/src/mir_app/src/srmm_statusicon.cpp
+++ b/src/mir_app/src/srmm_statusicon.cpp
@@ -266,12 +266,51 @@ void KillModuleSrmmIcons(HPLUGIN pPlugin)
arIcons.removeItem(&it);
}
+/////////////////////////////////////////////////////////////////////////////////////////
+
+static HGENMENU hmiEmpty;
+
+static INT_PTR svcEmptyHistory(WPARAM hContact, LPARAM)
+{
+ if (IDYES != MessageBoxW(nullptr, TranslateT("Are you sure to remove all events from history?"), L"Miranda", MB_YESNOCANCEL | MB_ICONQUESTION))
+ return 1;
+
+ DB::ECPTR pCursor(DB::Events(hContact));
+ while (pCursor.FetchNext())
+ pCursor.DeleteEvent();
+ return 0;
+}
+
+static int OnPrebuildContactMenu(WPARAM hContact, LPARAM)
+{
+ Menu_ShowItem(hmiEmpty, db_event_first(hContact) != 0);
+ return 0;
+}
+
+void SrmmModulesLoaded()
+{
+ // menu item
+ CMenuItem mi(&g_plugin);
+ SET_UID(mi, 0x0d4306aa, 0xe31e, 0x46ee, 0x89, 0x88, 0x3a, 0x2e, 0x05, 0xa6, 0xf3, 0xbc);
+ mi.pszService = MS_HISTORY_EMPTY;
+ mi.name.a = LPGEN("Empty history");
+ mi.position = 1000090001;
+ mi.hIcon = Skin_LoadIcon(SKINICON_OTHER_DELETE);
+ hmiEmpty = Menu_AddContactMenuItem(&mi);
+
+ HookEvent(ME_CLIST_PREBUILDCONTACTMENU, OnPrebuildContactMenu);
+}
+
+/////////////////////////////////////////////////////////////////////////////////////////
+
int LoadSrmmModule()
{
g_hCurHyperlinkHand = LoadCursor(nullptr, IDC_HAND);
LoadSrmmToolbarModule();
+ CreateServiceFunction(MS_HISTORY_EMPTY, svcEmptyHistory);
+
hHookSrmmEvent = CreateHookableEvent(ME_MSG_WINDOWEVENT);
hHookIconsChanged = CreateHookableEvent(ME_MSG_ICONSCHANGED);
hHookIconPressedEvt = CreateHookableEvent(ME_MSG_ICONPRESSED);
diff --git a/src/mir_app/src/stdafx.h b/src/mir_app/src/stdafx.h
index 890c13c082..db5ce33430 100644
--- a/src/mir_app/src/stdafx.h
+++ b/src/mir_app/src/stdafx.h
@@ -75,6 +75,7 @@ typedef struct SslHandle *HSSL;
#include <m_file.h>
#include <m_findadd.h>
#include <m_gui.h>
+#include <m_history.h>
#include <m_hpp.h>
#include <m_icolib.h>
#include <m_idle.h>