diff options
author | ouwou <26526779+ouwou@users.noreply.github.com> | 2023-07-16 04:16:48 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-07-16 04:16:48 +0000 |
commit | 49bbc926e76147d2f380685d4635ebcdf2163f8f (patch) | |
tree | 740be513f52752cf25479bede9e8e2231bf0ffa6 /src/components/chatinput.cpp | |
parent | 52a340e3666e4081b5f284c320404d06ac37b2f3 (diff) | |
parent | 52b52eb489caa64e6cea978f2c6917a55fa70979 (diff) | |
download | abaddon-portaudio-49bbc926e76147d2f380685d4635ebcdf2163f8f.tar.gz abaddon-portaudio-49bbc926e76147d2f380685d4635ebcdf2163f8f.zip |
Merge pull request #192 from uowuo/message-editing
Improve message editing
Diffstat (limited to 'src/components/chatinput.cpp')
-rw-r--r-- | src/components/chatinput.cpp | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/src/components/chatinput.cpp b/src/components/chatinput.cpp index 28ed1ea..1133302 100644 --- a/src/components/chatinput.cpp +++ b/src/components/chatinput.cpp @@ -497,6 +497,10 @@ void ChatInput::InsertText(const Glib::ustring &text) { m_input.Get().InsertText(text); } +void ChatInput::Clear() { + GetBuffer()->set_text(""); +} + Glib::RefPtr<Gtk::TextBuffer> ChatInput::GetBuffer() { return m_input.Get().GetBuffer(); } @@ -565,6 +569,24 @@ void ChatInput::StopReplying() { m_input.Get().get_style_context()->remove_class("replying"); } +void ChatInput::StartEditing(const Message &message) { + m_is_editing = true; + m_input.Get().grab_focus(); + m_input.Get().get_style_context()->add_class("editing"); + GetBuffer()->set_text(message.Content); + m_attachments.Clear(); + m_attachments_revealer.set_reveal_child(false); +} + +void ChatInput::StopEditing() { + m_is_editing = false; + m_input.Get().get_style_context()->remove_class("editing"); +} + +bool ChatInput::IsEmpty() { + return GetBuffer()->get_char_count() == 0; +} + bool ChatInput::AddFileAsImageAttachment(const Glib::RefPtr<Gio::File> &file) { try { const auto read_stream = file->read(); @@ -577,7 +599,7 @@ bool ChatInput::AddFileAsImageAttachment(const Glib::RefPtr<Gio::File> &file) { } bool ChatInput::CanAttachFiles() { - return Abaddon::Get().GetDiscordClient().HasSelfChannelPermission(m_active_channel, Permission::ATTACH_FILES | Permission::SEND_MESSAGES); + return !m_is_editing && Abaddon::Get().GetDiscordClient().HasSelfChannelPermission(m_active_channel, Permission::ATTACH_FILES | Permission::SEND_MESSAGES); } ChatInput::type_signal_submit ChatInput::signal_submit() { |