summaryrefslogtreecommitdiff
path: root/protocols/JabberG/src
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2022-08-04 20:56:19 +0300
committerGeorge Hazan <ghazan@miranda.im>2022-08-04 20:56:19 +0300
commitcac837555e467fd98716feafae2ce7a6814d3266 (patch)
treefd239c271a217b1ce55c9329968ef662ea8411fa /protocols/JabberG/src
parent8b4972feb7dc839d3a8537f9f1796a054c509d67 (diff)
Jabber: the code to hide unused user info pages
Diffstat (limited to 'protocols/JabberG/src')
-rw-r--r--protocols/JabberG/src/jabber_userinfo.cpp42
1 files changed, 27 insertions, 15 deletions
diff --git a/protocols/JabberG/src/jabber_userinfo.cpp b/protocols/JabberG/src/jabber_userinfo.cpp
index cf07268ba8..03b65daf1f 100644
--- a/protocols/JabberG/src/jabber_userinfo.cpp
+++ b/protocols/JabberG/src/jabber_userinfo.cpp
@@ -511,6 +511,20 @@ class JabberUserPhotoDlg : public CUserInfoPageDlg
UI_MESSAGE(WM_PAINT, OnPaint);
UI_MESSAGE_MAP_END();
+ char *GetFileName() const
+ {
+ ptrA jid(ppro->getUStringA(m_hContact, "jid"));
+ if (jid != nullptr) {
+ JABBER_LIST_ITEM *item = ppro->ListGetItemPtr(LIST_VCARD_TEMP, jid);
+ if (item == nullptr)
+ item = ppro->ListGetItemPtr(LIST_ROSTER, jid);
+ if (item != nullptr)
+ return item->photoFileName;
+ }
+
+ return nullptr;
+ }
+
public:
JabberUserPhotoDlg(CJabberProto *_ppro) :
CUserInfoPageDlg(g_plugin, IDD_VCARD_PHOTO),
@@ -538,6 +552,11 @@ public:
}
}
+ bool IsEmpty() const override
+ {
+ return mir_strlen(GetFileName()) == 0;
+ }
+
bool OnRefresh() override
{
if (hBitmap) {
@@ -545,22 +564,15 @@ public:
hBitmap = nullptr;
}
ShowWindow(GetDlgItem(m_hwnd, IDC_SAVE), SW_HIDE);
- {
- ptrA jid(ppro->getUStringA(m_hContact, "jid"));
- if (jid != nullptr) {
- JABBER_LIST_ITEM *item = ppro->ListGetItemPtr(LIST_VCARD_TEMP, jid);
- if (item == nullptr)
- item = ppro->ListGetItemPtr(LIST_ROSTER, jid);
- if (item != nullptr) {
- if (item->photoFileName) {
- ppro->debugLogA("Showing picture from %s", item->photoFileName);
- hBitmap = Bitmap_Load(Utf2T(item->photoFileName));
- FreeImage_Premultiply(hBitmap);
- ShowWindow(GetDlgItem(m_hwnd, IDC_SAVE), SW_SHOW);
- }
- }
- }
+
+ char *pszFileName = GetFileName();
+ if (mir_strlen(pszFileName)) {
+ ppro->debugLogA("Showing picture from %s", pszFileName);
+ hBitmap = Bitmap_Load(Utf2T(pszFileName));
+ FreeImage_Premultiply(hBitmap);
+ ShowWindow(GetDlgItem(m_hwnd, IDC_SAVE), SW_SHOW);
}
+
InvalidateRect(m_hwnd, nullptr, TRUE);
UpdateWindow(m_hwnd);
return true;