diff --git a/src/util/config.cpp b/src/util/config.cpp index e93f8de1..206df706 100644 --- a/src/util/config.cpp +++ b/src/util/config.cpp @@ -57,10 +57,6 @@ void set_defaults() void load() { - /* Assure that ~/.config folder exists */ - if (!QDir::home().exists(".config") && !QDir::home().mkdir(".config")) - berr("Couldn't create ~/.config, configuration files won't be saved"); - enable_uiohook = CGET_BOOL(S_UIOHOOK); enable_gamepad_hook = CGET_BOOL(S_GAMEPAD); enable_websocket_server = CGET_BOOL(S_ENABLE_WSS); diff --git a/src/util/input_filter.cpp b/src/util/input_filter.cpp index 42c0c1c8..053a623b 100644 --- a/src/util/input_filter.cpp +++ b/src/util/input_filter.cpp @@ -32,10 +32,18 @@ void input_filter::read_from_config() m_regex = CGET_BOOL(S_REGEX); m_whitelist = CGET_INT(S_FILTER_MODE) == 0; QJsonDocument j; - if (!util_open_json(util_get_data_file("filters.json"), j)) { - berr("Couldn't load filters.json"); - return; + + char* path = obs_module_config_path("filters.json"); + + if (!util_open_json(utf8_to_qt(path), j)) { + berr("Couldn't load filters.json from plugin config, trying legacy location"); + if (!util_open_json(util_get_data_file_legacy("filters.json"), j)) { + berr("Couldn't load filters.json from legacy location"); + bfree(path); + return; + } } + bfree(path); if (j.isArray()) { for (const auto &item : j.array()) { @@ -57,8 +65,10 @@ void input_filter::write_to_config() for (const auto &filter : m_filters) arr.append(filter); j.setArray(arr); - util_write_json(util_get_data_file("filters.json"), j); + char* path = obs_module_config_path("filters.json"); + util_write_json(utf8_to_qt(path), j); io_config::filter_mutex.unlock(); + bfree(path); } void input_filter::add_filter(const char *filter) diff --git a/src/util/obs_util.cpp b/src/util/obs_util.cpp index 08561fe6..3095b2d3 100644 --- a/src/util/obs_util.cpp +++ b/src/util/obs_util.cpp @@ -21,7 +21,7 @@ #include "lang.h" #include -QString util_get_data_file(const QString &file_name) +QString util_get_data_file_legacy(const QString &file_name) { QDir home = QDir::homePath(); #if UNIX @@ -123,4 +123,4 @@ inline void os_set_thread_name(const char *name) } __except (EXCEPTION_CONTINUE_EXECUTION) { } } -#endif \ No newline at end of file +#endif diff --git a/src/util/obs_util.hpp b/src/util/obs_util.hpp index e96aa129..db438564 100644 --- a/src/util/obs_util.hpp +++ b/src/util/obs_util.hpp @@ -45,8 +45,9 @@ bool util_write_json(const QString &path, const QJsonDocument &doc); /* Get file path to /home/user/.config/ * or C:\Users\user\* + * This is deprecated and only used to load old files */ -QString util_get_data_file(const QString &file_name); +QString util_get_data_file_legacy(const QString &file_name); /* Source: * github.com/obsproject/obs-studio/blob/master/UI/frontend-plugins/frontend-tools/auto-scene-switcher-win.cpp @@ -59,4 +60,4 @@ extern void GetCurrentWindowTitle(std::string &title); #if _WIN32 extern void os_set_thread_name(const char *); -#endif \ No newline at end of file +#endif