From 5703d06c7396814b239a621d03ef983372491d34 Mon Sep 17 00:00:00 2001 From: ouwou <26526779+ouwou@users.noreply.github.com> Date: Sat, 4 Nov 2023 20:54:15 -0400 Subject: show animated reactions --- src/components/chatmessage.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src/components/chatmessage.cpp') diff --git a/src/components/chatmessage.cpp b/src/components/chatmessage.cpp index 44396a2..d884077 100644 --- a/src/components/chatmessage.cpp +++ b/src/components/chatmessage.cpp @@ -620,7 +620,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(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); } -- cgit v1.2.3 From 260fc2a745afd4dca4e628e6c407b7757dbcf5f0 Mon Sep 17 00:00:00 2001 From: ouwou <26526779+ouwou@users.noreply.github.com> Date: Mon, 4 Dec 2023 01:50:16 -0500 Subject: show @ in reply markup if reply is a mention --- src/components/chatmessage.cpp | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) (limited to 'src/components/chatmessage.cpp') diff --git a/src/components/chatmessage.cpp b/src/components/chatmessage.cpp index d884077..6eccba2 100644 --- a/src/components/chatmessage.cpp +++ b/src/components/chatmessage.cpp @@ -661,7 +661,12 @@ Gtk::Widget *ChatMessageItemContainer::CreateReplyComponent(const Message &data) if (role.has_value()) { const auto author = discord.GetUser(author_id); if (author.has_value()) { - return "Color) + "\">" + author->GetDisplayNameEscaped(guild_id) + ""; + const auto is_mention = !data.Interaction.has_value() && data.DoesMention(author_id); + if (is_mention) { + return "Color) + "\">@" + author->GetDisplayNameEscaped(guild_id) + ""; + } else { + return "Color) + "\">" + author->GetDisplayNameEscaped(guild_id) + ""; + } } } } @@ -717,16 +722,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("reply unavailable"); -- cgit v1.2.3 From e21b678220ce6ca7712a46ee9fe674320e148bab Mon Sep 17 00:00:00 2001 From: ouwou <26526779+ouwou@users.noreply.github.com> Date: Mon, 4 Dec 2023 20:19:02 -0500 Subject: get link color from theme --- src/components/chatmessage.cpp | 5 +++-- src/settings.cpp | 2 -- src/settings.hpp | 1 - 3 files changed, 3 insertions(+), 5 deletions(-) (limited to 'src/components/chatmessage.cpp') diff --git a/src/components/chatmessage.cpp b/src/components/chatmessage.cpp index d884077..4b195aa 100644 --- a/src/components/chatmessage.cpp +++ b/src/components/chatmessage.cpp @@ -361,7 +361,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("" + Glib::Markup::escape_text(*embed.Title) + ""); } @@ -852,7 +852,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); diff --git a/src/settings.cpp b/src/settings.cpp index c824a34..368d5bb 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -68,7 +68,6 @@ void SettingsManager::ReadSettings() { SMINT("http", "concurrent", CacheHTTPConcurrency); SMSTR("http", "user_agent", UserAgent); SMSTR("style", "expandercolor", ChannelsExpanderColor); - SMSTR("style", "linkcolor", LinkColor); SMSTR("style", "nsfwchannelcolor", NSFWChannelColor); SMSTR("style", "channelcolor", ChannelColor); SMSTR("style", "mentionbadgecolor", MentionBadgeColor); @@ -159,7 +158,6 @@ void SettingsManager::Close() { SMINT("http", "concurrent", CacheHTTPConcurrency); SMSTR("http", "user_agent", UserAgent); SMSTR("style", "expandercolor", ChannelsExpanderColor); - SMSTR("style", "linkcolor", LinkColor); SMSTR("style", "nsfwchannelcolor", NSFWChannelColor); SMSTR("style", "channelcolor", ChannelColor); SMSTR("style", "mentionbadgecolor", MentionBadgeColor); diff --git a/src/settings.hpp b/src/settings.hpp index 037233b..67ba515 100644 --- a/src/settings.hpp +++ b/src/settings.hpp @@ -39,7 +39,6 @@ public: // [style] // TODO: convert to StyleProperty... or maybe not? i still cant figure out what the "correct" method is for this - std::string LinkColor { "rgba(40, 200, 180, 255)" }; std::string ChannelsExpanderColor { "rgba(255, 83, 112, 255)" }; std::string NSFWChannelColor { "#ed6666" }; std::string ChannelColor { "#fbfbfb" }; -- cgit v1.2.3 From 23bf237e4e7dd008df8ff32da31878d1b990f5bf Mon Sep 17 00:00:00 2001 From: ouwou <26526779+ouwou@users.noreply.github.com> Date: Wed, 13 Dec 2023 21:59:45 -0500 Subject: view image alt text on hover --- src/components/chatmessage.cpp | 3 +++ src/discord/message.cpp | 2 ++ src/discord/message.hpp | 5 +++-- src/discord/store.cpp | 5 ++++- 4 files changed, 12 insertions(+), 3 deletions(-) (limited to 'src/components/chatmessage.cpp') diff --git a/src/components/chatmessage.cpp b/src/components/chatmessage.cpp index 6eccba2..2c2f9dd 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); diff --git a/src/discord/message.cpp b/src/discord/message.cpp index bc4c6c8..8a0e271 100644 --- a/src/discord/message.cpp +++ b/src/discord/message.cpp @@ -128,6 +128,7 @@ void to_json(nlohmann::json &j, const AttachmentData &m) { j["proxy_url"] = m.ProxyURL; JS_IF("height", m.Height); JS_IF("width", m.Width); + JS_IF("description", m.Description); } void from_json(const nlohmann::json &j, AttachmentData &m) { @@ -138,6 +139,7 @@ void from_json(const nlohmann::json &j, AttachmentData &m) { JS_D("proxy_url", m.ProxyURL); JS_ON("height", m.Height); JS_ON("width", m.Width); + JS_ON("description", m.Description); } void from_json(const nlohmann::json &j, MessageReferenceData &m) { diff --git a/src/discord/message.hpp b/src/discord/message.hpp index b71c158..1e836d0 100644 --- a/src/discord/message.hpp +++ b/src/discord/message.hpp @@ -168,8 +168,9 @@ struct AttachmentData { int Bytes; std::string URL; std::string ProxyURL; - std::optional Height; // null - std::optional Width; // null + std::optional Height; // null + std::optional Width; // null + std::optional Description; // alt text friend void to_json(nlohmann::json &j, const AttachmentData &m); friend void from_json(const nlohmann::json &j, AttachmentData &m); diff --git a/src/discord/store.cpp b/src/discord/store.cpp index 0e1ba48..bf630aa 100644 --- a/src/discord/store.cpp +++ b/src/discord/store.cpp @@ -368,6 +368,7 @@ void Store::SetMessage(Snowflake id, const Message &message) { s->Bind(6, a.ProxyURL); s->Bind(7, a.Height); s->Bind(8, a.Width); + s->Bind(9, a.Description); if (!s->Insert()) fprintf(stderr, "message attachment insert failed for %" PRIu64 "/%" PRIu64 ": %s\n", static_cast(id), static_cast(a.ID), m_db.ErrStr()); s->Reset(); @@ -1021,6 +1022,7 @@ Message Store::GetMessageBound(std::unique_ptr &s) const { s->Get(5, q.ProxyURL); s->Get(6, q.Height); s->Get(7, q.Width); + s->Get(8, q.Description); } s->Reset(); } @@ -1509,6 +1511,7 @@ bool Store::CreateTables() { proxy TEXT NOT NULL, height INTEGER, width INTEGER, + description TEXT, PRIMARY KEY(message, id) ) )"; @@ -2212,7 +2215,7 @@ bool Store::CreateStatements() { m_stmt_set_attachment = std::make_unique(m_db, R"( REPLACE INTO attachments VALUES ( - ?, ?, ?, ?, ?, ?, ?, ? + ?, ?, ?, ?, ?, ?, ?, ?, ? ) )"); if (!m_stmt_set_attachment->OK()) { -- cgit v1.2.3