From 4ee7025ab09b606a2556bf9f42c1218d7fd72843 Mon Sep 17 00:00:00 2001 From: ouwou <26526779+ouwou@users.noreply.github.com> Date: Fri, 17 Jun 2022 02:46:55 -0400 Subject: add file upload via dnd + rework http --- src/components/chatinput.hpp | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) (limited to 'src/components/chatinput.hpp') diff --git a/src/components/chatinput.hpp b/src/components/chatinput.hpp index 254f96f..865b23e 100644 --- a/src/components/chatinput.hpp +++ b/src/components/chatinput.hpp @@ -5,10 +5,14 @@ class ChatInputAttachmentItem : public Gtk::EventBox { public: - ChatInputAttachmentItem(std::string path, const Glib::RefPtr &pb); + ChatInputAttachmentItem(const Glib::RefPtr &file); + ChatInputAttachmentItem(const Glib::RefPtr &file, const Glib::RefPtr &pb); - [[nodiscard]] std::string GetPath() const; + [[nodiscard]] Glib::RefPtr GetFile() const; [[nodiscard]] ChatSubmitParams::AttachmentType GetType() const; + [[nodiscard]] std::string GetFilename() const; + [[nodiscard]] bool IsTemp() const noexcept; + void RemoveIfTemp(); private: void SetupMenu(); @@ -19,16 +23,17 @@ private: Gtk::Box m_box; Gtk::Image *m_img = nullptr; - std::string m_path; + Glib::RefPtr m_file; ChatSubmitParams::AttachmentType m_type; + std::string m_filename; private: - using type_signal_remove = sigc::signal; + using type_signal_item_removed = sigc::signal; - type_signal_remove m_signal_remove; + type_signal_item_removed m_signal_item_removed; public: - type_signal_remove signal_remove(); + type_signal_item_removed signal_item_removed(); }; class ChatInputAttachmentContainer : public Gtk::ScrolledWindow { @@ -38,6 +43,7 @@ public: void Clear(); void ClearNoPurge(); bool AddImage(const Glib::RefPtr &pb); + bool AddFile(const Glib::RefPtr &file); [[nodiscard]] std::vector GetAttachments() const; private: @@ -92,6 +98,7 @@ public: void InsertText(const Glib::ustring &text); Glib::RefPtr GetBuffer(); bool ProcessKeyPress(GdkEventKey *event); + void AddAttachment(const Glib::RefPtr &file); private: Gtk::Revealer m_attachments_revealer; -- cgit v1.2.3