diff options
author | dec05eba <dec05eba@protonmail.com> | 2021-09-08 17:04:31 +0200 |
---|---|---|
committer | dec05eba <dec05eba@protonmail.com> | 2021-09-08 17:04:57 +0200 |
commit | da2988c4356d2756e86037b1c7e859f49583c109 (patch) | |
tree | 73ca076fa1a0f46fa3e3f1e6016d7bf479113491 /src/Config.cpp | |
parent | 24b0ed2ae8a0d52ceee647e34a943213e9d3bc89 (diff) |
Load theme from file (~/.config/quickmedia/themes/<theme-name>.json and /usr/share/quickmedia/themes/<theme-name>.json)
Diffstat (limited to 'src/Config.cpp')
-rw-r--r-- | src/Config.cpp | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/Config.cpp b/src/Config.cpp index b481374..31f8df9 100644 --- a/src/Config.cpp +++ b/src/Config.cpp @@ -58,7 +58,7 @@ namespace QuickMedia { } // No-op if this has already been called before - void init_config() { + static void init_config() { if(config_initialized) return; @@ -66,11 +66,16 @@ namespace QuickMedia { // Wtf? can't use static non-pointer config because it causes a segfault when setting config.theme. // It looks like a libc bug??? crashes for both gcc and clang. config = new Config(); + config->scale = get_ui_scale(); + Path config_path = get_storage_dir().join("config.json"); + if(get_file_type(config_path) != FileType::REGULAR) { + return; + } + Json::Value json_root; if(!read_file_as_json(config_path, json_root) || !json_root.isObject()) { fprintf(stderr, "Warning: failed to parse config file: %s\n", config_path.data.c_str()); - config->scale = get_ui_scale(); return; } |