From 4ac27e91403b708088451c9c07f3b4c2eecb7cf2 Mon Sep 17 00:00:00 2001 From: ouwou <26526779+ouwou@users.noreply.github.com> Date: Wed, 30 Sep 2020 00:12:38 -0400 Subject: add wonky image loading --- components/chatwindow.cpp | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'components/chatwindow.cpp') diff --git a/components/chatwindow.cpp b/components/chatwindow.cpp index ee4aea9..f466852 100644 --- a/components/chatwindow.cpp +++ b/components/chatwindow.cpp @@ -199,14 +199,25 @@ void ChatWindow::ProcessNewMessage(Snowflake id, bool prepend) { auto *content = CreateMessageComponent(id); if (content != nullptr) { + header->AddContent(content, prepend); + m_id_to_widget[id] = content; + content->signal_action_delete().connect([this, id] { m_signal_action_message_delete.emit(m_active_channel, id); }); content->signal_action_edit().connect([this, id] { m_signal_action_message_edit.emit(m_active_channel, id); }); - header->AddContent(content, prepend); - m_id_to_widget[id] = content; + content->signal_image_load().connect([this, id](std::string url) { + auto &mgr = Abaddon::Get().GetImageManager(); + mgr.LoadFromURL(url, [this, id](Glib::RefPtr buf) { + if (m_id_to_widget.find(id) != m_id_to_widget.end()) { + auto *x = dynamic_cast(m_id_to_widget.at(id)); + if (x != nullptr) + x->UpdateImage(); + } + }); + }); } header->set_margin_left(5); -- cgit v1.2.3