aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--example-config.json4
-rw-r--r--include/Config.hpp1
-rw-r--r--src/Config.cpp1
-rw-r--r--src/QuickMedia.cpp18
4 files changed, 18 insertions, 6 deletions
diff --git a/example-config.json b/example-config.json
index cb332f0..1977b1e 100644
--- a/example-config.json
+++ b/example-config.json
@@ -77,7 +77,9 @@
"send_read_receipts": true,
// If you want others to know when you are typing a message in the room
"send_typing_notifications": true,
- "appear_online": true
+ "appear_online": true,
+ // If the chat message should be removed when you press ESC
+ "clear_message_on_escape": true
},
"peertube": {
// List of instances to display when opening peertube
diff --git a/include/Config.hpp b/include/Config.hpp
index 6f908c8..0b0f021 100644
--- a/include/Config.hpp
+++ b/include/Config.hpp
@@ -62,6 +62,7 @@ namespace QuickMedia {
bool send_read_receipts = true;
bool send_typing_notifications = true;
bool appear_online = true;
+ bool clear_message_on_escape = true;
};
struct PeertubeConfig {
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();