aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2023-12-20 12:03:18 +0100
committerdec05eba <dec05eba@protonmail.com>2023-12-20 12:03:18 +0100
commit1a20c29eeba5edfd51068b5bec6ec53af0629d38 (patch)
tree128097f38e231bae00f06ee60b92019a90c16208 /src
parent8b5ebcf85b0dd7c4addc02028ae53b1f4fee9391 (diff)
Matrix: revert not clearing text on esc, make it an option 'matrix.clear_message_on_escape' instead
Diffstat (limited to 'src')
-rw-r--r--src/Config.cpp1
-rw-r--r--src/QuickMedia.cpp18
2 files changed, 14 insertions, 5 deletions
diff --git a/src/Config.cpp b/src/Config.cpp
index e8f67f6..2d44ed1 100644
--- a/src/Config.cpp
+++ b/src/Config.cpp
@@ -243,6 +243,7 @@ namespace QuickMedia {
get_json_value(matrix_json, "send_read_receipts", config->matrix.send_read_receipts);
get_json_value(matrix_json, "send_typing_notifications", config->matrix.send_typing_notifications);
get_json_value(matrix_json, "appear_online", config->matrix.appear_online);
+ get_json_value(matrix_json, "clear_message_on_escape", config->matrix.clear_message_on_escape);
}
if(!has_known_matrix_homeservers_config)
diff --git a/src/QuickMedia.cpp b/src/QuickMedia.cpp
index f7dab9f..7cea5e2 100644
--- a/src/QuickMedia.cpp
+++ b/src/QuickMedia.cpp
@@ -7195,7 +7195,7 @@ namespace QuickMedia {
RoomExtraData &room_extra_data = matrix->get_room_extra_data(current_room);
frame_skip_text_entry = true;
chat_input.set_editable(true);
- if(!room_extra_data.editing_message_id.empty()) {
+ if(get_config().matrix.clear_message_on_escape || !room_extra_data.editing_message_id.empty()) {
chat_input.set_text("");
room_extra_data.editing_message_id.clear();
}
@@ -7290,7 +7290,7 @@ namespace QuickMedia {
chat_state = ChatState::REPLYING;
currently_operating_on_item = selected;
chat_input.set_editable(true);
- if(!room_extra_data.editing_message_id.empty()) {
+ if(get_config().matrix.clear_message_on_escape || !room_extra_data.editing_message_id.empty()) {
chat_input.set_text("");
room_extra_data.editing_message_id.clear();
}
@@ -7329,7 +7329,7 @@ namespace QuickMedia {
chat_state = ChatState::EDITING;
currently_operating_on_item = selected;
chat_input.set_editable(true);
- if(chat_input.get_text().empty() || room_extra_data.editing_message_id.empty() || message->event_id != room_extra_data.editing_message_id) {
+ if(get_config().matrix.clear_message_on_escape || chat_input.get_text().empty() || room_extra_data.editing_message_id.empty() || message->event_id != room_extra_data.editing_message_id) {
chat_input.set_text(std::move(body_text_unformatted)); // TODO: Description? it may change in the future, in which case this should be edited
}
chat_input.move_caret_to_end();
@@ -7463,6 +7463,8 @@ namespace QuickMedia {
if(mention.visible) {
mention.hide();
} else {
+ if(get_config().matrix.clear_message_on_escape)
+ chat_input.set_text("");
chat_input.set_editable(false);
chat_state = ChatState::NAVIGATING;
currently_operating_on_item = nullptr;
@@ -7536,7 +7538,12 @@ namespace QuickMedia {
if(selected_files.empty()) {
if(chat_state == ChatState::REPLYING)
chat_input.set_editable(true);
- } else {
+ } else if(get_config().matrix.clear_message_on_escape) {
+ 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;
@@ -7988,7 +7995,8 @@ namespace QuickMedia {
}
chat_page_end:
- matrix->get_room_extra_data(current_room).chat_message = chat_input.get_text();
+ if(!get_config().matrix.clear_message_on_escape)
+ matrix->get_room_extra_data(current_room).chat_message = chat_input.get_text();
matrix_chat_page->set_current_room(nullptr, nullptr, nullptr);
fetch_messages_future.cancel();
cleanup_tasks();