diff options
-rw-r--r-- | src/QuickMedia.cpp | 41 |
1 files changed, 36 insertions, 5 deletions
diff --git a/src/QuickMedia.cpp b/src/QuickMedia.cpp index d4e9bac..b4fa915 100644 --- a/src/QuickMedia.cpp +++ b/src/QuickMedia.cpp @@ -4718,6 +4718,29 @@ namespace QuickMedia { return false; }; + auto download_selected_item = [this, &ui_tabs, PINNED_TAB_INDEX, MESSAGES_TAB_INDEX](BodyItem *selected) { + if(!selected) + return false; + + const int selected_tab = ui_tabs.get_selected(); + Message *selected_item_message = nullptr; + if(selected_tab == MESSAGES_TAB_INDEX) { + selected_item_message = static_cast<Message*>(selected->userdata); + } else if(selected_tab == PINNED_TAB_INDEX && static_cast<PinnedEventData*>(selected->userdata)->status == FetchStatus::FINISHED_LOADING) { + selected_item_message = static_cast<PinnedEventData*>(selected->userdata)->message; + } + + if(selected_item_message) { + MessageType message_type = selected_item_message->type; + if(!selected->url.empty() && (message_type == MessageType::VIDEO || message_type == MessageType::IMAGE || message_type == MessageType::AUDIO)) { + download_async_gui(selected->url, false, force_no_video); + return true; + } + } + + return false; + }; + auto update_pinned_messages_author = [&tabs, ¤t_room, PINNED_TAB_INDEX](const std::shared_ptr<UserInfo> &user) { fprintf(stderr, "updated pinned messages author for user: %s\n", user->user_id.c_str()); for(auto &pinned_body_item : tabs[PINNED_TAB_INDEX].body->items) { @@ -4931,11 +4954,19 @@ namespace QuickMedia { } } - if((selected_tab == MESSAGES_TAB_INDEX || selected_tab == PINNED_TAB_INDEX) && event.key.code == sf::Keyboard::Enter && !frame_skip_text_entry) { - BodyItem *selected = tabs[selected_tab].body->get_selected(); - if(selected) { - if(!display_url_or_image(selected)) - display_url_or_image(selected->embedded_item.get()); + if((selected_tab == MESSAGES_TAB_INDEX || selected_tab == PINNED_TAB_INDEX) && !frame_skip_text_entry) { + if(event.key.code == sf::Keyboard::Enter) { + BodyItem *selected = tabs[selected_tab].body->get_selected(); + if(selected) { + if(!display_url_or_image(selected)) + display_url_or_image(selected->embedded_item.get()); + } + } else if(event.key.code == sf::Keyboard::S && event.key.control) { + BodyItem *selected = tabs[selected_tab].body->get_selected(); + if(selected) { + if(!download_selected_item(selected)) + download_selected_item(selected->embedded_item.get()); + } } } |