From 7492c9aa0df61e7bd7e136679a0ef90414ed1283 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Fri, 7 May 2021 03:46:55 +0200 Subject: Allow to reverse image search video thumbnail, add reverse image search to saucenao --- src/QuickMedia.cpp | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/QuickMedia.cpp b/src/QuickMedia.cpp index 4647787..0e4ba22 100644 --- a/src/QuickMedia.cpp +++ b/src/QuickMedia.cpp @@ -3217,9 +3217,13 @@ namespace QuickMedia { } } else if(event.key.code == sf::Keyboard::I && event.key.control) { BodyItem *selected_item = thread_body->get_selected(); - if(selected_item && !selected_item->url.empty()) { + if(selected_item && !selected_item->url.empty() && !selected_item->thumbnail_url.empty()) { + std::string image_url = selected_item->url; + if(is_url_video(selected_item->url)) + image_url = selected_item->thumbnail_url; + std::vector saucenao_tabs; - saucenao_tabs.push_back(Tab{create_body(), std::make_unique(this, selected_item->url, false), nullptr}); + saucenao_tabs.push_back(Tab{create_body(), std::make_unique(this, image_url, false), nullptr}); page_loop(saucenao_tabs); redraw = true; frame_skip_text_entry = true; @@ -4881,6 +4885,28 @@ namespace QuickMedia { tabs[selected_tab].body.get()->select_last_item(); } else if(event.key.code == sf::Keyboard::Escape) { goto chat_page_end; + } else if(event.key.code == sf::Keyboard::I && event.key.control) { + BodyItem *selected_item = tabs[selected_tab].body->get_selected(); + if(selected_item && !selected_item->url.empty() && !selected_item->thumbnail_url.empty()) { + Message *selected_item_message = nullptr; + if(selected_tab == MESSAGES_TAB_INDEX) { + selected_item_message = static_cast(selected_item->userdata); + } else if(selected_tab == PINNED_TAB_INDEX && static_cast(selected_item->userdata)->status == FetchStatus::FINISHED_LOADING) { + selected_item_message = static_cast(selected_item->userdata)->message; + } + + if(selected_item_message && (selected_item_message->type == MessageType::IMAGE || selected_item_message->type == MessageType::VIDEO)) { + std::string image_url = selected_item->url; + if(selected_item_message->type == MessageType::VIDEO) + image_url = selected_item->thumbnail_url; + + std::vector saucenao_tabs; + saucenao_tabs.push_back(Tab{create_body(), std::make_unique(this, image_url, false), nullptr}); + page_loop(saucenao_tabs); + redraw = true; + frame_skip_text_entry = true; + } + } } if((selected_tab == MESSAGES_TAB_INDEX || selected_tab == PINNED_TAB_INDEX) && event.key.code == sf::Keyboard::Enter && !frame_skip_text_entry) { -- cgit v1.2.3