aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2020-10-16 19:44:18 +0200
committerdec05eba <dec05eba@protonmail.com>2020-10-16 19:44:24 +0200
commit0f6813a68d7f54c811b5040bdea37ca7b7e1b86e (patch)
tree8275a5750add009dca549c1e4388b52ff83bcc2b /src
parentf0539547ffe1de0d85822f10264a4a110e4344a2 (diff)
Matrix: Change keybindings to not use ctrl, and add U to upload media
Diffstat (limited to 'src')
-rw-r--r--src/QuickMedia.cpp135
1 files changed, 72 insertions, 63 deletions
diff --git a/src/QuickMedia.cpp b/src/QuickMedia.cpp
index cea2afb..cec81c6 100644
--- a/src/QuickMedia.cpp
+++ b/src/QuickMedia.cpp
@@ -2979,7 +2979,7 @@ namespace QuickMedia {
sf::Sprite logo_sprite(plugin_logo);
- Entry chat_input("Press ctrl+m to begin writing a message...", font.get(), cjk_font.get());
+ Entry chat_input("Press m or i to begin writing a message...", font.get(), cjk_font.get());
chat_input.draw_background = false;
chat_input.set_editable(false);
@@ -3259,68 +3259,6 @@ namespace QuickMedia {
}
}
- if(tabs[selected_tab].type == ChatTabType::MESSAGES && ((event.key.control && event.key.code == sf::Keyboard::M) || event.key.code == sf::Keyboard::I)) {
- chat_input.set_editable(true);
- chat_state = ChatState::TYPING_MESSAGE;
- }
-
- if(tabs[selected_tab].type == ChatTabType::MESSAGES && event.key.control && event.key.code == sf::Keyboard::V) {
- // TODO: Make asynchronous.
- // TODO: Upload multiple files.
- std::string err_msg;
- if(matrix->post_file(current_room_id, sf::Clipboard::getString(), err_msg) != PluginResult::OK) {
- std::string desc = "Failed to upload media to room, error: " + err_msg;
- show_notification("QuickMedia", desc.c_str(), Urgency::CRITICAL);
- }
- }
-
- if(tabs[selected_tab].type == ChatTabType::MESSAGES && event.key.control && event.key.code == sf::Keyboard::R) {
- std::shared_ptr<BodyItem> selected = tabs[selected_tab].body->get_selected_shared();
- if(selected) {
- chat_state = ChatState::REPLYING;
- currently_operating_on_item = selected;
- chat_input.set_editable(true);
- replying_to_text.setString("Replying to:");
- } else {
- // TODO: Show inline notification
- show_notification("QuickMedia", "No message selected for replying");
- }
- } else if(tabs[selected_tab].type == ChatTabType::MESSAGES && event.key.control && event.key.code == sf::Keyboard::E) {
- std::shared_ptr<BodyItem> selected = tabs[selected_tab].body->get_selected_shared();
- if(selected) {
- if(!selected->url.empty()) { // cant edit messages that are image/video posts
- // TODO: Show inline notification
- show_notification("QuickMedia", "You can only edit messages with no file attached to it");
- } else if(!matrix->was_message_posted_by_me(selected->userdata)) {
- // TODO: Show inline notification
- show_notification("QuickMedia", "You can't edit a message that was posted by somebody else");
- } else {
- chat_state = ChatState::EDITING;
- currently_operating_on_item = selected;
- chat_input.set_editable(true);
- chat_input.set_text(selected->get_description()); // TODO: Description? it may change in the future, in which case this should be edited
- chat_input.move_caret_to_end();
- replying_to_text.setString("Editing message:");
- }
- } else {
- // TODO: Show inline notification
- show_notification("QuickMedia", "No message selected for editing");
- }
- } else if(tabs[selected_tab].type == ChatTabType::MESSAGES && event.key.control && event.key.code == sf::Keyboard::D) {
- BodyItem *selected = tabs[selected_tab].body->get_selected();
- if(selected) {
- // TODO: Make asynchronous
- std::string err_msg;
- if(matrix->delete_message(current_room_id, selected->userdata, err_msg) != PluginResult::OK) {
- // TODO: Show inline notification
- show_notification("QuickMedia", "Failed to delete message, reason: " + err_msg, Urgency::CRITICAL);
- }
- } else {
- // TODO: Show inline notification
- show_notification("QuickMedia", "No message selected for deletion");
- }
- }
-
if(tabs[selected_tab].type == ChatTabType::MESSAGES && event.key.code == sf::Keyboard::Enter) {
BodyItem *selected = tabs[selected_tab].body->get_selected();
if(selected) {
@@ -3388,6 +3326,77 @@ namespace QuickMedia {
continue;
launch_url(selected_item->get_title());
}
+ } else if(event.type == sf::Event::KeyReleased && chat_state == ChatState::NAVIGATING && tabs[selected_tab].type == ChatTabType::MESSAGES) {
+ if(event.key.code == sf::Keyboard::U) {
+ new_page = PageType::FILE_MANAGER;
+ chat_input.set_editable(false);
+ }
+
+ if(event.key.code == sf::Keyboard::M || event.key.code == sf::Keyboard::I) {
+ chat_input.set_editable(true);
+ chat_state = ChatState::TYPING_MESSAGE;
+ }
+
+ if(event.key.control && event.key.code == sf::Keyboard::V) {
+ // TODO: Make asynchronous.
+ // TODO: Upload multiple files.
+ std::string err_msg;
+ if(matrix->post_file(current_room_id, sf::Clipboard::getString(), err_msg) != PluginResult::OK) {
+ std::string desc = "Failed to upload media to room, error: " + err_msg;
+ show_notification("QuickMedia", desc.c_str(), Urgency::CRITICAL);
+ }
+ }
+
+ if(event.key.code == sf::Keyboard::R) {
+ std::shared_ptr<BodyItem> selected = tabs[selected_tab].body->get_selected_shared();
+ if(selected) {
+ chat_state = ChatState::REPLYING;
+ currently_operating_on_item = selected;
+ chat_input.set_editable(true);
+ replying_to_text.setString("Replying to:");
+ } else {
+ // TODO: Show inline notification
+ show_notification("QuickMedia", "No message selected for replying");
+ }
+ }
+
+ if(event.key.code == sf::Keyboard::E) {
+ std::shared_ptr<BodyItem> selected = tabs[selected_tab].body->get_selected_shared();
+ if(selected) {
+ if(!selected->url.empty()) { // cant edit messages that are image/video posts
+ // TODO: Show inline notification
+ show_notification("QuickMedia", "You can only edit messages with no file attached to it");
+ } else if(!matrix->was_message_posted_by_me(selected->userdata)) {
+ // TODO: Show inline notification
+ show_notification("QuickMedia", "You can't edit a message that was posted by somebody else");
+ } else {
+ chat_state = ChatState::EDITING;
+ currently_operating_on_item = selected;
+ chat_input.set_editable(true);
+ chat_input.set_text(selected->get_description()); // TODO: Description? it may change in the future, in which case this should be edited
+ chat_input.move_caret_to_end();
+ replying_to_text.setString("Editing message:");
+ }
+ } else {
+ // TODO: Show inline notification
+ show_notification("QuickMedia", "No message selected for editing");
+ }
+ }
+
+ if(event.key.code == sf::Keyboard::D) {
+ BodyItem *selected = tabs[selected_tab].body->get_selected();
+ if(selected) {
+ // TODO: Make asynchronous
+ std::string err_msg;
+ if(matrix->delete_message(current_room_id, selected->userdata, err_msg) != PluginResult::OK) {
+ // TODO: Show inline notification
+ show_notification("QuickMedia", "Failed to delete message, reason: " + err_msg, Urgency::CRITICAL);
+ }
+ } else {
+ // TODO: Show inline notification
+ show_notification("QuickMedia", "No message selected for deletion");
+ }
+ }
}
if((chat_state == ChatState::TYPING_MESSAGE || chat_state == ChatState::REPLYING || chat_state == ChatState::EDITING) && tabs[selected_tab].type == ChatTabType::MESSAGES) {