2016-02-23 23:16:51 +00:00
|
|
|
/******************************************************************************
|
|
|
|
Copyright (C) 2015 by Hugh Bailey <obs.jim@gmail.com>
|
|
|
|
|
|
|
|
This program is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation, either version 2 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
******************************************************************************/
|
|
|
|
|
|
|
|
#include <obs.hpp>
|
|
|
|
#include <util/util.hpp>
|
|
|
|
#include <QMessageBox>
|
|
|
|
#include <QVariant>
|
2017-04-19 19:54:15 +00:00
|
|
|
#include <QFileDialog>
|
|
|
|
#include <QStandardPaths>
|
2016-02-23 23:16:51 +00:00
|
|
|
#include "item-widget-helpers.hpp"
|
|
|
|
#include "window-basic-main.hpp"
|
2020-03-25 08:07:22 +00:00
|
|
|
#include "window-importer.hpp"
|
2016-02-23 23:16:51 +00:00
|
|
|
#include "window-namedialog.hpp"
|
|
|
|
#include "qt-wrappers.hpp"
|
|
|
|
|
2016-10-10 19:01:40 +00:00
|
|
|
using namespace std;
|
|
|
|
|
2019-09-22 21:19:10 +00:00
|
|
|
void EnumSceneCollections(std::function<bool(const char *, const char *)> &&cb)
|
2016-02-23 23:16:51 +00:00
|
|
|
{
|
|
|
|
char path[512];
|
|
|
|
os_glob_t *glob;
|
|
|
|
|
|
|
|
int ret = GetConfigPath(path, sizeof(path),
|
2019-09-22 21:19:10 +00:00
|
|
|
"obs-studio/basic/scenes/*.json");
|
2016-02-23 23:16:51 +00:00
|
|
|
if (ret <= 0) {
|
|
|
|
blog(LOG_WARNING, "Failed to get config path for scene "
|
2019-09-22 21:19:10 +00:00
|
|
|
"collections");
|
2016-02-23 23:16:51 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (os_glob(path, 0, &glob) != 0) {
|
|
|
|
blog(LOG_WARNING, "Failed to glob scene collections");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (size_t i = 0; i < glob->gl_pathc; i++) {
|
|
|
|
const char *filePath = glob->gl_pathv[i].path;
|
|
|
|
|
|
|
|
if (glob->gl_pathv[i].directory)
|
|
|
|
continue;
|
|
|
|
|
2019-09-22 21:19:10 +00:00
|
|
|
obs_data_t *data =
|
|
|
|
obs_data_create_from_json_file_safe(filePath, "bak");
|
2016-02-23 23:16:51 +00:00
|
|
|
std::string name = obs_data_get_string(data, "name");
|
|
|
|
|
|
|
|
/* if no name found, use the file name as the name
|
|
|
|
* (this only happens when switching to the new version) */
|
|
|
|
if (name.empty()) {
|
|
|
|
name = strrchr(filePath, '/') + 1;
|
|
|
|
name.resize(name.size() - 5);
|
|
|
|
}
|
|
|
|
|
|
|
|
obs_data_release(data);
|
|
|
|
|
|
|
|
if (!cb(name.c_str(), filePath))
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
os_globfree(glob);
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool SceneCollectionExists(const char *findName)
|
|
|
|
{
|
|
|
|
bool found = false;
|
2019-09-22 21:19:10 +00:00
|
|
|
auto func = [&](const char *name, const char *) {
|
2016-02-23 23:16:51 +00:00
|
|
|
if (strcmp(name, findName) == 0) {
|
|
|
|
found = true;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
};
|
|
|
|
|
|
|
|
EnumSceneCollections(func);
|
|
|
|
return found;
|
|
|
|
}
|
|
|
|
|
2019-12-10 19:31:54 +00:00
|
|
|
static bool GetUnusedSceneCollectionFile(std::string &name, std::string &file)
|
|
|
|
{
|
|
|
|
char path[512];
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
if (!GetFileSafeName(name.c_str(), file)) {
|
|
|
|
blog(LOG_WARNING, "Failed to create safe file name for '%s'",
|
|
|
|
name.c_str());
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
ret = GetConfigPath(path, sizeof(path), "obs-studio/basic/scenes/");
|
|
|
|
if (ret <= 0) {
|
|
|
|
blog(LOG_WARNING, "Failed to get scene collection config path");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
file.insert(0, path);
|
|
|
|
|
|
|
|
if (!GetClosestUnusedFileName(file, "json")) {
|
|
|
|
blog(LOG_WARNING, "Failed to get closest file name for %s",
|
|
|
|
file.c_str());
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
file.erase(file.size() - 5, 5);
|
2020-10-01 20:15:25 +00:00
|
|
|
file.erase(0, strlen(path));
|
2019-12-10 19:31:54 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2016-02-23 23:16:51 +00:00
|
|
|
static bool GetSceneCollectionName(QWidget *parent, std::string &name,
|
2019-09-22 21:19:10 +00:00
|
|
|
std::string &file,
|
|
|
|
const char *oldName = nullptr)
|
2016-02-23 23:16:51 +00:00
|
|
|
{
|
|
|
|
bool rename = oldName != nullptr;
|
|
|
|
const char *title;
|
|
|
|
const char *text;
|
|
|
|
|
|
|
|
if (rename) {
|
|
|
|
title = Str("Basic.Main.RenameSceneCollection.Title");
|
2019-09-22 21:19:10 +00:00
|
|
|
text = Str("Basic.Main.AddSceneCollection.Text");
|
2016-02-23 23:16:51 +00:00
|
|
|
} else {
|
|
|
|
title = Str("Basic.Main.AddSceneCollection.Title");
|
2019-09-22 21:19:10 +00:00
|
|
|
text = Str("Basic.Main.AddSceneCollection.Text");
|
2016-02-23 23:16:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
for (;;) {
|
2019-09-22 21:19:10 +00:00
|
|
|
bool success = NameDialog::AskForName(parent, title, text, name,
|
|
|
|
QT_UTF8(oldName));
|
2016-02-23 23:16:51 +00:00
|
|
|
if (!success) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if (name.empty()) {
|
2019-07-27 12:47:10 +00:00
|
|
|
OBSMessageBox::warning(parent,
|
2019-09-22 21:19:10 +00:00
|
|
|
QTStr("NoNameEntered.Title"),
|
|
|
|
QTStr("NoNameEntered.Text"));
|
2016-02-23 23:16:51 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (SceneCollectionExists(name.c_str())) {
|
2019-07-27 12:47:10 +00:00
|
|
|
OBSMessageBox::warning(parent,
|
2019-09-22 21:19:10 +00:00
|
|
|
QTStr("NameExists.Title"),
|
|
|
|
QTStr("NameExists.Text"));
|
2016-02-23 23:16:51 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2019-12-10 19:31:54 +00:00
|
|
|
if (!GetUnusedSceneCollectionFile(name, file)) {
|
2016-02-23 23:16:51 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2018-12-16 16:14:58 +00:00
|
|
|
bool OBSBasic::AddSceneCollection(bool create_new, const QString &qname)
|
2016-02-23 23:16:51 +00:00
|
|
|
{
|
|
|
|
std::string name;
|
|
|
|
std::string file;
|
|
|
|
|
2018-12-16 16:14:58 +00:00
|
|
|
if (qname.isEmpty()) {
|
|
|
|
if (!GetSceneCollectionName(this, name, file))
|
|
|
|
return false;
|
|
|
|
} else {
|
|
|
|
name = QT_TO_UTF8(qname);
|
|
|
|
if (SceneCollectionExists(name.c_str()))
|
|
|
|
return false;
|
2019-12-10 19:31:54 +00:00
|
|
|
|
|
|
|
if (!GetUnusedSceneCollectionFile(name, file)) {
|
|
|
|
return false;
|
|
|
|
}
|
2018-12-16 16:14:58 +00:00
|
|
|
}
|
2016-02-23 23:16:51 +00:00
|
|
|
|
|
|
|
SaveProjectNow();
|
|
|
|
|
|
|
|
config_set_string(App()->GlobalConfig(), "Basic", "SceneCollection",
|
2019-09-22 21:19:10 +00:00
|
|
|
name.c_str());
|
2016-02-23 23:16:51 +00:00
|
|
|
config_set_string(App()->GlobalConfig(), "Basic", "SceneCollectionFile",
|
2019-09-22 21:19:10 +00:00
|
|
|
file.c_str());
|
2016-02-23 23:16:51 +00:00
|
|
|
if (create_new) {
|
|
|
|
CreateDefaultScene(false);
|
|
|
|
}
|
|
|
|
SaveProjectNow();
|
|
|
|
RefreshSceneCollections();
|
|
|
|
|
|
|
|
blog(LOG_INFO, "Added scene collection '%s' (%s, %s.json)",
|
2019-09-22 21:19:10 +00:00
|
|
|
name.c_str(), create_new ? "clean" : "duplicate", file.c_str());
|
2016-02-23 23:16:51 +00:00
|
|
|
blog(LOG_INFO, "------------------------------------------------");
|
|
|
|
|
|
|
|
UpdateTitleBar();
|
2016-10-10 19:01:40 +00:00
|
|
|
|
|
|
|
if (api) {
|
|
|
|
api->on_event(OBS_FRONTEND_EVENT_SCENE_COLLECTION_LIST_CHANGED);
|
|
|
|
api->on_event(OBS_FRONTEND_EVENT_SCENE_COLLECTION_CHANGED);
|
|
|
|
}
|
2018-12-16 16:14:58 +00:00
|
|
|
|
|
|
|
return true;
|
2016-02-23 23:16:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void OBSBasic::RefreshSceneCollections()
|
|
|
|
{
|
2019-09-22 21:19:10 +00:00
|
|
|
QList<QAction *> menuActions = ui->sceneCollectionMenu->actions();
|
2016-02-23 23:16:51 +00:00
|
|
|
int count = 0;
|
|
|
|
|
|
|
|
for (int i = 0; i < menuActions.count(); i++) {
|
2017-04-19 19:54:15 +00:00
|
|
|
QVariant v = menuActions[i]->property("file_name");
|
2016-02-23 23:16:51 +00:00
|
|
|
if (v.typeName() != nullptr)
|
|
|
|
delete menuActions[i];
|
|
|
|
}
|
|
|
|
|
2019-09-22 21:19:10 +00:00
|
|
|
const char *cur_name = config_get_string(App()->GlobalConfig(), "Basic",
|
|
|
|
"SceneCollection");
|
2016-02-23 23:16:51 +00:00
|
|
|
|
2019-09-22 21:19:10 +00:00
|
|
|
auto addCollection = [&](const char *name, const char *path) {
|
2016-02-23 23:16:51 +00:00
|
|
|
std::string file = strrchr(path, '/') + 1;
|
|
|
|
file.erase(file.size() - 5, 5);
|
|
|
|
|
|
|
|
QAction *action = new QAction(QT_UTF8(name), this);
|
2017-04-19 19:54:15 +00:00
|
|
|
action->setProperty("file_name", QT_UTF8(path));
|
2019-09-22 21:19:10 +00:00
|
|
|
connect(action, &QAction::triggered, this,
|
|
|
|
&OBSBasic::ChangeSceneCollection);
|
2016-02-23 23:16:51 +00:00
|
|
|
action->setCheckable(true);
|
|
|
|
|
|
|
|
action->setChecked(strcmp(name, cur_name) == 0);
|
|
|
|
|
|
|
|
ui->sceneCollectionMenu->addAction(action);
|
|
|
|
count++;
|
|
|
|
return true;
|
|
|
|
};
|
|
|
|
|
|
|
|
EnumSceneCollections(addCollection);
|
|
|
|
|
2017-06-29 19:01:10 +00:00
|
|
|
/* force saving of first scene collection on first run, otherwise
|
|
|
|
* no scene collections will show up */
|
|
|
|
if (!count) {
|
|
|
|
long prevDisableVal = disableSaving;
|
|
|
|
|
|
|
|
disableSaving = 0;
|
|
|
|
SaveProjectNow();
|
|
|
|
disableSaving = prevDisableVal;
|
|
|
|
|
|
|
|
EnumSceneCollections(addCollection);
|
|
|
|
}
|
|
|
|
|
2016-02-23 23:16:51 +00:00
|
|
|
ui->actionRemoveSceneCollection->setEnabled(count > 1);
|
2017-04-19 19:54:15 +00:00
|
|
|
|
2019-09-22 21:19:10 +00:00
|
|
|
OBSBasic *main = reinterpret_cast<OBSBasic *>(App()->GetMainWindow());
|
2017-06-29 19:01:10 +00:00
|
|
|
|
|
|
|
main->ui->actionPasteFilters->setEnabled(false);
|
|
|
|
main->ui->actionPasteRef->setEnabled(false);
|
|
|
|
main->ui->actionPasteDup->setEnabled(false);
|
2016-02-23 23:16:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void OBSBasic::on_actionNewSceneCollection_triggered()
|
|
|
|
{
|
|
|
|
AddSceneCollection(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
void OBSBasic::on_actionDupSceneCollection_triggered()
|
|
|
|
{
|
|
|
|
AddSceneCollection(false);
|
|
|
|
}
|
|
|
|
|
|
|
|
void OBSBasic::on_actionRenameSceneCollection_triggered()
|
|
|
|
{
|
|
|
|
std::string name;
|
|
|
|
std::string file;
|
|
|
|
|
2019-09-22 21:19:10 +00:00
|
|
|
std::string oldFile = config_get_string(App()->GlobalConfig(), "Basic",
|
|
|
|
"SceneCollectionFile");
|
|
|
|
const char *oldName = config_get_string(App()->GlobalConfig(), "Basic",
|
|
|
|
"SceneCollection");
|
2016-02-23 23:16:51 +00:00
|
|
|
|
|
|
|
bool success = GetSceneCollectionName(this, name, file, oldName);
|
|
|
|
if (!success)
|
|
|
|
return;
|
|
|
|
|
|
|
|
config_set_string(App()->GlobalConfig(), "Basic", "SceneCollection",
|
2019-09-22 21:19:10 +00:00
|
|
|
name.c_str());
|
2016-02-23 23:16:51 +00:00
|
|
|
config_set_string(App()->GlobalConfig(), "Basic", "SceneCollectionFile",
|
2019-09-22 21:19:10 +00:00
|
|
|
file.c_str());
|
2016-02-23 23:16:51 +00:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
oldFile.insert(0, path);
|
|
|
|
oldFile += ".json";
|
|
|
|
os_unlink(oldFile.c_str());
|
2016-05-24 19:53:01 +00:00
|
|
|
oldFile += ".bak";
|
|
|
|
os_unlink(oldFile.c_str());
|
2016-02-23 23:16:51 +00:00
|
|
|
|
|
|
|
blog(LOG_INFO, "------------------------------------------------");
|
|
|
|
blog(LOG_INFO, "Renamed scene collection to '%s' (%s.json)",
|
2019-09-22 21:19:10 +00:00
|
|
|
name.c_str(), file.c_str());
|
2016-02-23 23:16:51 +00:00
|
|
|
blog(LOG_INFO, "------------------------------------------------");
|
|
|
|
|
|
|
|
UpdateTitleBar();
|
|
|
|
RefreshSceneCollections();
|
2016-10-10 19:01:40 +00:00
|
|
|
|
|
|
|
if (api) {
|
|
|
|
api->on_event(OBS_FRONTEND_EVENT_SCENE_COLLECTION_LIST_CHANGED);
|
|
|
|
api->on_event(OBS_FRONTEND_EVENT_SCENE_COLLECTION_CHANGED);
|
|
|
|
}
|
2016-02-23 23:16:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void OBSBasic::on_actionRemoveSceneCollection_triggered()
|
|
|
|
{
|
|
|
|
std::string newName;
|
|
|
|
std::string newPath;
|
|
|
|
|
2019-09-22 21:19:10 +00:00
|
|
|
std::string oldFile = config_get_string(App()->GlobalConfig(), "Basic",
|
|
|
|
"SceneCollectionFile");
|
|
|
|
std::string oldName = config_get_string(App()->GlobalConfig(), "Basic",
|
|
|
|
"SceneCollection");
|
2016-02-23 23:16:51 +00:00
|
|
|
|
2019-09-22 21:19:10 +00:00
|
|
|
auto cb = [&](const char *name, const char *filePath) {
|
2016-02-23 23:16:51 +00:00
|
|
|
if (strcmp(oldName.c_str(), name) != 0) {
|
|
|
|
newName = name;
|
|
|
|
newPath = filePath;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
};
|
|
|
|
|
|
|
|
EnumSceneCollections(cb);
|
|
|
|
|
|
|
|
/* this should never be true due to menu item being grayed out */
|
|
|
|
if (newPath.empty())
|
|
|
|
return;
|
|
|
|
|
|
|
|
QString text = QTStr("ConfirmRemove.Text");
|
|
|
|
text.replace("$1", QT_UTF8(oldName.c_str()));
|
|
|
|
|
2019-09-22 21:19:10 +00:00
|
|
|
QMessageBox::StandardButton button = OBSMessageBox::question(
|
|
|
|
this, QTStr("ConfirmRemove.Title"), text);
|
2016-02-23 23:16:51 +00:00
|
|
|
if (button == QMessageBox::No)
|
|
|
|
return;
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
oldFile.insert(0, path);
|
|
|
|
oldFile += ".json";
|
|
|
|
os_unlink(oldFile.c_str());
|
|
|
|
oldFile += ".bak";
|
|
|
|
os_unlink(oldFile.c_str());
|
|
|
|
|
|
|
|
Load(newPath.c_str());
|
|
|
|
RefreshSceneCollections();
|
|
|
|
|
2019-09-22 21:19:10 +00:00
|
|
|
const char *newFile = config_get_string(App()->GlobalConfig(), "Basic",
|
|
|
|
"SceneCollectionFile");
|
2016-02-23 23:16:51 +00:00
|
|
|
|
2019-09-22 21:19:10 +00:00
|
|
|
blog(LOG_INFO,
|
|
|
|
"Removed scene collection '%s' (%s.json), "
|
|
|
|
"switched to '%s' (%s.json)",
|
|
|
|
oldName.c_str(), oldFile.c_str(), newName.c_str(), newFile);
|
2016-02-23 23:16:51 +00:00
|
|
|
blog(LOG_INFO, "------------------------------------------------");
|
|
|
|
|
|
|
|
UpdateTitleBar();
|
2016-10-10 19:01:40 +00:00
|
|
|
|
|
|
|
if (api) {
|
|
|
|
api->on_event(OBS_FRONTEND_EVENT_SCENE_COLLECTION_LIST_CHANGED);
|
|
|
|
api->on_event(OBS_FRONTEND_EVENT_SCENE_COLLECTION_CHANGED);
|
|
|
|
}
|
2016-02-23 23:16:51 +00:00
|
|
|
}
|
|
|
|
|
2017-04-19 19:54:15 +00:00
|
|
|
void OBSBasic::on_actionImportSceneCollection_triggered()
|
|
|
|
{
|
2020-03-25 08:07:22 +00:00
|
|
|
OBSImporter *imp;
|
|
|
|
imp = new OBSImporter(this);
|
|
|
|
imp->exec();
|
|
|
|
delete imp;
|
2018-05-29 19:13:02 +00:00
|
|
|
|
2020-03-25 08:07:22 +00:00
|
|
|
RefreshSceneCollections();
|
2017-04-19 19:54:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void OBSBasic::on_actionExportSceneCollection_triggered()
|
|
|
|
{
|
2019-07-27 12:47:10 +00:00
|
|
|
SaveProjectNow();
|
|
|
|
|
2017-04-19 19:54:15 +00:00
|
|
|
char path[512];
|
|
|
|
|
|
|
|
QString home = QDir::homePath();
|
|
|
|
|
2019-09-22 21:19:10 +00:00
|
|
|
QString currentFile = QT_UTF8(config_get_string(
|
|
|
|
App()->GlobalConfig(), "Basic", "SceneCollectionFile"));
|
2017-04-19 19:54:15 +00:00
|
|
|
|
|
|
|
int ret = GetConfigPath(path, 512, "obs-studio/basic/scenes/");
|
|
|
|
if (ret <= 0) {
|
|
|
|
blog(LOG_WARNING, "Failed to get scene collection config path");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2020-10-01 20:15:25 +00:00
|
|
|
QString exportFile =
|
|
|
|
SaveFile(this, QTStr("Basic.MainMenu.SceneCollection.Export"),
|
|
|
|
home + "/" + currentFile, "JSON Files (*.json)");
|
2017-04-19 19:54:15 +00:00
|
|
|
|
|
|
|
string file = QT_TO_UTF8(exportFile);
|
|
|
|
|
2018-02-19 19:54:37 +00:00
|
|
|
if (!exportFile.isEmpty() && !exportFile.isNull()) {
|
|
|
|
if (QFile::exists(exportFile))
|
|
|
|
QFile::remove(exportFile);
|
|
|
|
|
2017-04-19 19:54:15 +00:00
|
|
|
QFile::copy(path + currentFile + ".json", exportFile);
|
2018-02-19 19:54:37 +00:00
|
|
|
}
|
2017-04-19 19:54:15 +00:00
|
|
|
}
|
|
|
|
|
2016-02-23 23:16:51 +00:00
|
|
|
void OBSBasic::ChangeSceneCollection()
|
|
|
|
{
|
2019-09-22 21:19:10 +00:00
|
|
|
QAction *action = reinterpret_cast<QAction *>(sender());
|
2016-02-23 23:16:51 +00:00
|
|
|
std::string fileName;
|
|
|
|
|
|
|
|
if (!action)
|
|
|
|
return;
|
|
|
|
|
2017-04-19 19:54:15 +00:00
|
|
|
fileName = QT_TO_UTF8(action->property("file_name").value<QString>());
|
2016-02-23 23:16:51 +00:00
|
|
|
if (fileName.empty())
|
|
|
|
return;
|
|
|
|
|
2019-09-22 21:19:10 +00:00
|
|
|
const char *oldName = config_get_string(App()->GlobalConfig(), "Basic",
|
|
|
|
"SceneCollection");
|
2016-02-23 23:16:51 +00:00
|
|
|
if (action->text().compare(QT_UTF8(oldName)) == 0) {
|
|
|
|
action->setChecked(true);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
SaveProjectNow();
|
|
|
|
|
|
|
|
Load(fileName.c_str());
|
|
|
|
RefreshSceneCollections();
|
|
|
|
|
2019-09-22 21:19:10 +00:00
|
|
|
const char *newName = config_get_string(App()->GlobalConfig(), "Basic",
|
|
|
|
"SceneCollection");
|
|
|
|
const char *newFile = config_get_string(App()->GlobalConfig(), "Basic",
|
|
|
|
"SceneCollectionFile");
|
2016-02-23 23:16:51 +00:00
|
|
|
|
2019-09-22 21:19:10 +00:00
|
|
|
blog(LOG_INFO, "Switched to scene collection '%s' (%s.json)", newName,
|
|
|
|
newFile);
|
2016-02-23 23:16:51 +00:00
|
|
|
blog(LOG_INFO, "------------------------------------------------");
|
|
|
|
|
|
|
|
UpdateTitleBar();
|
2016-10-10 19:01:40 +00:00
|
|
|
|
|
|
|
if (api)
|
|
|
|
api->on_event(OBS_FRONTEND_EVENT_SCENE_COLLECTION_CHANGED);
|
2016-02-23 23:16:51 +00:00
|
|
|
}
|