aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.md2
-rw-r--r--src/QuickMedia.cpp35
2 files changed, 23 insertions, 14 deletions
diff --git a/README.md b/README.md
index f83ac60..7d65bd0 100644
--- a/README.md
+++ b/README.md
@@ -46,7 +46,7 @@ Press `Tab` to autocomplete a search when autocomplete is available (currently o
Press `Tab` to switch between username/password field in login panel.\
Press `Ctrl + C` to copy the url of the currently playing video to the clipboard (with timestamp).\
Press `Ctrl + V` to paste the content of your clipboard into the search bar.\
-Press `Ctrl + P` to view image/video attached to matrix message.\
+Press `Enter` to view image/video attached to matrix message, or to view the url in the message in quickmedia (youtube) or in the browser.\
Press `Ctrl + M` to begin writing a message in a matrix room, press `ESC` to cancel.\
Press `Ctrl + R` to reply to a message on matrix, press `ESC` to cancel.\
Press `Ctrl + E` to edit a message on matrix, press `ESC` to cancel. Currently only works for your own messages.\
diff --git a/src/QuickMedia.cpp b/src/QuickMedia.cpp
index 9460ec6..709dfea 100644
--- a/src/QuickMedia.cpp
+++ b/src/QuickMedia.cpp
@@ -3673,19 +3673,28 @@ namespace QuickMedia {
if(tabs[selected_tab].type == ChatTabType::MESSAGES && event.key.code == sf::Keyboard::Enter) {
BodyItem *selected = tabs[selected_tab].body->get_selected();
if(selected) {
- // TODO: Change this when messages are not stored in the description
- const std::string &message_str = selected->get_description();
- auto urls_begin = std::sregex_iterator(message_str.begin(), message_str.end(), url_extract_regex);
- auto urls_end = std::sregex_iterator();
- size_t num_urls = std::distance(urls_begin, urls_end);
- if(num_urls == 1) {
- launch_url(urls_begin->str());
- } else if(num_urls > 1) {
- chat_state = ChatState::URL_SELECTION;
- url_selection_body.clear_items();
- for(auto it = urls_begin; it != urls_end; ++it) {
- auto body_item = BodyItem::create(it->str());
- url_selection_body.items.push_back(std::move(body_item));
+ if(!selected->url.empty()) {
+ page_stack.push(Page::CHAT);
+ watched_videos.clear();
+ content_url = selected->url;
+ current_page = Page::VIDEO_CONTENT;
+ video_content_page();
+ redraw = true;
+ } else {
+ // TODO: Change this when messages are not stored in the description
+ const std::string &message_str = selected->get_description();
+ auto urls_begin = std::sregex_iterator(message_str.begin(), message_str.end(), url_extract_regex);
+ auto urls_end = std::sregex_iterator();
+ size_t num_urls = std::distance(urls_begin, urls_end);
+ if(num_urls == 1) {
+ launch_url(urls_begin->str());
+ } else if(num_urls > 1) {
+ chat_state = ChatState::URL_SELECTION;
+ url_selection_body.clear_items();
+ for(auto it = urls_begin; it != urls_end; ++it) {
+ auto body_item = BodyItem::create(it->str());
+ url_selection_body.items.push_back(std::move(body_item));
+ }
}
}
}