UI: Rewrite profile system to enable user-provided storage location

This change enables loading profiles from locations different than
OBS' own configuration directory.

It also rewrites profile management in the app to work off an in-memory
collection of profiles found on disk and does not require iterating
over directory contents for most profile interactions by the app.
This commit is contained in:
PatTheMav 2024-09-03 16:29:30 +02:00 • committed by Ryan Foster
commit 607d37b423
9 changed files with 1772 additions and 1601 deletions

View file

@ -39,18 +39,24 @@ extern QCefCookieManager *panel_cookies;
/* ------------------------------------------------------------------------- */
#define SERVICE_PATH "service.json"
constexpr std::string_view OBSServiceFileName = "service.json";
static OBSData OpenServiceSettings(std::string &type)
{
char serviceJsonPath[512];
int ret = GetProfilePath(serviceJsonPath, sizeof(serviceJsonPath),
SERVICE_PATH);
if (ret <= 0)
return OBSData();
const OBSBasic *basic =
reinterpret_cast<OBSBasic *>(App()->GetMainWindow());
const OBSProfile &currentProfile = basic->GetCurrentProfile();
OBSDataAutoRelease data =
obs_data_create_from_json_file_safe(serviceJsonPath, "bak");
const std::filesystem::path jsonFilePath =
currentProfile.path /
std::filesystem::u8path(OBSServiceFileName);
if (!std::filesystem::exists(jsonFilePath)) {
return OBSData();
}
OBSDataAutoRelease data = obs_data_create_from_json_file_safe(
jsonFilePath.u8string().c_str(), "bak");
obs_data_set_default_string(data, "type", "rtmp_common");
type = obs_data_get_string(data, "type");