From da2988c4356d2756e86037b1c7e859f49583c109 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Wed, 8 Sep 2021 17:04:31 +0200 Subject: Load theme from file (~/.config/quickmedia/themes/.json and /usr/share/quickmedia/themes/.json) --- src/Config.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'src/Config.cpp') 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; } -- cgit v1.2.3