aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2022-09-25 18:19:18 +0200
committerdec05eba <dec05eba@protonmail.com>2022-09-25 18:19:18 +0200
commite4d89350e2f239a833f7f337dd858570e7b52712 (patch)
tree08710eab456b61eca6f2bc41fff03e75f67f0971 /src
parent02165e3d0ea57d42f1559099408d8bb1b8838ba4 (diff)
Matrix: remove play/download prefix when downloading video/music/file or display it with mpv
Diffstat (limited to 'src')
-rw-r--r--src/QuickMedia.cpp32
1 files changed, 28 insertions, 4 deletions
diff --git a/src/QuickMedia.cpp b/src/QuickMedia.cpp
index beb3e84..23cd17b 100644
--- a/src/QuickMedia.cpp
+++ b/src/QuickMedia.cpp
@@ -6474,6 +6474,18 @@ namespace QuickMedia {
if(selected_item_message) {
MessageType message_type = selected_item_message->type;
if(!selected->url.empty()) {
+ const char *video_prefix = "🎥 Play ";
+ const char *music_prefix = "🎵 Play ";
+ const char *file_prefix = "💾 Download ";
+
+ std::string filename = selected_item_message->body;
+ if(string_starts_with(filename, video_prefix))
+ filename.erase(filename.begin(), filename.begin() + strlen(video_prefix));
+ else if(string_starts_with(filename, music_prefix))
+ filename.erase(filename.begin(), filename.begin() + strlen(music_prefix));
+ else if(string_starts_with(filename, file_prefix))
+ filename.erase(filename.begin(), filename.begin() + strlen(file_prefix));
+
if(message_type == MessageType::VIDEO || message_type == MessageType::IMAGE || message_type == MessageType::AUDIO) {
page_stack.push(PageType::CHAT);
watched_videos.clear();
@@ -6481,15 +6493,15 @@ namespace QuickMedia {
bool is_audio = (message_type == MessageType::AUDIO);
bool prev_no_video = no_video;
no_video = is_audio;
- auto video_page = std::make_unique<MatrixVideoPage>(this, selected_item_message->body);
+ auto video_page = std::make_unique<MatrixVideoPage>(this, filename);
video_page->set_url(selected->url);
- video_content_page(matrix_chat_page, video_page.get(), selected_item_message->body, message_type == MessageType::VIDEO || message_type == MessageType::AUDIO, nullptr, 0);
+ video_content_page(matrix_chat_page, video_page.get(), filename, message_type == MessageType::VIDEO || message_type == MessageType::AUDIO, nullptr, 0);
no_video = prev_no_video;
redraw = true;
avatar_applied = false;
return true;
} else if(message_type == MessageType::FILE) {
- download_async_gui(selected->url, file_manager_start_dir.string(), no_video, selected_item_message->body);
+ download_async_gui(selected->url, file_manager_start_dir.string(), no_video, filename);
return true;
}
@@ -6530,7 +6542,19 @@ namespace QuickMedia {
if(selected_item_message) {
MessageType message_type = selected_item_message->type;
if(!selected->url.empty() && message_type >= MessageType::IMAGE && message_type <= MessageType::FILE) {
- download_async_gui(selected->url, file_manager_start_dir.string(), no_video, selected_item_message->body);
+ const char *video_prefix = "🎥 Play ";
+ const char *music_prefix = "🎵 Play ";
+ const char *file_prefix = "💾 Download ";
+
+ std::string filename = selected_item_message->body;
+ if(string_starts_with(filename, video_prefix))
+ filename.erase(filename.begin(), filename.begin() + strlen(video_prefix));
+ else if(string_starts_with(filename, music_prefix))
+ filename.erase(filename.begin(), filename.begin() + strlen(music_prefix));
+ else if(string_starts_with(filename, file_prefix))
+ filename.erase(filename.begin(), filename.begin() + strlen(file_prefix));
+
+ download_async_gui(selected->url, file_manager_start_dir.string(), no_video, filename);
return true;
}
}