add gui.font_scale setting

This commit is contained in:
ouwou
2023-10-02 22:24:12 -04:00
parent 483b547a64
commit e68a086bca
4 changed files with 20 additions and 1 deletions

View File

@@ -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

View File

@@ -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();

View File

@@ -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))

View File

@@ -30,6 +30,7 @@ public:
bool Unreads { true };
bool AltMenu { false };
bool HideToTray { false };
double FontScale { -1.0 };
// [http]
int CacheHTTPConcurrency { 20 };