From c6519db3afea05236cd41a144110a8a74f3daa96 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Thu, 10 Jun 2021 16:29:02 +0300 Subject: fixes #2914 (unified empty history menu items) --- src/mir_app/src/chat_svc.cpp | 5 ++++- src/mir_app/src/srmm_statusicon.cpp | 39 +++++++++++++++++++++++++++++++++++++ src/mir_app/src/stdafx.h | 1 + 3 files changed, 44 insertions(+), 1 deletion(-) (limited to 'src') 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 #include #include +#include #include #include #include -- cgit v1.2.3