From 827327682d75718dea04ff0ede7b46cb746d2ec5 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Sat, 20 Feb 2021 15:18:40 +0300 Subject: fixes #2747 (unified System History menu item creation) --- plugins/HistoryPlusPlus/historypp.dpr | 59 ++++++++++------------------------ plugins/IEHistory/src/IEHistory.cpp | 5 --- plugins/NewStory/src/history.cpp | 12 ------- plugins/NewStory/src/history.h | 1 - plugins/NewStory/src/history_menus.cpp | 11 +------ src/mir_app/src/menu_clist.cpp | 11 ++++++- 6 files changed, 28 insertions(+), 71 deletions(-) diff --git a/plugins/HistoryPlusPlus/historypp.dpr b/plugins/HistoryPlusPlus/historypp.dpr index d12fae42a4..68006d6a92 100644 --- a/plugins/HistoryPlusPlus/historypp.dpr +++ b/plugins/HistoryPlusPlus/historypp.dpr @@ -67,31 +67,14 @@ uses hpp_JclSysUtils in 'hpp_JclSysUtils.pas', hpp_puny in 'hpp_puny.pas'; -type - TMenuHandles = record - Handle: THandle; - Name: pWideChar; - end; - -const - miContact = 0; - miSystem = 1; - miSearch = 2; - miEmpty = 3; - miSysEmpty = 4; - var MenuCount: Integer = -1; PrevShowHistoryCount: Boolean = False; - MenuHandles: array[0..4] of TMenuHandles = ( - (Handle:0; Name:'View &History'), - (Handle:0; Name:'&System History'), - (Handle:0; Name:'His&tory Search'), - (Handle:0; Name:'&Empty History'), - (Handle:0; Name:'&Empty System History')); + hmiEmpty, hmiContact: THandle; const hLangpack:THANDLE = 0; + histName:PWideChar = 'View &History'; var HookModulesLoad, @@ -234,42 +217,34 @@ begin SET_UID(@menuItem, '806B9223-0522-4B6B-AB2C-666D76C45D59'); menuItem.Position := 1000090000; - menuItem.szName.w := MenuHandles[miContact].Name; + menuItem.szName.w := histName; menuItem.pszService := MS_HISTORY_SHOWCONTACTHISTORY; menuItem.hIcon := hppIcons[HPP_ICON_CONTACTHISTORY].handle; - MenuHandles[miContact].Handle := Menu_AddContactMenuItem(@menuItem); + hmiContact := Menu_AddContactMenuItem(@menuItem); // create empty item in contact menu SET_UID(@menuItem, 'BA23B260-0AF7-4336-9703-D47C9AD7B1B0'); menuItem.Position := 1000090001; - menuItem.szName.w := MenuHandles[miEmpty].Name; + menuItem.szName.w := '&Empty History'; menuItem.pszService := MS_HPP_EMPTYHISTORY; menuItem.hIcon := hppIcons[HPP_ICON_TOOL_DELETEALL].handle; - MenuHandles[miEmpty].Handle := Menu_AddContactMenuItem(@menuItem); - - // create menu item in main menu for system history - SET_UID(@menuItem, 'A08805DD-7402-472D-BB46-0C702D03423A'); - menuItem.Position:=500060000; - menuItem.szName.w:=MenuHandles[miSystem].Name; - menuItem.pszService := MS_HISTORY_SHOWCONTACTHISTORY; - menuItem.hIcon := hppIcons[HPP_ICON_CONTACTHISTORY].handle; - MenuHandles[miSystem].Handle := Menu_AddMainMenuItem(@menuitem); + hmiEmpty := Menu_AddContactMenuItem(@menuItem); // create menu item in main menu for history search SET_UID(@menuItem, 'A5FE6AE6-7674-4DC0-9F22-9F56AE71E2D7'); - menuItem.Position:=500060001; - menuItem.szName.w:=MenuHandles[miSearch].Name; + menuItem.Position := 500060001; + menuItem.szName.w := 'His&tory Search'; menuItem.pszService := MS_HPP_SHOWGLOBALSEARCH; menuItem.hIcon := hppIcons[HPP_ICON_GLOBALSEARCH].handle; - MenuHandles[miSearch].Handle := Menu_AddMainMenuItem(@menuItem); + Menu_AddMainMenuItem(@menuItem); // create menu item in main menu for empty system history SET_UID(@menuItem, '633AD23C-24B5-4914-B240-AD9FACB564ED'); - menuItem.Position:=500060002; - menuItem.szName.w:=MenuHandles[miSysEmpty].Name; + menuItem.Position := 500060002; + menuItem.szName.w := '&Empty System History'; menuItem.pszService := MS_HPP_EMPTYHISTORY; menuItem.hIcon := hppIcons[HPP_ICON_TOOL_DELETEALL].handle; - MenuHandles[miSysEmpty].Handle := Menu_AddMainMenuItem(@menuItem); + Menu_AddMainMenuItem(@menuItem); LoadGridOptions; @@ -447,17 +422,17 @@ begin hLast := db_event_last(hContact); if (PrevShowHistoryCount xor ShowHistoryCount) or (count <> MenuCount) then begin - Menu_ShowItem(MenuHandles[miEmpty].Handle, byte(hLast <> 0)); - Menu_ShowItem(MenuHandles[miContact].Handle, byte(hLast <> 0)); + Menu_ShowItem(hmiEmpty, byte(hLast <> 0)); + Menu_ShowItem(hmiContact, byte(hLast <> 0)); if ShowHistoryCount then - text := pWideChar(Format('%s [%u]',[TranslateW(MenuHandles[miContact].Name),count])) + text := pWideChar(Format('%s [%u]',[TranslateW(histName),count])) else if PrevShowHistoryCount then - text := TranslateW(MenuHandles[miContact].Name) + text := TranslateW(histName) else text := nil; - Menu_ModifyItem(MenuHandles[miContact].Handle, text); + Menu_ModifyItem(hmiContact, text); MenuCount := count; PrevShowHistoryCount := ShowHistoryCount; end; diff --git a/plugins/IEHistory/src/IEHistory.cpp b/plugins/IEHistory/src/IEHistory.cpp index 344190de51..d0d5e853be 100644 --- a/plugins/IEHistory/src/IEHistory.cpp +++ b/plugins/IEHistory/src/IEHistory.cpp @@ -86,11 +86,6 @@ int CMPlugin::Load() mi.pszService = MS_HISTORY_SHOWCONTACTHISTORY; Menu_AddContactMenuItem(&mi); - // @todo (White-Tiger#1#08/19/14): fully implement System History someday^^ - SET_UID(mi, 0xfcb4bb2a, 0xd4d8, 0x48ab, 0x94, 0xcc, 0x5b, 0xe9, 0x8d, 0x53, 0x3e, 0xf1); - mi.name.w = LPGENW("&System History"); - Menu_AddMainMenuItem(&mi); - HookEvent(ME_OPT_INITIALISE, OnOptionsInitialize); return 0; } diff --git a/plugins/NewStory/src/history.cpp b/plugins/NewStory/src/history.cpp index 194669c545..f0f3fae9a4 100644 --- a/plugins/NewStory/src/history.cpp +++ b/plugins/NewStory/src/history.cpp @@ -1044,15 +1044,3 @@ INT_PTR svcShowNewstory(WPARAM hContact, LPARAM) return 0; } - -INT_PTR svcShowSystemNewstory(WPARAM, LPARAM) -{ - HWND hwnd = (HWND)WindowList_Find(hNewstoryWindows, 0); - if (hwnd && IsWindow(hwnd)) { - SetWindowPos(hwnd, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE); - SetFocus(hwnd); - } - else (new CHistoryDlg(0))->Show(); - - return 0; -} diff --git a/plugins/NewStory/src/history.h b/plugins/NewStory/src/history.h index a1293cadff..f7f448abd1 100644 --- a/plugins/NewStory/src/history.h +++ b/plugins/NewStory/src/history.h @@ -34,7 +34,6 @@ void InitMenus(); INT_PTR svcEmptyHistory(WPARAM hContact, LPARAM); INT_PTR svcShowNewstory(WPARAM wParam, LPARAM lParam); -INT_PTR svcShowSystemNewstory(WPARAM wParam, LPARAM lParam); CSrmmLogWindow* __cdecl NewStory_Stub(CMsgDialog &pDlg); diff --git a/plugins/NewStory/src/history_menus.cpp b/plugins/NewStory/src/history_menus.cpp index 1a38c1c05b..2a5b05c240 100644 --- a/plugins/NewStory/src/history_menus.cpp +++ b/plugins/NewStory/src/history_menus.cpp @@ -34,7 +34,7 @@ void InitMenus() hmiHistory = Menu_AddContactMenuItem(&mi); CreateServiceFunction(mi.pszService, svcShowNewstory); - SET_UID(mi, 0xc20d7a69, 0x7607, 0x4aad, 0xa7, 0x42, 0x10, 0x86, 0xfb, 0x32, 0x49, 0x21); + SET_UID(mi, 0x0d4306aa, 0xe31e, 0x46ee, 0x89, 0x88, 0x3a, 0x2e, 0x05, 0xa6, 0xf3, 0xbc); mi.pszService = "Newstory/EmptyHistory"; mi.name.a = LPGEN("Empty history"); mi.position = 1000090001; @@ -42,14 +42,5 @@ void InitMenus() hmiEmpty = Menu_AddContactMenuItem(&mi); CreateServiceFunction(mi.pszService, svcEmptyHistory); - // Main menu items - SET_UID(mi, 0xc20d7a69, 0x7607, 0x4aad, 0xa7, 0x42, 0x10, 0x86, 0xfb, 0x32, 0x49, 0x22); - mi.pszService = "Newstory/System"; - mi.name.a = LPGEN("System history"); - mi.position = 1000090000; - mi.hIcon = g_plugin.getIcon(ICO_NEWSTORY); - Menu_AddMainMenuItem(&mi); - CreateServiceFunction(mi.pszService, svcShowSystemNewstory); - HookEvent(ME_CLIST_PREBUILDCONTACTMENU, OnPrebuildContactMenu); } diff --git a/src/mir_app/src/menu_clist.cpp b/src/mir_app/src/menu_clist.cpp index ea21e7b86e..82f0c3fd03 100644 --- a/src/mir_app/src/menu_clist.cpp +++ b/src/mir_app/src/menu_clist.cpp @@ -26,6 +26,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #pragma hdrstop #include "m_hotkeys.h" +#include "m_history.h" #include "clc.h" #include "genmenu.h" @@ -1064,8 +1065,16 @@ void InitCustomMenus(void) HookEvent(ME_HOTKEYS_CHANGED, sttRebuildHotkeys); HookEvent(ME_LANGPACK_CHANGED, sttRebuildHotkeys); - // add exit command to menu CMenuItem mi(&g_plugin); + + SET_UID(mi, 0x9d6d4bb1, 0x5207, 0x481a, 0x80, 0x47, 0x67, 0x58, 0x8e, 0xb6, 0x8f, 0xff); + mi.pszService = MS_HISTORY_SHOWCONTACTHISTORY; + mi.name.a = LPGEN("System history"); + mi.position = 500060000; + mi.hIcolibItem = Skin_GetIconHandle(SKINICON_OTHER_HISTORY); + Menu_AddMainMenuItem(&mi); + + // add exit command to menu SET_UID(mi, 0x707c8962, 0xc33f, 0x4893, 0x8e, 0x36, 0x30, 0xb1, 0x7c, 0xd8, 0x61, 0x40); mi.position = 0x7fffffff; mi.pszService = "CloseAction"; -- cgit v1.2.3