Skip to content

Commit

Permalink
add gui.font_scale setting
Browse files Browse the repository at this point in the history
  • Loading branch information
ouwou committed Oct 3, 2023
1 parent 483b547 commit e68a086
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 1 deletion.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ the result of fundamental issues with Discord's thread implementation.
5. `make`
6. [Copy resources](#resources)


#### Linux:

1. Install dependencies
Expand Down Expand Up @@ -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
Expand Down
7 changes: 7 additions & 0 deletions src/abaddon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
11 changes: 11 additions & 0 deletions src/settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand Down Expand Up @@ -102,6 +107,7 @@ void SettingsManager::ReadSettings() {
#undef SMBOOL
#undef SMSTR
#undef SMINT
#undef SMFLT

m_read_settings = m_settings;
}
Expand All @@ -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);
Expand All @@ -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);
Expand Down Expand Up @@ -172,6 +182,7 @@ void SettingsManager::Close() {
#undef SMSTR
#undef SMBOOL
#undef SMINT
#undef SMFLT

try {
if (!m_file.save_to_file(m_filename))
Expand Down
1 change: 1 addition & 0 deletions src/settings.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ class SettingsManager {
bool Unreads { true };
bool AltMenu { false };
bool HideToTray { false };
double FontScale { -1.0 };

// [http]
int CacheHTTPConcurrency { 20 };
Expand Down

0 comments on commit e68a086

Please sign in to comment.