From d841a2c862eddc6b2053b48907f8e1400e2d1391 Mon Sep 17 00:00:00 2001 From: ouwou <26526779+ouwou@users.noreply.github.com> Date: Thu, 23 Jun 2022 00:48:00 -0400 Subject: add change filename --- src/components/chatinput.cpp | 15 +++++++++++++++ src/components/chatinput.hpp | 2 ++ 2 files changed, 17 insertions(+) (limited to 'src/components') diff --git a/src/components/chatinput.cpp b/src/components/chatinput.cpp index 269a2ac..a734dec 100644 --- a/src/components/chatinput.cpp +++ b/src/components/chatinput.cpp @@ -220,6 +220,7 @@ ChatInputAttachmentItem::ChatInputAttachmentItem(const Glib::RefPtr & show_all_children(); SetupMenu(); + UpdateTooltip(); } Glib::RefPtr ChatInputAttachmentItem::GetFile() const { @@ -249,6 +250,16 @@ void ChatInputAttachmentItem::SetupMenu() { m_signal_item_removed.emit(); }); + m_menu_set_filename.set_label("Change Filename"); + m_menu_set_filename.signal_activate().connect([this] { + const auto name = Abaddon::Get().ShowTextPrompt("Enter new filename for attachment", "Enter filename", m_filename); + if (name.has_value()) { + m_filename = *name; + UpdateTooltip(); + } + }); + + m_menu.add(m_menu_set_filename); m_menu.add(m_menu_remove); m_menu.show_all(); @@ -262,6 +273,10 @@ void ChatInputAttachmentItem::SetupMenu() { }); } +void ChatInputAttachmentItem::UpdateTooltip() { + set_tooltip_text(m_filename); +} + ChatInputAttachmentItem::type_signal_item_removed ChatInputAttachmentItem::signal_item_removed() { return m_signal_item_removed; } diff --git a/src/components/chatinput.hpp b/src/components/chatinput.hpp index 865b23e..8a4ad8d 100644 --- a/src/components/chatinput.hpp +++ b/src/components/chatinput.hpp @@ -16,9 +16,11 @@ public: private: void SetupMenu(); + void UpdateTooltip(); Gtk::Menu m_menu; Gtk::MenuItem m_menu_remove; + Gtk::MenuItem m_menu_set_filename; Gtk::Box m_box; Gtk::Image *m_img = nullptr; -- cgit v1.2.3