From e68a086bca8cf462c1d4d2528ac405f09a659670 Mon Sep 17 00:00:00 2001 From: ouwou <26526779+ouwou@users.noreply.github.com> Date: Mon, 2 Oct 2023 22:24:12 -0400 Subject: [PATCH] add gui.font_scale setting --- README.md | 2 +- src/abaddon.cpp | 7 +++++++ src/settings.cpp | 11 +++++++++++ src/settings.hpp | 1 + 4 files changed, 20 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index c7e6111b..0cb52d2f 100644 --- a/README.md +++ b/README.md @@ -75,7 +75,6 @@ the result of fundamental issues with Discord's thread implementation. 5. `make` 6. [Copy resources](#resources) - #### Linux: 1. Install dependencies @@ -300,6 +299,7 @@ For example, memory_db would be set by adding `memory_db = true` under the line | `save_state` | boolean | true | save the state of the gui (active channels, tabs, expanded channels) | | `alt_menu` | boolean | false | keep the menu hidden unless revealed with alt key | | `hide_to_tray` | boolean | false | hide abaddon to the system tray on window close | +| `font_scale` | double | | scale font rendering. 1 is unchanged | #### style diff --git a/src/abaddon.cpp b/src/abaddon.cpp index a8360c2b..65571824 100644 --- a/src/abaddon.cpp +++ b/src/abaddon.cpp @@ -263,6 +263,13 @@ int Abaddon::StartGTK() { } #endif + if (m_settings.GetSettings().FontScale > 0.0) { + auto dpi = Gdk::Screen::get_default()->get_resolution(); + if (dpi < 0.0) dpi = 96.0; + auto newdpi = dpi * 1024.0 * m_settings.GetSettings().FontScale; + Gtk::Settings::get_default()->set_property("gtk-xft-dpi", newdpi); + } + // store must be checked before this can be called m_main_window->UpdateComponents(); diff --git a/src/settings.cpp b/src/settings.cpp index 601205a9..f910ff70 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -42,6 +42,10 @@ void SettingsManager::ReadSettings() { try { \ m_settings.var = m_file.get_integer(section, key); \ } catch (...) {} +#define SMFLT(section, key, var) \ + try { \ + m_settings.var = m_file.get_double(section, key); \ + } catch (...) {} SMSTR("discord", "api_base", APIBaseURL); SMSTR("discord", "gateway", GatewayURL); @@ -59,6 +63,7 @@ void SettingsManager::ReadSettings() { SMBOOL("gui", "unreads", Unreads); SMBOOL("gui", "alt_menu", AltMenu); SMBOOL("gui", "hide_to_tray", HideToTray); + SMFLT("gui", "font_scale", FontScale); SMINT("http", "concurrent", CacheHTTPConcurrency); SMSTR("http", "user_agent", UserAgent); SMSTR("style", "expandercolor", ChannelsExpanderColor); @@ -102,6 +107,7 @@ void SettingsManager::ReadSettings() { #undef SMBOOL #undef SMSTR #undef SMINT +#undef SMFLT m_read_settings = m_settings; } @@ -127,6 +133,9 @@ void SettingsManager::Close() { #define SMINT(section, key, var) \ if (m_settings.var != m_read_settings.var) \ m_file.set_integer(section, key, m_settings.var); +#define SMFLT(section, key, var) \ + if (m_settings.var != m_read_settings.var) \ + m_file.set_double(section, key, m_settings.var); SMSTR("discord", "api_base", APIBaseURL); SMSTR("discord", "gateway", GatewayURL); @@ -144,6 +153,7 @@ void SettingsManager::Close() { SMBOOL("gui", "unreads", Unreads); SMBOOL("gui", "alt_menu", AltMenu); SMBOOL("gui", "hide_to_tray", HideToTray); + SMFLT("gui", "font_scale", FontScale); SMINT("http", "concurrent", CacheHTTPConcurrency); SMSTR("http", "user_agent", UserAgent); SMSTR("style", "expandercolor", ChannelsExpanderColor); @@ -172,6 +182,7 @@ void SettingsManager::Close() { #undef SMSTR #undef SMBOOL #undef SMINT +#undef SMFLT try { if (!m_file.save_to_file(m_filename)) diff --git a/src/settings.hpp b/src/settings.hpp index 0d2e68b2..7c6368fb 100644 --- a/src/settings.hpp +++ b/src/settings.hpp @@ -30,6 +30,7 @@ class SettingsManager { bool Unreads { true }; bool AltMenu { false }; bool HideToTray { false }; + double FontScale { -1.0 }; // [http] int CacheHTTPConcurrency { 20 };