From 1c4d47f35274d560ee9eb855d7f1c45dd4dd140c Mon Sep 17 00:00:00 2001 From: Miquel Lionel Date: Fri, 13 Oct 2023 00:05:26 +0200 Subject: Add keyboard shortcut and setting to increase text size (fixes #978) * Can zoom in / out or reset zoom levels via shortcuts * Can change zoom value via global preferences window --- libdino/src/entity/settings.vala | 19 +++++++++++++++++++ main/data/gtk/help-overlay.ui | 18 ++++++++++++++++++ main/data/settings_dialog.ui | 13 ++++++++++++- main/src/ui/application.vala | 33 ++++++++++++++++++++++++++++++--- main/src/ui/settings_dialog.vala | 6 +++++- 5 files changed, 84 insertions(+), 5 deletions(-) diff --git a/libdino/src/entity/settings.vala b/libdino/src/entity/settings.vala index 0b09e9b9..a488e20f 100644 --- a/libdino/src/entity/settings.vala +++ b/libdino/src/entity/settings.vala @@ -12,6 +12,7 @@ public class Settings : Object { notifications_ = col_to_bool_or_default("notifications", true); convert_utf8_smileys_ = col_to_bool_or_default("convert_utf8_smileys", true); check_spelling = col_to_bool_or_default("check_spelling", true); + zoom_level = col_to_int_or_default("zoom_level", 100); } private bool col_to_bool_or_default(string key, bool def) { @@ -19,6 +20,24 @@ 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]; + return val != null ? int.parse(val) : def; + } + + public int zoom_level_; + public int zoom_level { + get { return zoom_level_; } + set { + if (value == zoom_level_) return; + db.settings.upsert() + .value(db.settings.key, "zoom_level", true) + .value(db.settings.value, value.to_string()) + .perform(); + zoom_level_ = value; + } + } + private bool send_typing_; public bool send_typing { get { return send_typing_; } diff --git a/main/data/gtk/help-overlay.ui b/main/data/gtk/help-overlay.ui index 17b0555c..bb3bb437 100644 --- a/main/data/gtk/help-overlay.ui +++ b/main/data/gtk/help-overlay.ui @@ -26,6 +26,24 @@ Keyboard shortcuts + + + <ctrl>plus + Increase text size + + + + + <ctrl>minus + Lower text size + + + + + <ctrl>0 + Resets text size to default + + diff --git a/main/data/settings_dialog.ui b/main/data/settings_dialog.ui index a8b24135..ac7397a0 100644 --- a/main/data/settings_dialog.ui +++ b/main/data/settings_dialog.ui @@ -2,13 +2,24 @@