From f124626a6dcecf928be90193b2faf8e265ba502b Mon Sep 17 00:00:00 2001 From: ouwou <26526779+ouwou@users.noreply.github.com> Date: Sun, 8 Nov 2020 00:44:26 -0500 Subject: allow multiple components to display shared user menu --- components/chatwindow.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'components/chatwindow.cpp') diff --git a/components/chatwindow.cpp b/components/chatwindow.cpp index 3943bd5..c480b51 100644 --- a/components/chatwindow.cpp +++ b/components/chatwindow.cpp @@ -177,14 +177,20 @@ void ChatWindow::ProcessNewMessage(Snowflake id, bool prepend) { if (should_attach) { header = last_row; } else { + const auto guild_id = client.GetChannel(m_active_channel)->GuildID; const auto user_id = data->Author.ID; const auto *user = client.GetUser(user_id); if (user == nullptr) return; header = Gtk::manage(new ChatMessageHeader(data)); - header->signal_action_insert_mention().connect([this](const Snowflake &id) { - m_signal_action_insert_mention.emit(id); + header->signal_action_insert_mention().connect([this, user_id]() { + m_signal_action_insert_mention.emit(user_id); }); + + header->signal_action_open_user_menu().connect([this, user_id, guild_id](const GdkEvent *event) { + m_signal_action_open_user_menu.emit(event, user_id, guild_id); + }); + m_num_rows++; Abaddon::Get().GetImageManager().LoadFromURL(user->GetAvatarURL("png", "32"), [this, user_id](Glib::RefPtr buf) { Glib::signal_idle().connect([this, buf, user_id]() -> bool { @@ -341,3 +347,7 @@ ChatWindow::type_signal_action_channel_click ChatWindow::signal_action_channel_c ChatWindow::type_signal_action_insert_mention ChatWindow::signal_action_insert_mention() { return m_signal_action_insert_mention; } + +ChatWindow::type_signal_action_open_user_menu ChatWindow::signal_action_open_user_menu() { + return m_signal_action_open_user_menu; +} -- cgit v1.2.3