summaryrefslogtreecommitdiff
path: root/src/components
diff options
context:
space:
mode:
authorouwou <26526779+ouwou@users.noreply.github.com>2023-12-15 01:36:06 -0500
committerouwou <26526779+ouwou@users.noreply.github.com>2023-12-15 01:36:06 -0500
commitaf31402b7f1d9d118f07f0fd6554319dbd6b44b6 (patch)
tree309ef8ee1b4dc7e787193f4eaffa219f0b68213d /src/components
parent8324172a90752403edcec2203a2abb386046cc8f (diff)
parent4bce7b7523caa26023b1a2f5e02e6646ed29f5e0 (diff)
downloadabaddon-portaudio-af31402b7f1d9d118f07f0fd6554319dbd6b44b6.tar.gz
abaddon-portaudio-af31402b7f1d9d118f07f0fd6554319dbd6b44b6.zip
Merge branch 'master' into theming
Diffstat (limited to 'src/components')
-rw-r--r--src/components/chatinput.cpp21
-rw-r--r--src/components/chatinput.hpp14
-rw-r--r--src/components/chatmessage.cpp22
3 files changed, 43 insertions, 14 deletions
diff --git a/src/components/chatinput.cpp b/src/components/chatinput.cpp
index b6beaa5..1db03ed 100644
--- a/src/components/chatinput.cpp
+++ b/src/components/chatinput.cpp
@@ -262,7 +262,7 @@ std::vector<ChatSubmitParams::Attachment> ChatInputAttachmentContainer::GetAttac
for (auto *x : m_attachments) {
if (!x->GetFile()->query_exists())
puts("bad!");
- ret.push_back({ x->GetFile(), x->GetType(), x->GetFilename() });
+ ret.push_back({ x->GetFile(), x->GetType(), x->GetFilename(), x->GetDescription() });
}
return ret;
}
@@ -310,6 +310,7 @@ ChatInputAttachmentItem::ChatInputAttachmentItem(const Glib::RefPtr<Gio::File> &
, m_img(Gtk::make_managed<Gtk::Image>())
, m_type(is_extant ? ChatSubmitParams::ExtantFile : ChatSubmitParams::PastedImage)
, m_filename("unknown.png")
+ , m_is_image(true)
, m_label("unknown.png")
, m_box(Gtk::ORIENTATION_VERTICAL) {
get_style_context()->add_class("attachment-item");
@@ -356,10 +357,18 @@ std::string ChatInputAttachmentItem::GetFilename() const {
return m_filename;
}
+std::optional<std::string> ChatInputAttachmentItem::GetDescription() const {
+ return m_description.empty() ? std::nullopt : std::optional<std::string>(m_description);
+}
+
bool ChatInputAttachmentItem::IsTemp() const noexcept {
return m_type == ChatSubmitParams::PastedImage;
}
+bool ChatInputAttachmentItem::IsImage() const noexcept {
+ return m_is_image;
+}
+
void ChatInputAttachmentItem::RemoveIfTemp() {
if (IsTemp())
m_file->remove();
@@ -387,12 +396,22 @@ void ChatInputAttachmentItem::SetupMenu() {
}
});
+ m_menu_set_alt_text.set_label("Change Alt-Text");
+ m_menu_set_alt_text.signal_activate().connect([this]() {
+ const auto description = Abaddon::Get().ShowTextPrompt("Enter description (alt-text) for attachment", "Enter alt-text", m_description);
+ if (description.has_value()) {
+ m_description = *description;
+ }
+ });
+
m_menu.add(m_menu_set_filename);
+ m_menu.add(m_menu_set_alt_text);
m_menu.add(m_menu_remove);
m_menu.show_all();
signal_button_press_event().connect([this](GdkEventButton *ev) -> bool {
if (ev->button == GDK_BUTTON_SECONDARY) {
+ m_menu_set_alt_text.set_visible(IsImage());
m_menu.popup_at_pointer(reinterpret_cast<GdkEvent *>(ev));
return true;
}
diff --git a/src/components/chatinput.hpp b/src/components/chatinput.hpp
index 7ee3921..231d67c 100644
--- a/src/components/chatinput.hpp
+++ b/src/components/chatinput.hpp
@@ -7,10 +7,13 @@ public:
ChatInputAttachmentItem(const Glib::RefPtr<Gio::File> &file);
ChatInputAttachmentItem(const Glib::RefPtr<Gio::File> &file, const Glib::RefPtr<Gdk::Pixbuf> &pb, bool is_extant = false);
- [[nodiscard]] Glib::RefPtr<Gio::File> GetFile() const;
- [[nodiscard]] ChatSubmitParams::AttachmentType GetType() const;
- [[nodiscard]] std::string GetFilename() const;
- [[nodiscard]] bool IsTemp() const noexcept;
+ Glib::RefPtr<Gio::File> GetFile() const;
+ ChatSubmitParams::AttachmentType GetType() const;
+ std::string GetFilename() const;
+ std::optional<std::string> GetDescription() const;
+ bool IsTemp() const noexcept;
+ bool IsImage() const noexcept;
+
void RemoveIfTemp();
private:
@@ -21,6 +24,7 @@ private:
Gtk::Menu m_menu;
Gtk::MenuItem m_menu_remove;
Gtk::MenuItem m_menu_set_filename;
+ Gtk::MenuItem m_menu_set_alt_text;
Gtk::Box m_box;
Gtk::Label m_label;
@@ -29,6 +33,8 @@ private:
Glib::RefPtr<Gio::File> m_file;
ChatSubmitParams::AttachmentType m_type;
std::string m_filename;
+ std::string m_description;
+ bool m_is_image = false;
private:
using type_signal_item_removed = sigc::signal<void>;
diff --git a/src/components/chatmessage.cpp b/src/components/chatmessage.cpp
index 4b195aa..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);
@@ -661,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>";
+ }
}
}
}
@@ -717,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>");