diff options
Diffstat (limited to 'src/components/chatmessage.cpp')
-rw-r--r-- | src/components/chatmessage.cpp | 33 |
1 files changed, 21 insertions, 12 deletions
diff --git a/src/components/chatmessage.cpp b/src/components/chatmessage.cpp index 44396a2..a503294 100644 --- a/src/components/chatmessage.cpp +++ b/src/components/chatmessage.cpp @@ -46,6 +46,9 @@ ChatMessageItemContainer *ChatMessageItemContainer::FromMessage(const Message &d for (const auto &a : data.Attachments) { if (IsURLViewableImage(a.ProxyURL) && a.Width.has_value() && a.Height.has_value()) { auto *widget = container->CreateImageComponent(a.ProxyURL, a.URL, *a.Width, *a.Height); + if (a.Description.has_value()) { + widget->set_tooltip_text(*a.Description); + } container->m_main.add(*widget); } else { auto *widget = container->CreateAttachmentComponent(a); @@ -361,7 +364,7 @@ Gtk::Widget *ChatMessageItemContainer::CreateEmbedComponent(const EmbedData &emb } return false; }); - static auto color = Abaddon::Get().GetSettings().LinkColor; + const auto color = title_label->get_style_context()->get_color(Gtk::STATE_FLAG_LINK); title_label->override_color(Gdk::RGBA(color)); title_label->set_markup("<b>" + Glib::Markup::escape_text(*embed.Title) + "</b>"); } @@ -620,7 +623,11 @@ Gtk::Widget *ChatMessageItemContainer::CreateReactionsComponent(const Message &d } else { // custom ev->set_tooltip_text(reaction.Emoji.Name); - auto img = Gtk::manage(new LazyImage(reaction.Emoji.GetURL(), 16, 16)); + auto *img = Gtk::make_managed<LazyImage>(reaction.Emoji.GetURL(), 16, 16); + if (reaction.Emoji.IsEmojiAnimated() && Abaddon::Get().GetSettings().ShowAnimations) { + img->SetURL(reaction.Emoji.GetURL("gif")); + img->SetAnimated(true); + } img->set_can_focus(false); box->add(*img); } @@ -657,7 +664,12 @@ Gtk::Widget *ChatMessageItemContainer::CreateReplyComponent(const Message &data) if (role.has_value()) { const auto author = discord.GetUser(author_id); if (author.has_value()) { - return "<b><span color=\"#" + IntToCSSColor(role->Color) + "\">" + author->GetDisplayNameEscaped(guild_id) + "</span></b>"; + const auto is_mention = !data.Interaction.has_value() && data.DoesMention(author_id); + if (is_mention) { + return "<b><span color=\"#" + IntToCSSColor(role->Color) + "\">@" + author->GetDisplayNameEscaped(guild_id) + "</span></b>"; + } else { + return "<b><span color=\"#" + IntToCSSColor(role->Color) + "\">" + author->GetDisplayNameEscaped(guild_id) + "</span></b>"; + } } } } @@ -713,16 +725,12 @@ Gtk::Widget *ChatMessageItemContainer::CreateReplyComponent(const Message &data) HandleChannelMentions(buf); text = Glib::Markup::escape_text(buf->get_text()); } - // getting markup out of a textbuffer seems like something that to me should be really simple - // but actually is horribly annoying. replies won't have mention colors because you can't do this - // also no emojis because idk how to make a textview act like a label - // which of course would not be an issue if i could figure out how to get fonts to work on this god-forsaken framework - // oh well - // but ill manually get colors for the user who is being replied to - if (referenced.GuildID.has_value()) + + if (referenced.GuildID.has_value()) { lbl->set_markup(get_author_markup(referenced.Author.ID, *referenced.GuildID) + ": " + text); - else + } else { lbl->set_markup(get_author_markup(referenced.Author.ID) + ": " + text); + } } } else { lbl->set_markup("<i>reply unavailable</i>"); @@ -848,7 +856,8 @@ void ChatMessageItemContainer::HandleLinks(Gtk::TextView &tv) { std::string link = match.fetch(0); auto tag = buf->create_tag(); m_link_tagmap[tag] = link; - tag->property_foreground_rgba() = Gdk::RGBA(Abaddon::Get().GetSettings().LinkColor); + const auto color = tv.get_style_context()->get_color(Gtk::STATE_FLAG_LINK); + tag->property_foreground_rgba() = color; tag->set_property("underline", 1); // stupid workaround for vcpkg bug (i think) const auto chars_start = g_utf8_pointer_to_offset(text.c_str(), text.c_str() + mstart); |