mirror of
https://github.com/obsproject/obs-studio.git
synced 2026-05-12 09:16:10 -04:00
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:
@@ -2136,12 +2136,16 @@ OBSBasicSettings::CreateEncoderPropertyView(const char *encoder,
|
||||
OBSPropertiesView *view;
|
||||
|
||||
if (path) {
|
||||
char encoderJsonPath[512];
|
||||
int ret = GetProfilePath(encoderJsonPath,
|
||||
sizeof(encoderJsonPath), path);
|
||||
if (ret > 0) {
|
||||
const OBSBasic *basic =
|
||||
reinterpret_cast<OBSBasic *>(App()->GetMainWindow());
|
||||
const OBSProfile ¤tProfile = basic->GetCurrentProfile();
|
||||
|
||||
const std::filesystem::path jsonFilePath =
|
||||
currentProfile.path / std::filesystem::u8path(path);
|
||||
|
||||
if (!jsonFilePath.empty()) {
|
||||
obs_data_t *data = obs_data_create_from_json_file_safe(
|
||||
encoderJsonPath, "bak");
|
||||
jsonFilePath.u8string().c_str(), "bak");
|
||||
obs_data_apply(settings, data);
|
||||
obs_data_release(data);
|
||||
}
|
||||
@@ -3748,17 +3752,22 @@ static inline const char *SplitFileTypeFromIdx(int idx)
|
||||
|
||||
static void WriteJsonData(OBSPropertiesView *view, const char *path)
|
||||
{
|
||||
char full_path[512];
|
||||
|
||||
if (!view || !WidgetChanged(view))
|
||||
return;
|
||||
|
||||
int ret = GetProfilePath(full_path, sizeof(full_path), path);
|
||||
if (ret > 0) {
|
||||
const OBSBasic *basic =
|
||||
reinterpret_cast<OBSBasic *>(App()->GetMainWindow());
|
||||
const OBSProfile ¤tProfile = basic->GetCurrentProfile();
|
||||
|
||||
const std::filesystem::path jsonFilePath =
|
||||
currentProfile.path / std::filesystem::u8path(path);
|
||||
|
||||
if (!jsonFilePath.empty()) {
|
||||
obs_data_t *settings = view->GetSettings();
|
||||
if (settings) {
|
||||
obs_data_save_json_safe(settings, full_path, "tmp",
|
||||
"bak");
|
||||
obs_data_save_json_safe(settings,
|
||||
jsonFilePath.u8string().c_str(),
|
||||
"tmp", "bak");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5691,14 +5700,16 @@ void OBSBasicSettings::AdvReplayBufferChanged()
|
||||
if (!settings)
|
||||
return;
|
||||
|
||||
char encoderJsonPath[512];
|
||||
int ret = GetProfilePath(encoderJsonPath,
|
||||
sizeof(encoderJsonPath),
|
||||
"recordEncoder.json");
|
||||
if (ret > 0) {
|
||||
const OBSProfile ¤tProfile = main->GetCurrentProfile();
|
||||
|
||||
const std::filesystem::path jsonFilePath =
|
||||
currentProfile.path /
|
||||
std::filesystem::u8path("recordEncoder.json");
|
||||
|
||||
if (!jsonFilePath.empty()) {
|
||||
OBSDataAutoRelease data =
|
||||
obs_data_create_from_json_file_safe(
|
||||
encoderJsonPath, "bak");
|
||||
jsonFilePath.u8string().c_str(), "bak");
|
||||
obs_data_apply(settings, data);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user