diff options
author | dec05eba <dec05eba@protonmail.com> | 2021-09-03 01:26:14 +0200 |
---|---|---|
committer | dec05eba <dec05eba@protonmail.com> | 2021-09-03 01:26:14 +0200 |
commit | 6fbd76171b1f8f357524de20009380a93ca9bbf9 (patch) | |
tree | c6ac00d9ad26151f6357bc9b0823cc4b93481ccd /src/Utils.cpp | |
parent | 8c4e3217bf3e3c675f181c34f79448ba036dfcaf (diff) |
Add QM_FONT_SCALE environment variable to set font scale. Also add QM_SCALE to not have to rely on GDK_SCALE or xft.dpi
Diffstat (limited to 'src/Utils.cpp')
-rw-r--r-- | src/Utils.cpp | 33 |
1 files changed, 32 insertions, 1 deletions
diff --git a/src/Utils.cpp b/src/Utils.cpp index c73932b..3919bec 100644 --- a/src/Utils.cpp +++ b/src/Utils.cpp @@ -7,6 +7,8 @@ namespace QuickMedia { static float scale = 1.0f; static bool scale_set = false; + static float font_scale = 1.0f; + static bool font_scale_set = false; static bool qm_enable_touch = false; static bool qm_enable_touch_set = false; static bool wayland_display_set = false; @@ -46,9 +48,19 @@ namespace QuickMedia { if(scale_set) return scale; + setlocale(LC_ALL, "C"); // Sigh... stupid C + char *qm_scale = getenv("QM_SCALE"); + if(qm_scale) { + scale = atof(qm_scale); + if(scale < 0.0001f) + scale = 1.0f; + + scale_set = true; + return scale; + } + char *gdk_scale = getenv("GDK_SCALE"); if(gdk_scale) { - setlocale(LC_ALL, "C"); // Sigh... stupid C scale = atof(gdk_scale); if(scale < 0.0001f) scale = 1.0f; @@ -60,6 +72,24 @@ namespace QuickMedia { return scale; } + float get_font_scale() { + if(font_scale_set) + return font_scale; + + char *qm_font_scale = getenv("QM_FONT_SCALE"); + if(qm_font_scale) { + setlocale(LC_ALL, "C"); // Sigh... stupid C + font_scale = atof(qm_font_scale); + if(font_scale < 0.0001f) + font_scale = 1.0f; + } else { + font_scale = 1.0f; + } + + font_scale_set = true; + return font_scale; + } + void show_virtual_keyboard() { if(!is_touch_enabled()) return; @@ -88,6 +118,7 @@ namespace QuickMedia { return qm_enable_touch; } + // TODO: Find a better way to detect this. This will return true on ubuntu when running gnome in x11 mode bool is_running_wayland() { if(wayland_display_set) return wayland_display; |