From f2096694c6b17de1dd120773f870fced33a4834b Mon Sep 17 00:00:00 2001 From: Xavier Del Campo Romero Date: Wed, 27 Mar 2024 14:40:56 +0300 Subject: [PATCH] Add send button / Enter key settings Two new switches have been added to the application preferences: - Enable send button - Use Enter to insert newline ('\n') The latter cannot be active or sensitive if the former is not active. Otherwise, users would not be able to send messages. Thanks to horazont for suggesting a separate switch for the behaviour of the Enter key. --- libdino/src/entity/settings.vala | 28 +++++++++++++++++++++ main/data/chat_input.ui | 20 ++++++++++++--- main/data/settings_dialog.ui | 29 ++++++++++++++++++++++ main/src/ui/chat_input/chat_text_view.vala | 5 +++- main/src/ui/chat_input/view.vala | 22 ++++++++++++++++ main/src/ui/settings_dialog.vala | 14 +++++++++++ 6 files changed, 114 insertions(+), 4 deletions(-) diff --git a/libdino/src/entity/settings.vala b/libdino/src/entity/settings.vala index dbad9650..8f39713f 100644 --- a/libdino/src/entity/settings.vala +++ b/libdino/src/entity/settings.vala @@ -13,6 +13,8 @@ public class Settings : Object { convert_utf8_smileys_ = col_to_bool_or_default("convert_utf8_smileys", true); check_spelling = col_to_bool_or_default("check_spelling", true); default_encryption = col_to_encryption_or_default("default_encryption", Encryption.UNKNOWN); + send_button = col_to_bool_or_default("send_button", false); + enter_newline = col_to_bool_or_default("enter_newline", false); } private bool col_to_bool_or_default(string key, bool def) { @@ -100,6 +102,32 @@ public class Settings : Object { } } + + public signal void send_button_update(bool visible); + private bool send_button_; + public bool send_button { + get { return send_button_; } + set { + db.settings.upsert() + .value(db.settings.key, "send_button", true) + .value(db.settings.value, value.to_string()) + .perform(); + send_button_ = value; + send_button_update(value); + } + } + + private bool enter_newline_; + public bool enter_newline { + get { return enter_newline_; } + set { + db.settings.upsert() + .value(db.settings.key, "enter_newline", true) + .value(db.settings.value, value.to_string()) + .perform(); + enter_newline_ = value; + } + } } } diff --git a/main/data/chat_input.ui b/main/data/chat_input.ui index cde00b22..b490b765 100644 --- a/main/data/chat_input.ui +++ b/main/data/chat_input.ui @@ -17,7 +17,7 @@ mail-attachment-symbolic 2 - start + center + + + + + mail-send-symbolic + False + 2 + center + false