mirror of
https://github.com/obsproject/obs-studio.git
synced 2026-08-30 17:58:37 +08:00
UI: Add import/export of scene collections & profiles
Closes jp9000/obs-studio#721
This commit is contained in:
@@ -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());
|
||||
|
||||
Reference in New Issue
Block a user