aboutsummaryrefslogtreecommitdiff
path: root/src/QuickMedia.cpp
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2022-10-29 19:31:22 +0200
committerdec05eba <dec05eba@protonmail.com>2022-10-29 19:31:22 +0200
commit555f0e7e910b2231073734816727379e1276aa6c (patch)
tree2081bb231c0526e8fa20f195e049af6d23d2525d /src/QuickMedia.cpp
parent1b82048e16ae998c780a31ff14317d4ac1fbbacd (diff)
Matrix: add media reply with ctrl+u
Diffstat (limited to 'src/QuickMedia.cpp')
-rw-r--r--src/QuickMedia.cpp34
1 files changed, 31 insertions, 3 deletions
diff --git a/src/QuickMedia.cpp b/src/QuickMedia.cpp
index 57c5489..13931d2 100644
--- a/src/QuickMedia.cpp
+++ b/src/QuickMedia.cpp
@@ -5864,15 +5864,19 @@ namespace QuickMedia {
}
};
- auto upload_file = [this, &current_room](const std::string &filepath, const std::string &filename) {
- run_task_with_loading_screen([this, &current_room, filepath, filename]() {
+ auto upload_file = [this, &current_room, &tabs, &ui_tabs, &chat_state](const std::string &filepath, const std::string &filename) {
+ const int selected_tab = ui_tabs.get_selected();
+ std::shared_ptr<BodyItem> selected = tabs[selected_tab].body->get_selected_shared();
+ void *message_to_reply_to = chat_state == ChatState::REPLYING ? selected->userdata : nullptr;
+
+ run_task_with_loading_screen([this, &current_room, filepath, filename, message_to_reply_to]() {
std::string filepath_mod = filepath;
if(string_starts_with(filepath_mod, "file://"))
filepath_mod.erase(filepath_mod.begin(), filepath_mod.begin() + 7);
std::string event_id_response;
std::string err_msg;
- if(matrix->post_file(current_room, filepath_mod, filename, event_id_response, err_msg) == PluginResult::OK) {
+ if(matrix->post_file(current_room, filepath_mod, filename, event_id_response, err_msg, message_to_reply_to) == PluginResult::OK) {
return true;
} else {
show_notification("QuickMedia", "Failed to upload media to room, error: " + err_msg, Urgency::CRITICAL);
@@ -7102,6 +7106,14 @@ namespace QuickMedia {
continue;
launch_url(selected_item->get_title());
}
+ } else if(event.type == mgl::Event::KeyPressed && chat_state == ChatState::REPLYING) {
+ if(selected_tab == MESSAGES_TAB_INDEX) {
+ if(event.key.code == mgl::Keyboard::U && event.key.control) {
+ frame_skip_text_entry = true;
+ new_page = PageType::FILE_MANAGER;
+ chat_input.set_editable(false);
+ }
+ }
}
if((chat_state == ChatState::TYPING_MESSAGE || chat_state == ChatState::REPLYING || chat_state == ChatState::EDITING) && selected_tab == MESSAGES_TAB_INDEX && !frame_skip_text_entry) {
@@ -7190,6 +7202,22 @@ namespace QuickMedia {
}
redraw = true;
avatar_applied = false;
+
+ if(selected_files.empty()) {
+ if(chat_state == ChatState::REPLYING)
+ chat_input.set_editable(true);
+ } else {
+ mention.hide();
+ chat_input.set_editable(false);
+ chat_input.set_text("");
+ chat_state = ChatState::NAVIGATING;
+ currently_operating_on_item = nullptr;
+ if(typing && current_room) {
+ fprintf(stderr, "Stopped typing\n");
+ typing = false;
+ typing_state_queue.push(false);
+ }
+ }
break;
}
case PageType::CHAT_LOGIN: {