New upstream version 21.1.2+dfsg1
This commit is contained in:
parent
baafb6325b
commit
665f64a933
152 changed files with 3957 additions and 356 deletions
|
|
@ -372,7 +372,7 @@ void OBSBasic::on_actionImportSceneCollection_triggered()
|
|||
{
|
||||
char path[512];
|
||||
|
||||
QString home = QDir::homePath();
|
||||
QString qhome = QDir::homePath();
|
||||
|
||||
int ret = GetConfigPath(path, 512, "obs-studio/basic/scenes/");
|
||||
if (ret <= 0) {
|
||||
|
|
@ -380,25 +380,53 @@ void OBSBasic::on_actionImportSceneCollection_triggered()
|
|||
return;
|
||||
}
|
||||
|
||||
QString file = QFileDialog::getOpenFileName(
|
||||
QString qfilePath = QFileDialog::getOpenFileName(
|
||||
this,
|
||||
QTStr("Basic.MainMenu.SceneCollection.Import"),
|
||||
home,
|
||||
qhome,
|
||||
"JSON Files (*.json)");
|
||||
|
||||
QFileInfo finfo(file);
|
||||
QString filename = finfo.fileName();
|
||||
QFileInfo destinfo(path + filename);
|
||||
QFileInfo finfo(qfilePath);
|
||||
QString qfilename = finfo.fileName();
|
||||
QString qpath = QT_UTF8(path);
|
||||
QFileInfo destinfo(QT_UTF8(path) + qfilename);
|
||||
|
||||
if (!file.isEmpty() && !file.isNull()) {
|
||||
if (!destinfo.exists()) {
|
||||
QFile::copy(file, path + filename);
|
||||
RefreshSceneCollections();
|
||||
} else {
|
||||
OBSMessageBox::information(this,
|
||||
QTStr("Basic.MainMenu.SceneCollection.Import"),
|
||||
QTStr("Basic.MainMenu.SceneCollection.Exists"));
|
||||
if (!qfilePath.isEmpty() && !qfilePath.isNull()) {
|
||||
string absPath = QT_TO_UTF8(finfo.absoluteFilePath());
|
||||
OBSData scenedata =
|
||||
obs_data_create_from_json_file(absPath.c_str());
|
||||
obs_data_release(scenedata);
|
||||
|
||||
string origName = obs_data_get_string(scenedata, "name");
|
||||
string name = origName;
|
||||
string file;
|
||||
int inc = 1;
|
||||
|
||||
while (SceneCollectionExists(name.c_str())) {
|
||||
name = origName + " (" + to_string(++inc) + ")";
|
||||
}
|
||||
|
||||
obs_data_set_string(scenedata, "name", name.c_str());
|
||||
|
||||
if (!GetFileSafeName(name.c_str(), file)) {
|
||||
blog(LOG_WARNING, "Failed to create "
|
||||
"safe file name for '%s'",
|
||||
name.c_str());
|
||||
return;
|
||||
}
|
||||
|
||||
string filePath = path + file;
|
||||
|
||||
if (!GetClosestUnusedFileName(filePath, "json")) {
|
||||
blog(LOG_WARNING, "Failed to get "
|
||||
"closest file name for %s",
|
||||
file.c_str());
|
||||
return;
|
||||
}
|
||||
|
||||
obs_data_save_json_safe(scenedata, filePath.c_str(),
|
||||
"tmp", "bak");
|
||||
RefreshSceneCollections();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue