diff options
Diffstat (limited to 'libdino/src/entity/settings.vala')
| -rw-r--r-- | libdino/src/entity/settings.vala | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/libdino/src/entity/settings.vala b/libdino/src/entity/settings.vala index 8a3eb2fe..7d0f03c8 100644 --- a/libdino/src/entity/settings.vala +++ b/libdino/src/entity/settings.vala @@ -21,6 +21,7 @@ public class Settings : Object { notifications_connection_errors_ = col_to_bool_or_default("notifications_connection_errors", true); convert_utf8_smileys_ = col_to_bool_or_default("convert_utf8_smileys", true); check_spelling = col_to_bool_or_default("check_spelling", true); + avatar_roundness_ = col_to_int_or_default("avatar_roundness", 20).clamp(0, 100); } private bool col_to_bool_or_default(string key, bool def) { @@ -28,6 +29,12 @@ public class Settings : Object { return val != null ? bool.parse(val) : def; } + private int col_to_int_or_default(string key, int def) { + string? val = db.settings.select({db.settings.value}).with(db.settings.key, "=", key)[db.settings.value]; + int parsed = def; + return val != null && int.try_parse(val, out parsed) ? parsed : def; + } + private bool send_typing_; public bool send_typing { get { return send_typing_; } @@ -173,6 +180,19 @@ public class Settings : Object { } } + private int avatar_roundness_; + public int avatar_roundness { + get { return avatar_roundness_; } + set { + int clamped_value = value.clamp(0, 100); + db.settings.upsert() + .value(db.settings.key, "avatar_roundness", true) + .value(db.settings.value, clamped_value.to_string()) + .perform(); + avatar_roundness_ = clamped_value; + } + } + public Encryption get_default_encryption(Account account) { string? setting = db.account_settings.get_value(account.id, "default-encryption"); if (setting != null) { |
