From 851cf91ef94adc40d49f4d60e6f0f32694fba96b Mon Sep 17 00:00:00 2001 From: George Hazan Date: Wed, 30 Oct 2024 14:18:29 +0300 Subject: fixes #4644 (NewStory: added protocol icon for the global history search window) --- plugins/NewStory/src/history_array.cpp | 3 +++ plugins/NewStory/src/history_control.cpp | 21 +++++++++++++++++++++ plugins/NewStory/src/history_control.h | 2 ++ plugins/NewStory/src/version.h | 2 +- plugins/NewStory/src/webpage.cpp | 2 +- 5 files changed, 28 insertions(+), 2 deletions(-) (limited to 'plugins/NewStory') diff --git a/plugins/NewStory/src/history_array.cpp b/plugins/NewStory/src/history_array.cpp index 3d81d77b4b..bcf1120a9b 100644 --- a/plugins/NewStory/src/history_array.cpp +++ b/plugins/NewStory/src/history_array.cpp @@ -210,6 +210,9 @@ int ItemData::calcHeight(int width) if (dbe.flags & DBEF_BOOKMARK) // Bookmark icon xPos += 18; + if (pOwner->m_hContact == INVALID_CONTACT_ID) // Protocol icon + xPos += 18; + cx -= xPos; if (m_bOfflineDownloaded != 0 || m_bDelivered || m_bRemoteRead) // Download completed icon cx -= 18; diff --git a/plugins/NewStory/src/history_control.cpp b/plugins/NewStory/src/history_control.cpp index a944053381..b10e7a98a3 100644 --- a/plugins/NewStory/src/history_control.cpp +++ b/plugins/NewStory/src/history_control.cpp @@ -67,6 +67,12 @@ NewstoryListData::NewstoryListData(HWND _1) : iLineHeigth = GetFontHeight(g_fontTable[FONT_INMSG].lf); } +NewstoryListData::~NewstoryListData() +{ + for (auto &it : m_protoIcons) + IcoLib_ReleaseIcon(it.second); +} + void NewstoryListData::onTimer_Draw(CTimer *pTimer) { pTimer->Stop(); @@ -772,6 +778,21 @@ void NewstoryListData::Paint(simpledib::dib &dib) if (!bReadOnly) { HICON hIcon; + // Protocol icon + if (m_hContact == INVALID_CONTACT_ID) { + if (auto *pa = Proto_GetContactAccount(pItem->dbe.hContact)) { + if (m_protoIcons.count(pa->szModuleName)) + hIcon = m_protoIcons[pa->szModuleName]; + else { + hIcon = Skin_LoadProtoIcon(pa->szModuleName, ID_STATUS_ONLINE); + m_protoIcons[pa->szModuleName] = hIcon; + } + + DrawIconEx(dib, xPos, yPos, hIcon, 16, 16, 0, 0, DI_NORMAL); + xPos += 18; + } + } + // Message type icon if (g_plugin.bShowType) { switch (pItem->dbe.eventType) { diff --git a/plugins/NewStory/src/history_control.h b/plugins/NewStory/src/history_control.h index 49289baeb4..e74b7b754b 100644 --- a/plugins/NewStory/src/history_control.h +++ b/plugins/NewStory/src/history_control.h @@ -86,9 +86,11 @@ public: struct NewstoryListData : public MZeroedObject { NewstoryListData(HWND); + ~NewstoryListData(); mir_cs m_csItems; HistoryArray items; + std::map m_protoIcons; int scrollTopItem; // topmost item int scrollTopPixel; // y coord of topmost item, this should be negative or zero diff --git a/plugins/NewStory/src/version.h b/plugins/NewStory/src/version.h index 7d9f500c7e..deec274fc5 100644 --- a/plugins/NewStory/src/version.h +++ b/plugins/NewStory/src/version.h @@ -1,7 +1,7 @@ #define __MAJOR_VERSION 0 #define __MINOR_VERSION 2 #define __RELEASE_NUM 0 -#define __BUILD_NUM 2 +#define __BUILD_NUM 3 #include diff --git a/plugins/NewStory/src/webpage.cpp b/plugins/NewStory/src/webpage.cpp index b2fcd9892d..79dbdd095b 100644 --- a/plugins/NewStory/src/webpage.cpp +++ b/plugins/NewStory/src/webpage.cpp @@ -58,7 +58,7 @@ INT_PTR SvcFileReady(WPARAM wParam, LPARAM) static std::set g_installed_fonts; -int CALLBACK EnumFontsProc(const LOGFONTW *lplf, const TEXTMETRIC *, DWORD, LPARAM) +static int CALLBACK EnumFontsProc(const LOGFONTW *lplf, const TEXTMETRIC *, DWORD, LPARAM) { g_installed_fonts.insert(lplf->lfFaceName); return 1; -- cgit v1.2.3