UI: Remove scene collection undo/redo actions
This commit is contained in:
parent
90df8d44df
commit
fb42a2ad8c
@ -168,39 +168,6 @@ bool OBSBasic::AddSceneCollection(bool create_new, const QString &qname)
|
||||
|
||||
new_collection(file, name);
|
||||
|
||||
auto undo = [this, oldName = name](const std::string &data) {
|
||||
std::string newPath;
|
||||
auto cb = [&](const char *name, const char *filePath) {
|
||||
if (strcmp(oldName.c_str(), name) != 0) {
|
||||
newPath = filePath;
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
};
|
||||
|
||||
EnumSceneCollections(cb);
|
||||
char path[512];
|
||||
int ret = GetConfigPath(path, 512, "obs-studio/basic/scenes/");
|
||||
if (ret <= 0) {
|
||||
blog(LOG_WARNING,
|
||||
"Failed to get scene collection config path");
|
||||
return;
|
||||
}
|
||||
std::string file = path + data + ".json";
|
||||
os_unlink(file.c_str());
|
||||
file += ".bak";
|
||||
os_unlink(file.c_str());
|
||||
Load(newPath.c_str());
|
||||
RefreshSceneCollections();
|
||||
};
|
||||
|
||||
auto redo = [new_collection, file, name](const std::string &) {
|
||||
new_collection(file, name);
|
||||
};
|
||||
|
||||
undo_s.add_action(QTStr("Undo.Add").arg(name.c_str()), undo, redo, file,
|
||||
"");
|
||||
|
||||
blog(LOG_INFO, "Added scene collection '%s' (%s, %s.json)",
|
||||
name.c_str(), create_new ? "clean" : "duplicate", file.c_str());
|
||||
blog(LOG_INFO, "------------------------------------------------");
|
||||
@ -308,59 +275,6 @@ void OBSBasic::on_actionRenameSceneCollection_triggered()
|
||||
return;
|
||||
}
|
||||
|
||||
auto undo = [name = oname, file = oldFile, of = file,
|
||||
this](const std::string &) {
|
||||
config_set_string(App()->GlobalConfig(), "Basic",
|
||||
"SceneCollection", name.c_str());
|
||||
config_set_string(App()->GlobalConfig(), "Basic",
|
||||
"SceneCollectionFile", file.c_str());
|
||||
SaveProjectNow();
|
||||
|
||||
char path[512];
|
||||
int ret = GetConfigPath(path, 512, "obs-studio/basic/scenes/");
|
||||
if (ret <= 0) {
|
||||
blog(LOG_WARNING,
|
||||
"Failed to get scene collection config path");
|
||||
return;
|
||||
}
|
||||
std::string oldFile = of;
|
||||
|
||||
oldFile.insert(0, path);
|
||||
oldFile += ".json";
|
||||
os_unlink(oldFile.c_str());
|
||||
oldFile += ".bak";
|
||||
os_unlink(oldFile.c_str());
|
||||
|
||||
UpdateTitleBar();
|
||||
RefreshSceneCollections();
|
||||
};
|
||||
|
||||
auto redo = [of = oldFile, name, file, this](const std::string &) {
|
||||
config_set_string(App()->GlobalConfig(), "Basic",
|
||||
"SceneCollection", name.c_str());
|
||||
config_set_string(App()->GlobalConfig(), "Basic",
|
||||
"SceneCollectionFile", file.c_str());
|
||||
SaveProjectNow();
|
||||
|
||||
char path[512];
|
||||
int ret = GetConfigPath(path, 512, "obs-studio/basic/scenes/");
|
||||
if (ret <= 0) {
|
||||
blog(LOG_WARNING,
|
||||
"Failed to get scene collection config path");
|
||||
return;
|
||||
}
|
||||
std::string oldFile = of;
|
||||
|
||||
oldFile.insert(0, path);
|
||||
oldFile += ".json";
|
||||
os_unlink(oldFile.c_str());
|
||||
oldFile += ".bak";
|
||||
os_unlink(oldFile.c_str());
|
||||
|
||||
UpdateTitleBar();
|
||||
RefreshSceneCollections();
|
||||
};
|
||||
|
||||
oldFile.insert(0, path);
|
||||
oldFile += ".json";
|
||||
os_unlink(oldFile.c_str());
|
||||
@ -375,9 +289,6 @@ void OBSBasic::on_actionRenameSceneCollection_triggered()
|
||||
UpdateTitleBar();
|
||||
RefreshSceneCollections();
|
||||
|
||||
undo_s.add_action(QTStr("Undo.Rename").arg(name.c_str()), undo, redo,
|
||||
"", "");
|
||||
|
||||
if (api) {
|
||||
api->on_event(OBS_FRONTEND_EVENT_SCENE_COLLECTION_LIST_CHANGED);
|
||||
api->on_event(OBS_FRONTEND_EVENT_SCENE_COLLECTION_CHANGED);
|
||||
@ -427,31 +338,6 @@ void OBSBasic::on_actionRemoveSceneCollection_triggered()
|
||||
|
||||
oldFile.insert(0, path);
|
||||
oldFile += ".json";
|
||||
obs_data_t *data =
|
||||
obs_data_create_from_json_file_safe(oldFile.c_str(), "bak");
|
||||
obs_data_set_string(data, "undo_filename", oldFile.c_str());
|
||||
auto undo = [this](const std::string &data) {
|
||||
obs_data_t *dat = obs_data_create_from_json(data.c_str());
|
||||
LoadData(dat, obs_data_get_string(dat, "undo_filename"));
|
||||
SaveProjectNow();
|
||||
RefreshSceneCollections();
|
||||
obs_data_release(dat);
|
||||
};
|
||||
|
||||
auto redo = [this, of = oldFile, newPath](const std::string &) {
|
||||
std::string oldFile = of;
|
||||
os_unlink(oldFile.c_str());
|
||||
oldFile += ".bak";
|
||||
os_unlink(oldFile.c_str());
|
||||
|
||||
Load(newPath.c_str());
|
||||
RefreshSceneCollections();
|
||||
};
|
||||
|
||||
std::string undo_data = std::string(obs_data_get_json(data));
|
||||
undo_s.add_action(QTStr("Undo.Delete").arg(oldName.c_str()), undo, redo,
|
||||
undo_data, "");
|
||||
obs_data_release(data);
|
||||
|
||||
os_unlink(oldFile.c_str());
|
||||
oldFile += ".bak";
|
||||
|
Loading…
x
Reference in New Issue
Block a user