aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.md8
-rw-r--r--src/QuickMedia.cpp135
2 files changed, 76 insertions, 67 deletions
diff --git a/README.md b/README.md
index e8631e2..00d47cf 100644
--- a/README.md
+++ b/README.md
@@ -46,10 +46,10 @@ 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 `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.\
-Press `Ctrl + D` to delete a message on matrix. Currently deleting a message only deletes the event, so if you delete an edit then the original message wont be deleted.\
+Press `M or I` to begin writing a message in a matrix room, press `ESC` to cancel.\
+Press `R` to reply to a message on matrix, press `ESC` to cancel.\
+Press `E` to edit a message on matrix, press `ESC` to cancel. Currently only works for your own messages.\
+Press `D` to delete a message on matrix. Currently deleting a message only deletes the event, so if you delete an edit then the original message wont be deleted.\
Press `Ctrl + V` to upload media to room in matrix, if the clipboard contains a path to an absolute filepath.
In the matrix client you can also navigate using VIM keys (H, J, K, L).
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) {