UI: Add import/export of scene collections & profiles

Closes jp9000/obs-studio#721
This commit is contained in:
cg2121
2016-12-08 17:09:22 -06:00
committed by jp9000
parent 42a646f28e
commit 9f0c48d9c7
5 changed files with 179 additions and 0 deletions
@@ -19,6 +19,8 @@
#include <util/util.hpp>
#include <QMessageBox>
#include <QVariant>
#include <QFileDialog>
#include <QStandardPaths>
#include "item-widget-helpers.hpp"
#include "window-basic-main.hpp"
#include "window-namedialog.hpp"
@@ -347,6 +349,67 @@ void OBSBasic::on_actionRemoveSceneCollection_triggered()
}
}
void OBSBasic::on_actionImportSceneCollection_triggered()
{
char path[512];
QString home = QDir::homePath();
int ret = GetConfigPath(path, 512, "obs-studio/basic/scenes/");
if (ret <= 0) {
blog(LOG_WARNING, "Failed to get scene collection config path");
return;
}
QString file = QFileDialog::getOpenFileName(
this,
QTStr("Basic.MainMenu.SceneCollection.Import"),
home,
"JSON Files (*.json)");
QFileInfo finfo(file);
QString filename = finfo.fileName();
QFileInfo destinfo(path + filename);
if (!file.isEmpty() && !file.isNull()) {
if (!destinfo.exists()) {
QFile::copy(file, path + filename);
RefreshSceneCollections();
} else {
QMessageBox::information(this,
QTStr("Basic.MainMenu.SceneCollection.Import"),
QTStr("Basic.MainMenu.SceneCollection.Exists"));
}
}
}
void OBSBasic::on_actionExportSceneCollection_triggered()
{
char path[512];
QString home = QDir::homePath();
QString currentFile = QT_UTF8(config_get_string(App()->GlobalConfig(),
"Basic", "SceneCollectionFile"));
int ret = GetConfigPath(path, 512, "obs-studio/basic/scenes/");
if (ret <= 0) {
blog(LOG_WARNING, "Failed to get scene collection config path");
return;
}
QString exportFile = QFileDialog::getSaveFileName(
0,
QTStr("Basic.MainMenu.SceneCollection.Export"),
home + "/" + currentFile,
"JSON Files (*.json)");
string file = QT_TO_UTF8(exportFile);
if (!exportFile.isEmpty() && !exportFile.isNull())
QFile::copy(path + currentFile + ".json", exportFile);
}
void OBSBasic::ChangeSceneCollection()
{
QAction *action = reinterpret_cast<QAction*>(sender());