diff options
author | ouwou <26526779+ouwou@users.noreply.github.com> | 2020-10-11 01:56:30 -0400 |
---|---|---|
committer | ouwou <26526779+ouwou@users.noreply.github.com> | 2020-10-11 01:56:30 -0400 |
commit | 1ff177ad5a11f084acca616084021664f8201514 (patch) | |
tree | 0ecf71075af0a66a62ef58c2a395cc3dc9a06dc3 /components/chatmessage.cpp | |
parent | 059146b060e9cdd57f6ddbb9d6e6a17a2d6529f9 (diff) | |
download | abaddon-portaudio-1ff177ad5a11f084acca616084021664f8201514.tar.gz abaddon-portaudio-1ff177ad5a11f084acca616084021664f8201514.zip |
shift click on message author to insert mention
Diffstat (limited to 'components/chatmessage.cpp')
-rw-r--r-- | components/chatmessage.cpp | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/components/chatmessage.cpp b/components/chatmessage.cpp index 39b6626..f804572 100644 --- a/components/chatmessage.cpp +++ b/components/chatmessage.cpp @@ -586,6 +586,7 @@ ChatMessageHeader::ChatMessageHeader(const Message *data) { m_main_box = Gtk::manage(new Gtk::Box(Gtk::ORIENTATION_HORIZONTAL)); m_content_box = Gtk::manage(new Gtk::Box(Gtk::ORIENTATION_VERTICAL)); m_meta_box = Gtk::manage(new Gtk::Box(Gtk::ORIENTATION_HORIZONTAL)); + m_author_ev = Gtk::manage(new Gtk::EventBox); m_author = Gtk::manage(new Gtk::Label); m_timestamp = Gtk::manage(new Gtk::Label); @@ -609,6 +610,7 @@ ChatMessageHeader::ChatMessageHeader(const Message *data) { m_author->set_ellipsize(Pango::ELLIPSIZE_END); m_author->set_xalign(0.f); m_author->set_can_focus(false); + m_author_ev->signal_button_press_event().connect(sigc::mem_fun(*this, &ChatMessageHeader::on_author_button_press)); if (data->WebhookID.IsValid()) { m_extra = Gtk::manage(new Gtk::Label); @@ -642,7 +644,8 @@ ChatMessageHeader::ChatMessageHeader(const Message *data) { m_content_box->set_can_focus(false); - m_meta_box->add(*m_author); + m_author_ev->add(*m_author); + m_meta_box->add(*m_author_ev); if (m_extra != nullptr) m_meta_box->add(*m_extra); m_meta_box->add(*m_timestamp); @@ -675,6 +678,19 @@ void ChatMessageHeader::UpdateNameColor() { m_author->set_markup(md); } +bool ChatMessageHeader::on_author_button_press(GdkEventButton *ev) { + if (ev->button == GDK_BUTTON_PRIMARY && (ev->state & GDK_SHIFT_MASK)) { + m_signal_action_insert_mention.emit(UserID); + return true; + } + + return false; +} + +ChatMessageHeader::type_signal_action_insert_mention ChatMessageHeader::signal_action_insert_mention() { + return m_signal_action_insert_mention; +} + void ChatMessageHeader::AddContent(Gtk::Widget *widget, bool prepend) { m_content_box->add(*widget); if (prepend) |