diff options
author | dec05eba <dec05eba@protonmail.com> | 2021-05-07 03:46:55 +0200 |
---|---|---|
committer | dec05eba <dec05eba@protonmail.com> | 2021-05-07 03:46:55 +0200 |
commit | 7492c9aa0df61e7bd7e136679a0ef90414ed1283 (patch) | |
tree | 50e30ad094e3d92b3b1dfccda27f1a75e6907f8a | |
parent | 27eac1c56904a853e79d66e1cf4daac7d8f8ba6b (diff) |
Allow to reverse image search video thumbnail, add reverse image search to saucenao
-rw-r--r-- | README.md | 2 | ||||
-rw-r--r-- | src/QuickMedia.cpp | 30 |
2 files changed, 29 insertions, 3 deletions
@@ -57,7 +57,7 @@ Press `Ctrl + C` to copy the text of the selected item to the clipboard.\ Press `U` in matrix or in a 4chan thread to bring up the file manager to choose a file to upload.\ Press `Ctrl + V` to upload media to room in matrix if the clipboard contains a valid absolute filepath.\ Press `Ctrl + D` to remove the file that was previously selected with `U` in a 4chan thread.\ -Press `Ctrl + I` to reverse image search the selected image on 4chan.\ +Press `Ctrl + I` to reverse image search the selected image on 4chan or matrix.\ Press `Ctrl+Alt+Arrow up` / `Ctrl+Alt+Arrow down` or `Ctrl+Alt+K` / `Ctrl+Alt+J` to view the room above/below the selected room in matrix. In matrix you can select a message with enter to open the url in the message (or if there are multiple urls then a menu will appear for selecting which to open). 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<Tab> saucenao_tabs; - saucenao_tabs.push_back(Tab{create_body(), std::make_unique<SaucenaoPage>(this, selected_item->url, false), nullptr}); + saucenao_tabs.push_back(Tab{create_body(), std::make_unique<SaucenaoPage>(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<Message*>(selected_item->userdata); + } else if(selected_tab == PINNED_TAB_INDEX && static_cast<PinnedEventData*>(selected_item->userdata)->status == FetchStatus::FINISHED_LOADING) { + selected_item_message = static_cast<PinnedEventData*>(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<Tab> saucenao_tabs; + saucenao_tabs.push_back(Tab{create_body(), std::make_unique<SaucenaoPage>(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) { |